fix(@dekstop/chat): wrong redirect when opening a profile -> send message inside of community

Fixes #4837
This commit is contained in:
Sale Djenic 2022-02-23 17:35:28 +01:00 committed by Iuri Matias
parent 58935b82d7
commit 6f3ce63f51
4 changed files with 23 additions and 3 deletions

View File

@ -166,6 +166,12 @@ method init*(self: Controller) =
return
self.delegate.makeChatWithIdActive(args.chatId)
self.events.on(SIGNAL_CHAT_SWITCH_TO_OR_CREATE_1_1_CHAT) do(e:Args):
let args = ChatExtArgs(e)
if (self.isCommunitySection):
return
self.delegate.createOneToOneChat(args.chatId, args.ensName)
self.events.on(SignalType.HistoryRequestStarted.event) do(e: Args):
self.delegate.setLoadingHistoryMessagesInProgress(true)
@ -235,6 +241,9 @@ method createOneToOneChat*(self: Controller, chatId: string, ensName: string) =
self.delegate.addNewChat(response.chatDto, false, self.events, self.settingsService, self.contactService, self.chatService,
self.communityService, self.messageService, self.gifService, self.mailserversService)
method switchToOrCreateOneToOneChat*(self: Controller, chatId: string, ensName: string) =
self.chatService.switchToOrCreateOneToOneChat(chatId, ensName)
method leaveChat*(self: Controller, chatId: string) =
self.chatService.leaveChat(chatId)

View File

@ -56,6 +56,9 @@ method createPublicChat*(self: AccessInterface, chatId: string) {.base.} =
method createOneToOneChat*(self: AccessInterface, chatId: string, ensName: string) {.base.} =
raise newException(ValueError, "No implementation available")
method switchToOrCreateOneToOneChat*(self: AccessInterface, chatId: string, ensName: string) {.base.} =
raise newException(ValueError, "No implementation available")
method leaveChat*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -527,7 +527,8 @@ method onCommunityChannelEdited*(self: Module, chat: ChatDto) =
method createOneToOneChat*(self: Module, chatId: string, ensName: string) =
if(self.controller.isCommunity()):
debug "creating an one to one chat is not allowed for community, most likely it's an error in qml", methodName="createOneToOneChat"
# initiate chat creation in the `Chat` seciton module.
self.controller.switchToOrCreateOneToOneChat(chatId, ensName)
return
if(self.chatContentModules.hasKey(chatId)):

View File

@ -39,6 +39,9 @@ type
ChatArgs* = ref object of Args
chatId*: string
ChatExtArgs* = ref object of ChatArgs
ensName*: string
MessageSendingSuccess* = ref object of Args
chat*: ChatDto
message*: MessageDto
@ -67,8 +70,8 @@ type
# Signals which may be emitted by this service:
const SIGNAL_CHAT_UPDATE* = "chatUpdate_new"
const SIGNAL_CHAT_LEFT* = "channelLeft_new"
const SIGNAL_CHAT_UPDATE* = "chatUpdate"
const SIGNAL_CHAT_LEFT* = "channelLeft"
const SIGNAL_SENDING_FAILED* = "messageSendingFailed"
const SIGNAL_SENDING_SUCCESS* = "messageSendingSuccess"
const SIGNAL_MESSAGE_DELETED* = "messageDeleted"
@ -79,6 +82,7 @@ const SIGNAL_CHAT_RENAMED* = "chatRenamed"
const SIGNAL_CHAT_MEMBERS_ADDED* = "chatMemberAdded"
const SIGNAL_CHAT_MEMBER_REMOVED* = "chatMemberRemoved"
const SIGNAL_CHAT_MEMBER_UPDATED* = "chatMemberUpdated"
const SIGNAL_CHAT_SWITCH_TO_OR_CREATE_1_1_CHAT* = "switchToOrCreateOneToOneChat"
QtObject:
type Service* = ref object of QObject
@ -238,6 +242,9 @@ QtObject:
error "error: ", errDesription
return
proc switchToOrCreateOneToOneChat*(self: Service, chatId: string, ensName: string) =
self.events.emit(SIGNAL_CHAT_SWITCH_TO_OR_CREATE_1_1_CHAT, ChatExtArgs(chatId: chatId, ensName: ensName))
proc leaveChat*(self: Service, chatId: string) =
try:
if self.chats.len == 0: