|
28 | 28 | use OCA\Files\Event\LoadAdditionalScriptsEvent;
|
29 | 29 | use OCA\Viewer\AppInfo\Application;
|
30 | 30 | use OCA\Viewer\Event\LoadViewer;
|
| 31 | +use OCP\AppFramework\Services\IAppConfig; |
31 | 32 | use OCP\AppFramework\Services\IInitialState;
|
32 | 33 | use OCP\EventDispatcher\Event;
|
33 | 34 | use OCP\EventDispatcher\IEventListener;
|
|
40 | 41 | class LoadViewerScript implements IEventListener {
|
41 | 42 | private IInitialState $initialStateService;
|
42 | 43 | private IPreview $previewManager;
|
| 44 | + private IAppConfig $appConfig; |
43 | 45 |
|
44 | 46 | public function __construct(
|
45 | 47 | IInitialState $initialStateService,
|
46 |
| - IPreview $previewManager |
| 48 | + IPreview $previewManager, |
| 49 | + IAppConfig $appConfig |
47 | 50 | ) {
|
48 | 51 | $this->initialStateService = $initialStateService;
|
49 | 52 | $this->previewManager = $previewManager;
|
| 53 | + $this->appConfig = $appConfig; |
50 | 54 | }
|
51 | 55 |
|
52 | 56 | public function handle(Event $event): void {
|
53 | 57 | if (!($event instanceof LoadViewer || $event instanceof LoadAdditionalScriptsEvent)) {
|
54 | 58 | return;
|
55 | 59 | }
|
56 | 60 |
|
| 61 | + $alwaysShowViewer = $this->appConfig->getAppValue('always_show_viewer', 'no') === 'yes'; |
| 62 | + |
57 | 63 | Util::addStyle(Application::APP_ID, 'viewer-init');
|
58 | 64 | Util::addStyle(Application::APP_ID, 'viewer-main');
|
59 | 65 | Util::addInitScript(Application::APP_ID, 'viewer-init');
|
60 | 66 | Util::addScript(Application::APP_ID, 'viewer-main', 'files');
|
61 | 67 | $this->initialStateService->provideInitialState('enabled_preview_providers', array_keys($this->previewManager->getProviders()));
|
| 68 | + $this->initialStateService->provideInitialState("always_show_viewer", $alwaysShowViewer); |
62 | 69 | }
|
63 | 70 | }
|
0 commit comments