Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not load version when sidebar is closed #11998

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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