File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed
apps/files/src/components Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 3939 :class =" {'files-list__row-icon-preview--loaded': backgroundFailed === false}"
4040 loading =" lazy"
4141 :src =" previewUrl"
42- @error =" backgroundFailed = true "
42+ @error =" onBackgroundError "
4343 @load =" backgroundFailed = false" >
4444
4545 <FileIcon v-else v-once />
@@ -218,12 +218,21 @@ export default Vue.extend({
218218 },
219219
220220 methods: {
221+ // Called from FileEntry
221222 reset() {
222- if (this .backgroundFailed === true && this .$refs .previewImg ) {
223+ // Reset background state to cancel any ongoing requests
224+ this .backgroundFailed = undefined
225+ if (this .$refs .previewImg ) {
223226 this .$refs .previewImg .src = ' '
224227 }
225- // Reset background state
226- this .backgroundFailed = undefined
228+ },
229+
230+ onBackgroundError(event ) {
231+ // Do not fail if we just reset the background
232+ if (event .target ?.src === ' ' ) {
233+ return
234+ }
235+ this .backgroundFailed = true
227236 },
228237
229238 t ,
Original file line number Diff line number Diff line change @@ -175,8 +175,10 @@ export default defineComponent({
175175 * When the source changes, reset the preview
176176 * and fetch the new one.
177177 */
178- source ( ) {
179- this . resetState ( )
178+ source ( a : Node , b : Node ) {
179+ if ( a . source !== b . source ) {
180+ this . resetState ( )
181+ }
180182 } ,
181183 } ,
182184
@@ -189,7 +191,8 @@ export default defineComponent({
189191 // Reset loading state
190192 this . loading = ''
191193
192- this . $refs . preview . reset ( )
194+ // Reset the preview state
195+ this . $refs ?. preview ?. reset ?.( )
193196
194197 // Close menu
195198 this . openedMenu = false
You can’t perform that action at this time.
0 commit comments