|
102 | 102 | </template> |
103 | 103 |
|
104 | 104 | <script> |
105 | | -import { getRootPath } from '../utils/davUtils' |
| 105 | +import Vue from 'vue' |
| 106 | +
|
| 107 | +import '@nextcloud/dialogs/styles/toast.scss' |
| 108 | +import { showError } from '@nextcloud/dialogs' |
| 109 | +
|
106 | 110 | import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' |
107 | 111 | import isFullscreen from '@nextcloud/vue/dist/Mixins/isFullscreen' |
108 | 112 | import isMobile from '@nextcloud/vue/dist/Mixins/isMobile' |
109 | 113 | import Modal from '@nextcloud/vue/dist/Components/Modal' |
110 | | -import Vue from 'vue' |
111 | 114 |
|
112 | 115 | import { extractFilePaths, sortCompare } from '../utils/fileUtils' |
| 116 | +import { getRootPath } from '../utils/davUtils' |
| 117 | +import cancelableRequest from '../utils/CancelableRequest' |
113 | 118 | import Error from '../components/Error' |
114 | 119 | import File from '../models/file' |
115 | | -import Mime from '../mixins/Mime' |
116 | | -import getFileList from '../services/FileList' |
117 | | -import getFileInfo from '../services/FileInfo' |
118 | 120 | import filesActionHandler from '../services/FilesActionHandler' |
119 | | -
|
120 | | -import cancelableRequest from '../utils/CancelableRequest' |
| 121 | +import getFileInfo from '../services/FileInfo' |
| 122 | +import getFileList from '../services/FileList' |
| 123 | +import Mime from '../mixins/Mime' |
121 | 124 |
|
122 | 125 | export default { |
123 | 126 | name: 'Viewer', |
@@ -341,6 +344,14 @@ export default { |
341 | 344 | // get original mime |
342 | 345 | let mime = fileInfo.mime |
343 | 346 |
|
| 347 | + // if we don't have a handler for this mime, abort |
| 348 | + if (!(mime in this.components)) { |
| 349 | + console.error('The following file could not be displayed', fileName, fileInfo) |
| 350 | + showError(t('viewer', 'There is no plugin available to display this file type')) |
| 351 | + this.close() |
| 352 | + return |
| 353 | + } |
| 354 | +
|
344 | 355 | // check if part of a group, if so retrieve full files list |
345 | 356 | const group = this.mimeGroups[mime] |
346 | 357 | if (this.files && this.files.length > 0) { |
@@ -381,14 +392,9 @@ export default { |
381 | 392 | mime = mime.split('/')[0] |
382 | 393 | } |
383 | 394 |
|
384 | | - // if we have a valid mime, show it! |
385 | | - if (this.components[mime]) { |
386 | | - this.currentFile = new File(fileInfo, mime, this.components[mime]) |
387 | | - this.updatePreviousNext() |
388 | | - } else { |
389 | | - console.error('The following file could not be displayed', fileName, fileInfo) |
390 | | - this.close() |
391 | | - } |
| 395 | + // show file |
| 396 | + this.currentFile = new File(fileInfo, mime, this.components[mime]) |
| 397 | + this.updatePreviousNext() |
392 | 398 |
|
393 | 399 | // if sidebar was opened before, let's update the file |
394 | 400 | this.changeSidebar() |
|
0 commit comments