88
99namespace OCA \Files \Controller ;
1010
11- use OC \Files \FilenameValidator ;
1211use OC \Files \Filesystem ;
1312use OCA \Files \AppInfo \Application ;
14- use OCA \Files \ConfigLexicon ;
15- use OCA \Files \Event \LoadAdditionalScriptsEvent ;
16- use OCA \Files \Event \LoadSearchPlugins ;
17- use OCA \Files \Event \LoadSidebar ;
18- use OCA \Files \Service \UserConfig ;
19- use OCA \Files \Service \ViewConfig ;
13+ use OCA \Files \Event \LoadFilesApp ;
2014use OCP \App \IAppManager ;
2115use OCP \AppFramework \Controller ;
2216use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
2620use OCP \AppFramework \Http \RedirectResponse ;
2721use OCP \AppFramework \Http \Response ;
2822use OCP \AppFramework \Http \TemplateResponse ;
29- use OCP \AppFramework \Services \IAppConfig ;
3023use OCP \AppFramework \Services \IInitialState ;
31- use OCP \Authentication \TwoFactorAuth \IRegistry ;
32- use OCP \Collaboration \Resources \LoadAdditionalScriptsEvent as ResourcesLoadAdditionalScriptsEvent ;
3324use OCP \EventDispatcher \IEventDispatcher ;
3425use OCP \Files \Folder ;
3526use OCP \Files \IRootFolder ;
3627use OCP \Files \NotFoundException ;
37- use OCP \Files \Template \ITemplateManager ;
38- use OCP \IConfig ;
3928use OCP \IL10N ;
4029use OCP \IRequest ;
4130use OCP \IURLGenerator ;
4231use OCP \IUserSession ;
43- use OCP \Util ;
4432
4533/**
4634 * @package OCA\Files\Controller
@@ -53,18 +41,11 @@ public function __construct(
5341 IRequest $ request ,
5442 private IURLGenerator $ urlGenerator ,
5543 private IL10N $ l10n ,
56- private IConfig $ config ,
5744 private IEventDispatcher $ eventDispatcher ,
5845 private IUserSession $ userSession ,
5946 private IAppManager $ appManager ,
6047 private IRootFolder $ rootFolder ,
6148 private IInitialState $ initialState ,
62- private ITemplateManager $ templateManager ,
63- private UserConfig $ userConfig ,
64- private ViewConfig $ viewConfig ,
65- private FilenameValidator $ filenameValidator ,
66- private IRegistry $ twoFactorRegistry ,
67- private IAppConfig $ appConfig ,
6849 ) {
6950 parent ::__construct ($ appName , $ request );
7051 }
@@ -142,10 +123,6 @@ public function index($dir = '', $view = '', $fileid = null) {
142123 }
143124 }
144125
145- // Load the files we need
146- Util ::addInitScript ('files ' , 'init ' );
147- Util ::addScript ('files ' , 'main ' );
148-
149126 $ user = $ this ->userSession ->getUser ();
150127 $ userId = $ user ->getUID ();
151128
@@ -174,42 +151,8 @@ public function index($dir = '', $view = '', $fileid = null) {
174151 }
175152
176153 $ this ->initialState ->provideInitialState ('storageStats ' , $ storageInfo );
177- $ this ->initialState ->provideInitialState ('config ' , $ this ->userConfig ->getConfigs ());
178- $ this ->initialState ->provideInitialState ('viewConfigs ' , $ this ->viewConfig ->getConfigs ());
179- $ this ->initialState ->provideInitialState ('recent_limit ' , $ this ->appConfig ->getAppValueInt (ConfigLexicon::RECENT_LIMIT , 100 ));
180- // Not yet consumed by the frontend, provided for future implementation
181- $ this ->initialState ->provideInitialState ('group_recent_files ' , $ this ->appConfig ->getAppValueBool (ConfigLexicon::GROUP_RECENT_FILES , false ));
182- $ this ->initialState ->provideInitialState ('recent_files_group_mime_types ' , $ this ->appConfig ->getAppValueArray (ConfigLexicon::RECENT_FILES_GROUP_MIME_TYPES , []));
183- $ this ->initialState ->provideInitialState ('recent_files_group_timespan_minutes ' , $ this ->appConfig ->getAppValueInt (ConfigLexicon::RECENT_FILES_GROUP_TIMESPAN_MINUTES , 2 ));
184-
185- // File sorting user config
186- $ filesSortingConfig = json_decode ($ this ->config ->getUserValue ($ userId , 'files ' , 'files_sorting_configs ' , '{} ' ), true );
187- $ this ->initialState ->provideInitialState ('filesSortingConfig ' , $ filesSortingConfig );
188-
189- // Forbidden file characters (deprecated use capabilities)
190- // TODO: Remove with next release of `@nextcloud/files`
191- $ forbiddenCharacters = $ this ->filenameValidator ->getForbiddenCharacters ();
192- $ this ->initialState ->provideInitialState ('forbiddenCharacters ' , $ forbiddenCharacters );
193-
194- $ event = new LoadAdditionalScriptsEvent ();
195- $ this ->eventDispatcher ->dispatchTyped ($ event );
196- $ this ->eventDispatcher ->dispatchTyped (new ResourcesLoadAdditionalScriptsEvent ());
197- $ this ->eventDispatcher ->dispatchTyped (new LoadSidebar ());
198- $ this ->eventDispatcher ->dispatchTyped (new LoadSearchPlugins ());
199-
200- $ this ->initialState ->provideInitialState ('templates_enabled ' , true );
201- $ this ->initialState ->provideInitialState ('templates_path ' , $ this ->templateManager ->hasTemplateDirectory () ? $ this ->templateManager ->getTemplatePath () : false );
202- $ this ->initialState ->provideInitialState ('templates ' , $ this ->templateManager ->listCreators ());
203- $ this ->initialState ->provideInitialState ('localClientEnabled ' , $ this ->appConfig ->getAppValueBool (ConfigLexicon::LOCAL_CLIENT_INTEGRATION ));
204-
205- $ isTwoFactorEnabled = false ;
206- foreach ($ this ->twoFactorRegistry ->getProviderStates ($ user ) as $ providerId => $ providerState ) {
207- if ($ providerId !== 'backup_codes ' && $ providerState === true ) {
208- $ isTwoFactorEnabled = true ;
209- }
210- }
211154
212- $ this ->initialState -> provideInitialState ( ' isTwoFactorEnabled ' , $ isTwoFactorEnabled );
155+ $ this ->eventDispatcher -> dispatchTyped ( new LoadFilesApp () );
213156
214157 $ response = new TemplateResponse (
215158 Application::APP_ID ,
0 commit comments