Skip to content

Commit 2d45420

Browse files
committed
fix(files): wait for nodes to be fetched before checking for opendetails or openfile
Signed-off-by: skjnldsv <[email protected]>
1 parent 33a69bf commit 2d45420

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

apps/files/src/components/FilesListVirtual.vue

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ export default defineComponent({
157157
FileEntry,
158158
FileEntryGrid,
159159
scrollToIndex: 0,
160-
openFileId: null as number|null,
161160
}
162161
},
163162
@@ -222,39 +221,37 @@ export default defineComponent({
222221
isNoneSelected() {
223222
return this.selectedNodes.length === 0
224223
},
224+
225+
isEmpty() {
226+
return this.nodes.length === 0
227+
},
225228
},
226229
227230
watch: {
228-
fileId: {
229-
handler(fileId) {
230-
this.scrollToFile(fileId, false)
231-
},
232-
immediate: true,
233-
},
231+
// If nodes gets populated and we have a fileId,
232+
// an openFile or openDetails, we fire the appropriate actions.
233+
isEmpty(isEmpty: boolean) {
234+
if (isEmpty || !this.fileId) {
235+
return
236+
}
234237
235-
openFile: {
236-
handler(openFile) {
237-
if (!openFile || !this.fileId) {
238-
return
239-
}
238+
logger.debug('FilesListVirtual: nodes populated, checking for requested fileId, openFile or openDetails again', {
239+
fileId: this.fileId,
240+
openFile: this.openFile,
241+
openDetails: this.openDetails,
242+
})
240243
244+
if (this.openFile) {
241245
this.handleOpenFile(this.fileId)
242-
},
243-
immediate: true,
244-
},
246+
}
245247
246-
openDetails: {
247-
handler(openDetails) {
248-
// wait for scrolling and updating the actions to settle
249-
this.$nextTick(() => {
250-
if (!openDetails || !this.fileId) {
251-
return
252-
}
248+
if (this.openDetails) {
249+
this.openSidebarForFile(this.fileId)
250+
}
253251
254-
this.openSidebarForFile(this.fileId)
255-
})
256-
},
257-
immediate: true,
252+
if (this.fileId) {
253+
this.scrollToFile(this.fileId, false)
254+
}
258255
},
259256
},
260257
@@ -293,7 +290,7 @@ export default defineComponent({
293290
sidebarAction.exec(node, this.currentView, this.currentFolder.path)
294291
return
295292
}
296-
logger.error(`Failed to open sidebar on file ${fileId}, file isn't cached yet !`, { fileId, node })
293+
logger.warn(`Failed to open sidebar on file ${fileId}, file isn't cached yet !`, { fileId, node })
297294
},
298295
299296
scrollToFile(fileId: number|null, warn = true) {

0 commit comments

Comments
 (0)