Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use filename to find current index #2112

Merged
merged 2 commits into from
Jan 9, 2024
Merged
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
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/services/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import Audios from '../models/audios.js'
* File info type definition
*
* @typedef {object} Fileinfo
* @property {string} filename the file name
* @property {string} basename the full path of the file
* @property {string} filename File path of the remote item
* @property {string} basename Base filename of the remote item, no path
* @property {?string} source absolute path of a non-dav file, e.g. a static resource or provided by an app route
* @property {string} mime file MIME type in the format type/sub-type
* @property {string} [previewUrl] URL of the file preview
Expand Down
10 changes: 5 additions & 5 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export default {

files(fileList) {
// the files list changed, let's update the current opened index
const currentIndex = fileList.findIndex(file => file.basename === this.currentFile.basename)
const currentIndex = fileList.findIndex(file => file.filename === this.currentFile.filename)
if (currentIndex > -1) {
this.currentIndex = currentIndex
logger.debug('The files list changed, new current file index is ' + currentIndex)
Expand Down Expand Up @@ -694,7 +694,7 @@ export default {
this.fileList = this.files

// store current position
this.currentIndex = this.fileList.findIndex(file => file.basename === fileInfo.basename)
this.currentIndex = this.fileList.findIndex(file => file.filename === fileInfo.filename)
} else if (group && this.el === null) {
const mimes = this.mimeGroups[group]
? this.mimeGroups[group]
Expand All @@ -715,7 +715,7 @@ export default {
this.fileList = filteredFiles.sort((a, b) => sortCompare(a, b, this.sortingConfig.key, this.sortingConfig.asc))

// store current position
this.currentIndex = this.fileList.findIndex(file => file.basename === fileInfo.basename)
this.currentIndex = this.fileList.findIndex(file => file.filename === fileInfo.filename)
} else {
this.currentIndex = 0
this.fileList = [fileInfo]
Expand Down Expand Up @@ -1137,8 +1137,8 @@ export default {
await axios.delete(url)
emit('files:node:deleted', { fileid })

// fileid is not unique, basename is
const currentIndex = this.fileList.findIndex(file => file.basename === this.currentFile.basename)
// fileid is not unique, basename is not unqiue, filename is
const currentIndex = this.fileList.findIndex(file => file.filename === this.currentFile.filename)
if (this.hasPrevious || this.hasNext) {
// Checking the previous or next file
this.hasPrevious ? this.previous() : this.next()
Expand Down
Loading