Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/Listener/LoadViewerScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
use OCP\IPreview;
use OCP\Util;

Expand All @@ -22,13 +23,16 @@
* @psalm-api
*/
class LoadViewerScript implements IEventListener {
private IConfig $config;
private IInitialState $initialStateService;
private IPreview $previewManager;

public function __construct(
IConfig $config,
IInitialState $initialStateService,
IPreview $previewManager,
) {
$this->config = $config;
$this->initialStateService = $initialStateService;
$this->previewManager = $previewManager;
}
Expand All @@ -43,5 +47,10 @@ public function handle(Event $event): void {
Util::addInitScript(Application::APP_ID, 'viewer-init');
Util::addScript(Application::APP_ID, 'viewer-main', 'files');
$this->initialStateService->provideInitialState('enabled_preview_providers', array_keys($this->previewManager->getProviders()));
$this->initialStateService->provideInitialState('disable_preview',$this->getSystemValue('disable_preview_in_viewer'));
}

public function getSystemValue(string $key) {
return $this->config->getSystemValue($key, false);
}
}
8 changes: 8 additions & 0 deletions src/components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ import { findLivePhotoPeerFromFileId } from '../utils/livePhotoUtils'
import { getDavPath } from '../utils/fileUtils'
import { preloadMedia } from '../services/mediaPreloader'

import { loadState } from '@nextcloud/initial-state'

Vue.use(AsyncComputed)

export default {
Expand Down Expand Up @@ -117,6 +119,7 @@ export default {
pinchDistance: 0,
pinchStartZoomRatio: 1,
pointerCache: [],
disablePreview: loadState(appName, 'disable_preview', false)
}
},

Expand Down Expand Up @@ -180,6 +183,11 @@ export default {
return this.src
}

// If disablePreview is set in config.php then return the original file source
if(this.disablePreview) {
return this.src;
}

// If there is no preview and we have a direct source
// load it instead
if (this.source && !this.hasPreview && !this.previewUrl) {
Expand Down