mirror of
https://github.com/nextcloud/server.git
synced 2026-06-06 07:13:23 -04:00
Merge pull request #44062 from nextcloud/fix/preview-cancel
fix(files): properly reset preview component
This commit is contained in:
commit
bd1fd5e079
4 changed files with 22 additions and 10 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue