Skip to content

Commit 2415628

Browse files
skjnldsvnextcloud-command
authored andcommitted
fix: file list update
Signed-off-by: skjnldsv <skjnldsv@protonmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent 37844a4 commit 2415628

7 files changed

Lines changed: 22 additions & 6 deletions

File tree

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/viewer-main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/* extracted by css-entry-points-plugin */
2-
@import './main-CvEdi1qV.chunk.css';
2+
@import './main-D70yuWu9.chunk.css';
33
@import './viewerAction-60RCWKf0.chunk.css';

js/viewer-init.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/viewer-main.mjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

js/viewer-main.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/Viewer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ export default class Viewer {
315315
} else {
316316
this._state.fileInfo = fileInfo
317317
}
318+
318319
if (!this._state.el) {
319320
this._state.files = list
320321
this._state.enableSidebar = enableSidebar

src/views/Viewer.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@ export default defineComponent({
415415
return true
416416
}
417417
418+
if (path === this.currentFile.filename) {
419+
// if the path is the same as the current file, we can assume it's the same file
420+
return true
421+
}
422+
418423
if (
419424
fileInfo && fileInfo.fileid === this.currentFile.fileid
420425
&& fileInfo.mtime && fileInfo.mtime === this.currentFile.mtime
@@ -478,12 +483,18 @@ export default defineComponent({
478483
},
479484
480485
files(fileList) {
486+
if (!fileList || !Array.isArray(fileList) || fileList.length === 0) {
487+
logger.warn('No files provided, skipping update')
488+
return
489+
}
490+
481491
// the files list changed, let's update the current opened index
482492
const currentIndex = fileList.findIndex(file => file.filename === this.currentFile.filename)
483493
if (currentIndex > -1) {
484494
this.currentIndex = currentIndex
485495
logger.debug('The files list changed, new current file index is ' + currentIndex)
486496
}
497+
487498
// finally replace the fileList
488499
this.fileList = fileList
489500
},
@@ -619,6 +630,7 @@ export default defineComponent({
619630
620631
// do not open the same file again
621632
if (this.isSameFile(null, path)) {
633+
logger.debug('Viewer already opened with the same path, ignoring', { path })
622634
return
623635
}
624636
@@ -673,6 +685,7 @@ export default defineComponent({
673685
674686
// do not open the same file info again
675687
if (this.isSameFile(fileInfo)) {
688+
logger.debug('Viewer already opened with the same fileInfo, ignoring', { fileInfo })
676689
return
677690
}
678691
@@ -969,6 +982,8 @@ export default defineComponent({
969982
},
970983
971984
cleanup() {
985+
logger.info('Cleaning up viewer')
986+
972987
// reset all properties
973988
this.currentFile = {}
974989
this.comparisonFile = null

0 commit comments

Comments
 (0)