From fd5aea78d2c0735ac7f6800dca9165b5141f887b Mon Sep 17 00:00:00 2001 From: Sebin Song Date: Thu, 16 Jan 2025 04:34:48 +0900 Subject: [PATCH] #2506 - Fix the redirection bug on `Send Message` button. (#2509) * fix the bug * update the variable name * fix #2510 * variable update again --- frontend/views/components/ProfileCard.vue | 7 +++++-- frontend/views/containers/chatroom/DMMixin.js | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/views/components/ProfileCard.vue b/frontend/views/components/ProfileCard.vue index 4ef0cd4a6..ea3ca6e5e 100644 --- a/frontend/views/components/ProfileCard.vue +++ b/frontend/views/components/ProfileCard.vue @@ -176,12 +176,15 @@ export default ({ ) }, toggleTooltip () { - this.$refs.tooltip.toggle() + this.$refs.tooltip?.toggle() }, async sendMessage () { const chatRoomID = this.ourGroupDirectMessageFromUserIds(this.contractID) if (!chatRoomID) { - await this.createDirectMessage(this.contractID) + const freshChatRoomID = await this.createDirectMessage(this.contractID) + if (freshChatRoomID) { + this.redirect(freshChatRoomID) + } } else { if (!this.ourGroupDirectMessages[chatRoomID].visible) { this.setDMVisibility(chatRoomID, true) diff --git a/frontend/views/containers/chatroom/DMMixin.js b/frontend/views/containers/chatroom/DMMixin.js index 889184866..fdf1f117e 100644 --- a/frontend/views/containers/chatroom/DMMixin.js +++ b/frontend/views/containers/chatroom/DMMixin.js @@ -22,6 +22,8 @@ const DMMixin: Object = { try { const identityContractID = this.ourIdentityContractId const currentGroupId = this.currentGroupId + let dmChatRoomId + await sbp('gi.actions/identity/createDirectMessage', { contractID: identityContractID, data: { currentGroupId, memberIDs }, @@ -33,10 +35,13 @@ const DMMixin: Object = { // state ('pending') and we'll set the chatroom ID when the // contract is loaded. // This is done in the JOINED_CHATROOM event. - sbp('state/vuex/commit', 'setPendingChatRoomId', { chatRoomID: message.contractID(), groupID: currentGroupId }) + dmChatRoomId = message.contractID() + sbp('state/vuex/commit', 'setPendingChatRoomId', { chatRoomID: dmChatRoomId, groupID: currentGroupId }) } } }) + + return dmChatRoomId } catch (err) { console.error('[DMMixin.js] Failed to create a new chatroom', err) await sbp('gi.ui/prompt', {