Skip to content

Commit

Permalink
Fetch share again via OCS request if it's not in the response
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Apr 27, 2021
1 parent 9e0f11c commit a6b0711
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions packages/web-app-files/src/views/SharedWithMe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,33 @@ export default {
async triggerShareAction(resource, type) {
try {
// exec share action
let response = await this.$client.requests.ocs({
service: 'apps/files_sharing',
action: `api/v1/shares/pending/${resource.share.id}`,
method: type
})
response = await response.json()
if (response.ocs.data.length > 0) {
// exit on failure
if (response.status !== 200) {
throw new Error()
}
// get updated share from response or re-fetch it
let share = null
if (response.headers.map['content-length'] > 0) {
response = await response.json()
if (response.ocs.data.length > 0) {
share = response.ocs.data[0]
}
} else {
share = await this.$client.shares.getShare(resource.share.id)
}
// update share in store
if (share) {
const sharedResource = await buildSharedResource(
response.ocs.data[0],
share,
true,
!this.isOcis,
this.configuration.server,
Expand All @@ -243,6 +261,7 @@ export default {
this.UPDATE_RESOURCE(sharedResource)
}
} catch (error) {
console.log(error)
this.showMessage({
title: this.$gettext('Error while changing share state'),
desc: error.message,
Expand Down

0 comments on commit a6b0711

Please sign in to comment.