Skip to content

Commit

Permalink
Fix share panel now showing correct data after updating a share
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Feb 20, 2023
1 parent f01f6c1 commit b909fe5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ The performance when loading folders and share indicators has been improved by o

https://github.com/owncloud/web/issues/7721
https://github.com/owncloud/web/pull/8349
https://github.com/owncloud/web/pull/8482
21 changes: 13 additions & 8 deletions packages/web-app-files/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,16 @@ export default {
permissions,
expireDate: expirationDate
})

commit(
'CURRENT_FILE_OUTGOING_SHARES_UPSERT',
buildCollaboratorShare(
updatedShare.shareInfo,
getters.highlightedFile,
allowSharePermissions(rootGetters)
)
const builtShare = buildCollaboratorShare(
updatedShare.shareInfo,
getters.highlightedFile,
allowSharePermissions(rootGetters)
)
commit('CURRENT_FILE_OUTGOING_SHARES_UPSERT', builtShare)
commit('SHARESTREE_UPSERT', {
path: share.path,
share: { ...builtShare, indirect: false, outgoing: true }
})
} catch (error) {
dispatch(
'showMessage',
Expand Down Expand Up @@ -447,6 +448,10 @@ export default {
.then((data) => {
const link = buildShare(data.shareInfo, null, allowSharePermissions(context.rootGetters))
context.commit('CURRENT_FILE_OUTGOING_SHARES_UPSERT', link)
context.commit('SHARESTREE_UPSERT', {
path: link.path,
share: { ...link, indirect: false, outgoing: true }
})
resolve(link)
})
.catch((e) => {
Expand Down
5 changes: 5 additions & 0 deletions packages/web-app-files/src/store/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export default {
if (!state.sharesTree[path]) {
state.sharesTree[path] = []
}
const existingShare = state.sharesTree[path].find((s) => s.id === share.id)
if (existingShare) {
Object.assign(existingShare, share)
return
}
state.sharesTree[path].push(share)
},
SHARESTREE_REMOVE(state, { path, id }) {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/tests/unit/store/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('vuex store actions', () => {
expirationDate: null
})

expect(stateMock.commit).toHaveBeenCalledTimes(1)
expect(stateMock.commit).toHaveBeenCalledTimes(2)
})
it('fails on error', async () => {
const clientMock = mockDeep<OwnCloudSdk>()
Expand Down

0 comments on commit b909fe5

Please sign in to comment.