fix(filebrowser): avoid duplicate list refresh (#731)

This commit is contained in:
InfinityPacer
2026-08-30 16:50:37 +08:00
committed by GitHub
parent 17b9d51569
commit a7c377fa15
2 changed files with 11 additions and 3 deletions
@@ -342,7 +342,6 @@ onUnmounted(cleanupDrag)
@pathchanged="pathChanged" @pathchanged="pathChanged"
@loading="loadingChanged" @loading="loadingChanged"
@refreshed="refreshPending = false" @refreshed="refreshPending = false"
@filedeleted="refreshPending = true"
@renamed="refreshPending = true" @renamed="refreshPending = true"
@items-updated="fileListUpdated" @items-updated="fileListUpdated"
@switch-tree="switchDirTree" @switch-tree="switchDirTree"
@@ -72,9 +72,9 @@ const FileNavigatorStub = defineComponent({
const FileListStub = defineComponent({ const FileListStub = defineComponent({
name: 'FileList', name: 'FileList',
props: ['refreshpending', 'sort', 'showTree'], props: ['refreshpending', 'sort', 'showTree'],
emits: ['items-updated', 'loading', 'pathchanged', 'refreshed', 'switch-tree'], emits: ['items-updated', 'loading', 'pathchanged', 'refreshed', 'switch-tree', 'filedeleted'],
template: template:
'<div><button class="emit-loading" @click="$emit(`loading`, 1)" /><button class="emit-tree" @click="$emit(`switch-tree`, true)" /></div>', '<div><button class="emit-loading" @click="$emit(`loading`, 1)" /><button class="emit-tree" @click="$emit(`switch-tree`, true)" /><button class="emit-filedeleted" @click="$emit(`filedeleted`)" /></div>',
}) })
function createBrowserProps() { function createBrowserProps() {
@@ -266,6 +266,15 @@ describe('FileBrowser state and child contracts', () => {
expect(wrapper.getComponent(FileListStub).props('refreshpending')).toBe(false) expect(wrapper.getComponent(FileListStub).props('refreshpending')).toBe(false)
}) })
it('does not schedule a second list refresh after the child completes a delete', async () => {
const wrapper = mountBrowser()
await wrapper.get('.emit-filedeleted').trigger('click')
await nextTick()
expect(wrapper.getComponent(FileListStub).props('refreshpending')).toBe(false)
})
it('forwards the latest file list snapshot to the directory navigator', async () => { it('forwards the latest file list snapshot to the directory navigator', async () => {
localStorage.setItem('fileBrowser.showDirTree', 'true') localStorage.setItem('fileBrowser.showDirTree', 'true')
const wrapper = mountBrowser() const wrapper = mountBrowser()