From 13a3a594e205707c68e0d64528acf324dc643837 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Thu, 11 Jan 2024 14:08:14 +0100 Subject: [PATCH 1/9] Implement base edit function Signed-off-by: DorraJaouad --- .../MessagesGroup/Message/Message.vue | 10 +++ .../MessageButtonsBar/MessageButtonsBar.vue | 16 ++++- src/components/MessagesList/MessagesList.vue | 1 + src/components/NewMessage/NewMessage.vue | 68 ++++++++++++++++++- src/components/Quote.vue | 18 ++++- src/services/messagesService.js | 7 ++ src/store/messagesStore.js | 13 ++++ src/stores/chatExtras.js | 21 +++++- 8 files changed, 146 insertions(+), 8 deletions(-) diff --git a/src/components/MessagesList/MessagesGroup/Message/Message.vue b/src/components/MessagesList/MessagesGroup/Message/Message.vue index 98a649ab6bf..81c8d719878 100644 --- a/src/components/MessagesList/MessagesGroup/Message/Message.vue +++ b/src/components/MessagesList/MessagesGroup/Message/Message.vue @@ -178,6 +178,7 @@ the main body of the message as well as a quote. :sent-icon-tooltip="sentIconTooltip" @show-translate-dialog="isTranslateDialogOpen = true" @reply="handleReply" + @edit="handleEdit" @delete="handleDelete" />
@@ -756,6 +757,15 @@ export default { EventBus.$emit('focus-chat-input') }, + handleEdit() { + this.chatExtrasStore.setMessageIdToEdit({ + token: this.token, + message: this.message, + id: this.id + }) + EventBus.$emit('focus-chat-input') + }, + async handleDelete() { this.isDeleting = true try { diff --git a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue index 56f85102d7f..a56a336ac64 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue @@ -83,6 +83,14 @@ {{ t('spreed', 'Reply privately') }} + + + {{ t('spreed', 'Edit message') }} + @@ -267,6 +275,7 @@ import EyeOffOutline from 'vue-material-design-icons/EyeOffOutline.vue' import File from 'vue-material-design-icons/File.vue' import Note from 'vue-material-design-icons/NoteEditOutline.vue' import OpenInNewIcon from 'vue-material-design-icons/OpenInNew.vue' +import Pencil from 'vue-material-design-icons/Pencil.vue' import Plus from 'vue-material-design-icons/Plus.vue' import Reply from 'vue-material-design-icons/Reply.vue' import Share from 'vue-material-design-icons/Share.vue' @@ -323,6 +332,7 @@ export default { File, Note, OpenInNewIcon, + Pencil, Plus, Reply, Share, @@ -447,7 +457,7 @@ export default { }, }, - emits: ['delete', 'update:isActionMenuOpen', 'update:isEmojiPickerOpen', 'update:isReactionsMenuOpen', 'update:isForwarderOpen', 'show-translate-dialog', 'reply'], + emits: ['delete', 'update:isActionMenuOpen', 'update:isEmojiPickerOpen', 'update:isReactionsMenuOpen', 'update:isForwarderOpen', 'show-translate-dialog', 'reply', 'edit'], setup() { const reactionsStore = useReactionsStore() @@ -791,6 +801,10 @@ export default { setCustomReminder() { this.setReminder(this.customReminderDateTime.valueOf()) }, + + editMessage() { + this.$emit('edit') + }, }, } diff --git a/src/components/MessagesList/MessagesList.vue b/src/components/MessagesList/MessagesList.vue index e0896d93536..f7ae0c67840 100644 --- a/src/components/MessagesList/MessagesList.vue +++ b/src/components/MessagesList/MessagesList.vue @@ -356,6 +356,7 @@ export default { areGroupsIdentical(group1, group2) { if (group1.messages.length !== group2.messages.length + || JSON.stringify(group1.messages) !== JSON.stringify(group2.messages) || group1.dateSeparator !== group2.dateSeparator || group1.previousMessageId !== group2.previousMessageId || group1.nextMessageId !== group2.nextMessageId) { diff --git a/src/components/NewMessage/NewMessage.vue b/src/components/NewMessage/NewMessage.vue index ac2fd014e4e..2b5f420f3e9 100644 --- a/src/components/NewMessage/NewMessage.vue +++ b/src/components/NewMessage/NewMessage.vue @@ -82,8 +82,8 @@
-
- +
+
+ + + + +