Skip to content

Commit

Permalink
refactor: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Sep 2, 2022
1 parent 5ba5d7b commit d099815
Showing 1 changed file with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,35 +119,34 @@ export default defineComponent({
this.createModal(modal)
},
$_ocCollaborators_deleteShare(share) {
this.deleteShare({
client: this.$client,
graphClient: this.graphClient,
share: share,
path: this.highlightedFile.path,
reloadResource: false
})
.then(() => {
this.hideModal()
this.showMessage({
title: this.$gettext('Share was removed successfully')
})
// current user was removed from the share.
if (share.collaborator.name === this.user.id) {
if (isLocationSpacesActive(this.$router, 'files-spaces-projects')) {
return this.$router.go()
}
return this.$router.push(createLocationSpaces('files-spaces-projects'))
}
async $_ocCollaborators_deleteShare(share) {
try {
await this.deleteShare({
client: this.$client,
graphClient: this.graphClient,
share: share,
path: this.highlightedFile.path,
reloadResource: false
})
this.showMessage({
title: this.$gettext('Share was removed successfully')
})
.catch((error) => {
console.error(error)
this.hideModal()
this.showMessage({
title: this.$gettext('Failed to remove share'),
status: 'danger'
})
// current user was removed from the share.
if (share.collaborator.name === this.user.id) {
if (isLocationSpacesActive(this.$router, 'files-spaces-projects')) {
return this.$router.go()
}
return this.$router.push(createLocationSpaces('files-spaces-projects'))
}
} catch (error) {
console.error(error)
this.showMessage({
title: this.$gettext('Failed to remove share'),
status: 'danger'
})
} finally {
this.hideModal()
}
}
}
})
Expand Down

0 comments on commit d099815

Please sign in to comment.