Skip to content

Commit

Permalink
Use the enabled previews config to register images
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Mar 3, 2022
1 parent 86b0921 commit 73c75db
Show file tree
Hide file tree
Showing 8 changed files with 14,787 additions and 11,617 deletions.
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions js/viewer-main.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ object-assign
*/

/**
* @copyright Copyright (c) 2020 Azul <[email protected]>
* @copyright Copyright (c) 2019 Marco Ambrosini <[email protected]>
*
* @author Azul <[email protected]>
* @author Marco Ambrosini <[email protected]>
* @author John Molakvoæ <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
Expand All @@ -203,9 +204,9 @@ object-assign
*/

/**
* @copyright Copyright (c) 2021 John Molakvoæ <[email protected]>
* @copyright Copyright (c) 2020 Azul <[email protected]>
*
* @author John Molakvoæ <[email protected]>
* @author Azul <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
Expand Down
2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion lib/Listener/LoadViewerScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,35 @@

namespace OCA\Viewer\Listener;

use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Viewer\AppInfo\Application;
use OCA\Viewer\Event\LoadViewer;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IPreview;
use OCP\Util;

class LoadViewerScript implements IEventListener {

/** @var IInitialState */
private $initialStateService;

/** @var IPreview */
private $previewManager;

public function __construct(IInitialState $initialStateService,
IPreview $previewManager) {
$this->initialStateService = $initialStateService;
$this->previewManager = $previewManager;
}

public function handle(Event $event): void {
if (!($event instanceof LoadViewer || $event instanceof LoadAdditionalScriptsEvent)) {
return;
}

Util::addScript(Application::APP_ID, 'viewer-main', 'files');
$this->initialStateService->provideInitialState('enabled_preview_providers', array_keys($this->previewManager->getProviders()));
}
}
Loading

0 comments on commit 73c75db

Please sign in to comment.