Skip to content

Commit

Permalink
Fix share loading when adding a link via quick action (#8915)
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen authored Apr 27, 2023
1 parent f04b47d commit c9c53ab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ https://github.com/owncloud/web/issues/7721
https://github.com/owncloud/web/pull/8349
https://github.com/owncloud/web/pull/8482
https://github.com/owncloud/web/pull/8667
https://github.com/owncloud/web/pull/8915
20 changes: 16 additions & 4 deletions packages/web-app-files/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,15 @@ export default {

const shareMethod = isGroupShare ? 'shareFileWithGroup' : 'shareFileWithUser'
return client.shares[shareMethod](path, shareWith, options)
.then((share) => {
.then(async (share) => {
const builtShare = buildCollaboratorShare(
share.shareInfo,
context.getters.highlightedFile,
allowSharePermissions(context.rootGetters)
)
if (context.state.sharesLoading) {
await Promise.resolve(context.state.sharesLoading)
}
context.commit('OUTGOING_SHARES_UPSERT', { ...builtShare, outgoing: true })
context.dispatch('updateCurrentFileShareTypes')
context.commit('LOAD_INDICATORS', path)
Expand All @@ -317,7 +320,10 @@ export default {
})
},
deleteShare(context, { client, share, path, loadIndicators = false }) {
return client.shares.deleteShare(share.id, {} as any).then(() => {
return client.shares.deleteShare(share.id, {} as any).then(async () => {
if (context.state.sharesLoading) {
await Promise.resolve(context.state.sharesLoading)
}
context.commit('OUTGOING_SHARES_REMOVE', share)
context.dispatch('updateCurrentFileShareTypes')
if (loadIndicators) {
Expand Down Expand Up @@ -427,8 +433,11 @@ export default {
return new Promise((resolve, reject) => {
client.shares
.shareFileWithLink(path, { ...params, spaceRef: storageId })
.then((data) => {
.then(async (data) => {
const link = buildShare(data.shareInfo, null, allowSharePermissions(context.rootGetters))
if (context.state.sharesLoading) {
await Promise.resolve(context.state.sharesLoading)
}
context.commit('OUTGOING_SHARES_UPSERT', { ...link, outgoing: true })
context.dispatch('updateCurrentFileShareTypes')
context.commit('LOAD_INDICATORS', path)
Expand All @@ -454,7 +463,10 @@ export default {
})
},
removeLink(context, { share, client, path, loadIndicators = false }) {
return client.shares.deleteShare(share.id).then(() => {
return client.shares.deleteShare(share.id).then(async () => {
if (context.state.sharesLoading) {
await Promise.resolve(context.state.sharesLoading)
}
context.commit('OUTGOING_SHARES_REMOVE', share)
context.dispatch('updateCurrentFileShareTypes')
if (loadIndicators) {
Expand Down
3 changes: 2 additions & 1 deletion packages/web-app-files/tests/unit/store/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const stateMock = {
commit: jest.fn(),
dispatch: jest.fn(),
getters: {},
rootGetters: {}
rootGetters: {},
state: {}
}
// we need to define $gettext explicitly to make it enumerable on the mock
const languageMock = mock<Language>({ $gettext: jest.fn() })
Expand Down

0 comments on commit c9c53ab

Please sign in to comment.