Skip to content

Commit

Permalink
MEED-2749 Fix the mentioned users removed when selecting another audi…
Browse files Browse the repository at this point in the history
…ence
  • Loading branch information
MayTekayaa committed Oct 24, 2023
1 parent 5e0e77c commit 20b4062
Showing 1 changed file with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<exo-drawer
ref="activityKudosDrawer"
v-model="drawer"
v-draggable="enabled"
width="500px"
hide-actions
Expand Down Expand Up @@ -174,8 +175,8 @@
username-class />
<div class="d-flex flex-row pt-8">
<rich-editor
v-if="drawer"
:ref="ckEditorId"
:key="spaceURL"
v-model="kudosMessage"
:max-length="MESSAGE_MAX_LENGTH"
:ck-editor-type="ckEditorType"
Expand Down Expand Up @@ -305,6 +306,11 @@ export default {
this.spaceURL = this.audience?.remoteId || null;
this.spaceId = this.audience?.spaceId || null;
},
spaceURL() {
// Clear suggester cache
document.dispatchEvent(new CustomEvent('suggester-clear-people-cache'));
this.resetRichEditorData();
},
audienceChoice(newVal) {
if (newVal === 'yourNetwork') {
this.removeAudience();
Expand Down Expand Up @@ -423,7 +429,10 @@ export default {
},
displaySenderAvatar() {
return (this.postInYourNetwork && this.audienceTypesDisplay) || this.isLinkedKudos;
}
},
ckEditorInstance() {
return this.drawer && this.$refs.kudosContent || null;
},
},
methods: {
init() {
Expand All @@ -450,7 +459,7 @@ export default {
});
},
resetEditor() {
this.$refs[this.ckEditorId].destroyCKEditor();
this.ckEditorInstance.destroyCKEditor();
},
initDrawer() {
this.kudosMessage = '';
Expand Down Expand Up @@ -561,7 +570,7 @@ export default {
this.$refs.activityKudosDrawer.startLoading();
this.initDrawer()
.then(() => this.$nextTick())
.then(() => this.$refs[this.ckEditorId].initCKEditor())
.then(() => this.ckEditorInstance.initCKEditor())
.finally( () => {
this.loading = false;
this.$refs.activityKudosDrawer.endLoading();
Expand All @@ -579,14 +588,15 @@ export default {
send() {
this.error = null;
const kudosMessage = this.ckEditorInstance.updateMessageBeforPost();
this.$refs.activityKudosDrawer.startLoading();
const kudos = {
entityType: this.entityType,
entityId: this.entityId,
parentEntityId: this.parentEntityId,
receiverType: this.receiverType,
receiverId: this.receiverId,
message: this.kudosMessage,
message: kudosMessage,
spacePrettyName: this.audience?.remoteId || this.spaceId
};
sendKudos(kudos)
Expand All @@ -598,7 +608,7 @@ export default {
document.dispatchEvent(new CustomEvent('exo-kudos-sent', {detail: kudosSent}));
return this.$nextTick();
})
.then(() => this.$refs[this.ckEditorId].saveAttachments())
.then(() => this.ckEditorInstance.saveAttachments())
.then(() => {
return this.init()
.catch(e => {
Expand Down Expand Up @@ -658,7 +668,14 @@ export default {
},
removeReceiver() {
this.selectedReceiver = '';
}
},
resetRichEditorData() {
const message = this.ckEditorInstance.getMessage();
const mentionedUsers = message.match(/@([A-Za-z0-9_'.+-]+)/g)?.map(a => a.replace('@', '')) || null;
if (mentionedUsers?.length) {
this.ckEditorInstance?.replaceSuggestedUsers?.(message, mentionedUsers, this.spaceId);
}
},
}
};
</script>

0 comments on commit 20b4062

Please sign in to comment.