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

[stable28] fix: use filename to find current index #2118

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 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 @@ -492,7 +492,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 @@ -691,7 +691,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 @@ -712,7 +712,7 @@ export default {
this.fileList = filteredFiles.sort((a, b) => sortCompare(a, b, 'basename'))

// 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 @@ -1134,8 +1134,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