aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2024-03-07 15:08:24 +0100
committernextcloud-command <nextcloud-command@users.noreply.github.com>2024-03-07 21:47:50 +0000
commite453b700b9740ff6ae27dcced423cad73104ecb8 (patch)
tree56212c38947d2d5ca1fa37403a52655a8dd4cf16 /apps
parentcf888e972346a91a9ab63bb5b7a62be446d5b6ac (diff)
downloadnextcloud-server-e453b700b9740ff6ae27dcced423cad73104ecb8.tar.gz
nextcloud-server-e453b700b9740ff6ae27dcced423cad73104ecb8.zip
fix(files): properly reset preview component
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/src/components/FileEntry/FileEntryPreview.vue17
-rw-r--r--apps/files/src/components/FileEntryMixin.ts9
2 files changed, 19 insertions, 7 deletions
diff --git a/apps/files/src/components/FileEntry/FileEntryPreview.vue b/apps/files/src/components/FileEntry/FileEntryPreview.vue
index 25b27d2e889..d1bb78a105e 100644
--- a/apps/files/src/components/FileEntry/FileEntryPreview.vue
+++ b/apps/files/src/components/FileEntry/FileEntryPreview.vue
@@ -39,7 +39,7 @@
:class="{'files-list__row-icon-preview--loaded': backgroundFailed === false}"
loading="lazy"
:src="previewUrl"
- @error="backgroundFailed = true"
+ @error="onBackgroundError"
@load="backgroundFailed = false">
<FileIcon v-else v-once />
@@ -219,12 +219,21 @@ export default Vue.extend({
},
methods: {
+ // Called from FileEntry
reset() {
- if (this.backgroundFailed === true && this.$refs.previewImg) {
+ // Reset background state to cancel any ongoing requests
+ this.backgroundFailed = undefined
+ if (this.$refs.previewImg) {
this.$refs.previewImg.src = ''
}
- // Reset background state
- this.backgroundFailed = undefined
+ },
+
+ onBackgroundError(event) {
+ // Do not fail if we just reset the background
+ if (event.target?.src === '') {
+ return
+ }
+ this.backgroundFailed = true
},
t,
diff --git a/apps/files/src/components/FileEntryMixin.ts b/apps/files/src/components/FileEntryMixin.ts
index 69638d33212..5a20eb1ecc1 100644
--- a/apps/files/src/components/FileEntryMixin.ts
+++ b/apps/files/src/components/FileEntryMixin.ts
@@ -177,8 +177,10 @@ export default defineComponent({
* When the source changes, reset the preview
* and fetch the new one.
*/
- source() {
- this.resetState()
+ source(a: Node, b: Node) {
+ if (a.source !== b.source) {
+ this.resetState()
+ }
},
},
@@ -191,7 +193,8 @@ export default defineComponent({
// Reset loading state
this.loading = ''
- this.$refs.preview.reset()
+ // Reset the preview state
+ this.$refs?.preview?.reset?.()
// Close menu
this.openedMenu = false