Skip to content

Commit 22c9019

Browse files
committed
fix(files_sharing): Do not nothing pre-create share actions menu closed
- This fixes the issue of having the refresh the UI after share creation, as the share is not immediately removed from the UI list. - We explicitly call cancel, when the cancel button is pressed, if click-outside, it's okay to do nothing, new share proccesses starts with a new share object. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
1 parent d4cea1c commit 22c9019

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ export default {
238238
239239
data() {
240240
return {
241+
shareCreationComplete: false,
241242
showDropdown: false,
242243
copySuccess: true,
243244
copied: false,
@@ -296,7 +297,7 @@ export default {
296297
* @return {string}
297298
*/
298299
subtitle() {
299-
if (this.isEmailShareType
300+
if (this.isEmailShareTypef
300301
&& this.title !== this.share.shareWith) {
301302
return this.share.shareWith
302303
}
@@ -483,6 +484,7 @@ export default {
483484
* Create a new share link and append it to the list
484485
*/
485486
async onNewLinkShare() {
487+
console.log('Level 0')
486488
// do not run again if already loading
487489
if (this.loading) {
488490
return
@@ -500,13 +502,17 @@ export default {
500502
// do not push yet if we need a password or an expiration date: show pending menu
501503
if (this.config.enableLinkPasswordByDefault || this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced) {
502504
this.pending = true
505+
this.shareCreationComplete = false
503506
504507
// if a share already exists, pushing it
505508
if (this.share && !this.share.id) {
506509
// if the share is valid, create it on the server
507510
if (this.checkShare(this.share)) {
508511
try {
509-
await this.pushNewLinkShare(this.share, true)
512+
console.log('Level 1')
513+
debugger
514+
const success = await this.pushNewLinkShare(this.share, true)
515+
console.log('Level 2', success)
510516
} catch (e) {
511517
this.pending = false
512518
console.error(e)
@@ -536,12 +542,17 @@ export default {
536542
// freshly created share component
537543
this.open = false
538544
this.pending = false
545+
this.shareCreationComplete = true
539546
component.open = true
547+
console.log('Level 3')
540548
541549
// Nothing is enforced, creating share directly
542550
} else {
543551
const share = new Share(shareDefaults)
552+
console.log('Level 4')
544553
await this.pushNewLinkShare(share)
554+
this.shareCreationComplete = true
555+
console.log('Level 5')
545556
}
546557
},
547558
@@ -582,7 +593,6 @@ export default {
582593
583594
this.open = false
584595
console.debug('Link share created', newShare)
585-
586596
// if share already exists, copy link directly on next tick
587597
let component
588598
if (update) {
@@ -609,13 +619,17 @@ export default {
609619
showSuccess(t('files_sharing', 'Link share created'))
610620
611621
} catch (data) {
622+
console.log('Error null')
612623
const message = data?.response?.data?.ocs?.meta?.message
613624
if (!message) {
614625
showError(t('files_sharing', 'Error while creating the share'))
615626
console.error(data)
627+
console.log('Error a')
616628
return
617629
}
618630
631+
console.log('Error b')
632+
619633
if (message.match(/password/i)) {
620634
this.onSyncError('password', message)
621635
} else if (message.match(/date/i)) {
@@ -624,8 +638,13 @@ export default {
624638
this.onSyncError('pending', message)
625639
}
626640
throw data
641+
642+
console.log('Error c')
643+
627644
} finally {
628645
this.loading = false
646+
this.shareCreationComplete = true
647+
console.log('End of share creation')
629648
}
630649
},
631650
async copyLink() {
@@ -723,12 +742,17 @@ export default {
723742
/**
724743
* Cancel the share creation
725744
* Used in the pending popover
745+
*
746+
* @param e
726747
*/
727-
onCancel() {
748+
onCancel(e) {
749+
console.log("SHARE COMPLETE", this.shareCreationComplete)
728750
// this.share already exists at this point,
729751
// but is incomplete as not pushed to server
730752
// YET. We can safely delete the share :)
731-
this.$emit('remove:share', this.share)
753+
if (!this.shareCreationComplete) {
754+
this.$emit('remove:share', this.share)
755+
}
732756
},
733757
734758
toggleQuickShareSelect() {

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ export default {
808808
this.share = share
809809
this.$emit('add:share', this.share)
810810
} else {
811+
this.$emit('update:share', this.share)
811812
this.queueUpdate(...permissionsAndAttributes)
812813
}
813814

0 commit comments

Comments
 (0)