From 9623df08fbef7574e4032639e61594ba78879faf Mon Sep 17 00:00:00 2001 From: SebinSong Date: Wed, 15 Jan 2025 11:15:54 +0900 Subject: [PATCH] fix the bug --- frontend/views/components/ProfileCard.vue | 5 ++++- frontend/views/containers/chatroom/DMMixin.js | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/views/components/ProfileCard.vue b/frontend/views/components/ProfileCard.vue index 4ef0cd4a6..2a8459442 100644 --- a/frontend/views/components/ProfileCard.vue +++ b/frontend/views/components/ProfileCard.vue @@ -181,7 +181,10 @@ export default ({ async sendMessage () { const chatRoomID = this.ourGroupDirectMessageFromUserIds(this.contractID) if (!chatRoomID) { - await this.createDirectMessage(this.contractID) + const dmChatRoomId = await this.createDirectMessage(this.contractID) + if (dmChatRoomId) { + this.redirect(dmChatRoomId) + } } 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', {