fix(files_sharing): ugly hacks to update permissions on share creation

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen
2025-03-06 00:25:59 +01:00
parent beb538f9f2
commit 0f58178e4d
4 changed files with 26 additions and 9 deletions

View File

@@ -46,6 +46,7 @@ export default {
scope: 'permissions',
},
],
hideDownload: false,
share_type: shareRequestObject.shareType,
share_with: shareRequestObject.shareWith,
is_no_user: shareRequestObject.isNoUser,

View File

@@ -308,7 +308,7 @@ export default {
}
})
this.updateQueue.add(async () => {
return this.updateQueue.add(async () => {
this.saving = true
this.errors = {}
try {
@@ -340,7 +340,6 @@ export default {
this.saving = false
}
})
return
}
// This share does not exists on the server yet

View File

@@ -39,6 +39,10 @@ export default class Share {
ocsData = ocsData.ocs.data[0]
}
// string to int
if (typeof ocsData.id === 'string') {
ocsData.id = Number.parseInt(ocsData.id)
}
// convert int into boolean
ocsData.hide_download = !!ocsData.hide_download
ocsData.mail_send = !!ocsData.mail_send
@@ -113,7 +117,7 @@ export default class Share {
* @memberof Share
*/
get attributes() {
return this._share.attributes
return this._share.attributes || []
}
/**

View File

@@ -901,16 +901,29 @@ export default {
this.creating = true
const share = await this.addShare(incomingShare)
this.creating = false
// ugly hack to make code work - we need the id to be set but at the same time we need to keep values we want to update
this.share._share.id = share.id
await this.queueUpdate(...permissionsAndAttributes)
// Also a ugly hack to update the updated permissions
for (const prop of permissionsAndAttributes) {
if (prop in share && prop in this.share) {
try {
share[prop] = this.share[prop]
} catch {
share._share[prop] = this.share[prop]
}
}
}
this.share = share
this.creating = false
this.$emit('add:share', this.share)
} else {
// Let's update after creation as some attrs are only available after creation
this.$emit('update:share', this.share)
emit('update:share', this.share)
this.queueUpdate(...permissionsAndAttributes)
}
// Let's update after creation as some attrs are only available after creation
this.$emit('update:share', this.share)
emit('update:share', this.share)
this.queueUpdate(...permissionsAndAttributes)
await this.getNode()
emit('files:node:updated', this.node)