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

[stable31] fix: invalid keys #2711

Merged
merged 2 commits into from
Jan 28, 2025
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/viewer-init.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* extracted by css-entry-points-plugin */
@import './init-BKhEieqn.chunk.css';
@import './init-Dk7geEdL.chunk.css';
@import './logger-BffjDTy3.chunk.css';
@import './NcActionButton-WAAyMq9-.chunk.css';
@import './NcActionLink-C3uWgqfV.chunk.css';
2 changes: 1 addition & 1 deletion css/viewer-main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* extracted by css-entry-points-plugin */
@import './main-Ck_4WeTm.chunk.css';
@import './main-D756fEgg.chunk.css';
@import './logger-BffjDTy3.chunk.css';
2 changes: 1 addition & 1 deletion js/viewer-init.mjs

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ img, video {
linear-gradient(45deg, transparent 75%, #{$checkered-color} 75%),
linear-gradient(45deg, transparent 75%, #{$checkered-color} 75%),
linear-gradient(45deg, #{$checkered-color} 25%, #fff 25%);
background-size: 2 * $checkered-size 2 * $checkered-size;
background-size: #{2 * $checkered-size} #{2 * $checkered-size};
background-position: 0 0, 0 0, -#{$checkered-size} -#{$checkered-size}, $checkered-size $checkered-size;
}
&.loaded {
Expand Down
37 changes: 22 additions & 15 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:data-handler="handlerId">
<component :is="currentFile.modal"
v-if="!currentFile.failed"
:key="currentFile | uniqueKey"
:key="uniqueKey(currentFile)"
ref="content"
:active="true"
:can-swipe="false"
Expand Down Expand Up @@ -102,7 +102,7 @@
<!-- COMPARE FILE -->
<div v-if="comparisonFile && !comparisonFile.failed && showComparison" class="viewer__file-wrapper">
<component :is="comparisonFile.modal"
:key="comparisonFile | uniqueKey"
:key="uniqueKey(comparisonFile)"
ref="comparison-content"
v-bind="comparisonFile"
:active="true"
Expand All @@ -117,8 +117,8 @@
</div>

<!-- PREVIOUS -->
<div v-if="previousFile"
:key="previousFile | uniqueKey"
<div v-if="hasPreviousFile"
:key="uniqueKey(previousFile)"
class="viewer__file-wrapper viewer__file-wrapper--hidden"
aria-hidden="true"
inert>
Expand All @@ -134,7 +134,7 @@
</div>

<!-- CURRENT -->
<div :key="currentFile | uniqueKey" class="viewer__file-wrapper">
<div :key="uniqueKey(currentFile)" class="viewer__file-wrapper">
<component :is="currentFile.modal"
v-if="!currentFile.failed"
ref="content"
Expand All @@ -154,8 +154,8 @@
</div>

<!-- NEXT -->
<div v-if="nextFile"
:key="nextFile | uniqueKey"
<div v-if="hasNextFile"
:key="uniqueKey(nextFile)"
class="viewer__file-wrapper viewer__file-wrapper--hidden"
aria-hidden="true"
inert>
Expand Down Expand Up @@ -223,12 +223,6 @@ export default defineComponent({
Pencil,
},

filters: {
uniqueKey(file) {
return '' + file.fileid + file.source
},
},

mixins: [isFullscreen, isMobile],

data() {
Expand Down Expand Up @@ -319,6 +313,15 @@ export default defineComponent({
return this.currentIndex === this.fileList.length - 1
},

hasPreviousFile() {
// Check if empty object
return Object.keys(this.previousFile).length > 0
},
hasNextFile() {
// Check if empty object
return Object.keys(this.nextFile).length > 0
},

isImage() {
return ['image/jpeg', 'image/png', 'image/webp'].includes(this.currentFile?.mime)
},
Expand Down Expand Up @@ -562,6 +565,10 @@ export default defineComponent({
},

methods: {
uniqueKey(file) {
return '' + file.fileid + file.source
},

/**
* If there is no download permission also hide the context menu.
* @param {MouseEvent} event The mouse click event
Expand Down Expand Up @@ -773,7 +780,7 @@ export default defineComponent({
}
} else {
// RESET
this.previousFile = null
this.previousFile = {}
}

if (next) {
Expand All @@ -783,7 +790,7 @@ export default defineComponent({
}
} else {
// RESET
this.nextFile = null
this.nextFile = {}
}

},
Expand Down
Loading