Skip to content

Commit

Permalink
Merge pull request #11998 from owncloud/fix/file-versions-loading
Browse files Browse the repository at this point in the history
fix: do not load version when sidebar is closed
  • Loading branch information
JammingBen authored Dec 4, 2024
2 parents f360666 + 7389e2a commit 764fc26
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Do not load version when sidebar is closed

We've fixed the the loading of file versions which was triggered even when sidebar was closed. File version will now be loaded only when the sidebar is opened.

https://github.com/owncloud/web/pull/11998
https://github.com/owncloud/web/issues/11979
6 changes: 6 additions & 0 deletions packages/web-pkg/src/components/SideBar/FileSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ export default defineComponent({
if (unref(panelContext).items?.length !== 1) {
return
}
if (!props.isOpen) {
versions.value = []
return
}
const resource = unref(panelContext).items[0]
if (loadVersionsTask.isRunning) {
Expand Down
28 changes: 28 additions & 0 deletions packages/web-pkg/tests/unit/components/sidebar/FileSideBar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,34 @@ describe('FileSideBar', () => {
expect(sharesStore.setCollaboratorShares).toHaveBeenCalledWith([])
})
})
describe('loadVersionsTask', () => {
beforeEach(() => {
vi.mock('../../../../src/composables/resources/useCanListVersions', () => ({
useCanListVersions: () => ({ canListVersions: vi.fn().mockReturnValue(true) })
}))
})

it('is called when resource is selected and sidebar is opened', () => {
const resource = mock<Resource>({ id: 'some-image', path: '/someImage.jpg' })
const { mocks } = createWrapper({
item: resource
})

expect(mocks.$clientService.webdav.listFileVersions).toHaveBeenCalledWith('some-image', {
signal: expect.any(AbortSignal)
})
})

it('is not called if resource is selected and sidebar is not opened', () => {
const resource = mock<Resource>({ id: 'some-image', path: '/someImage.jpg' })
const { mocks } = createWrapper({
item: resource,
isOpen: false
})

expect(mocks.$clientService.webdav.listFileVersions).not.toHaveBeenCalled()
})
})
})
})

Expand Down

0 comments on commit 764fc26

Please sign in to comment.