fix(chat_section): Open Chat section before creating or switching to one-to-one chat

Fixes: #9880
This commit is contained in:
Boris Melnik 2023-03-21 19:27:40 +03:00
parent ec6d35a6bd
commit 5592335b2f
2 changed files with 12 additions and 10 deletions

View File

@ -333,12 +333,11 @@ proc init*(self: Controller) =
if (self.sectionId != args.sectionId):
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.communityId, args.chatId, args.ensName)
if (not self.isCommunitySection):
self.events.on(SIGNAL_CHAT_SWITCH_TO_OR_CREATE_1_1_CHAT) do(e:Args):
let args = ChatExtArgs(e)
self.delegate.createOneToOneChat(args.communityId, args.chatId, args.ensName)
self.events.on(SIGNAL_CONTACTS_STATUS_UPDATED) do(e: Args):
let args = ContactsStatusUpdatedArgs(e)

View File

@ -708,7 +708,10 @@ method onCommunityChannelEdited*(self: Module, chat: ChatDto) =
method switchToOrCreateOneToOneChat*(self: Module, chatId: string) =
# One To One chat is available only in the `Chat` section
if(self.controller.getMySectionId() != singletonInstance.userProfile.getPubKey()):
if (self.controller.getMySectionId() == singletonInstance.userProfile.getPubKey()) and (self.delegate.getActiveSectionId() != self.controller.getMySectionId()):
self.delegate.setActiveSectionById(self.controller.getMySectionId())
# if its not `Chat` section - skip
else:
return
if(self.chatContentModules.hasKey(chatId)):
@ -719,9 +722,9 @@ method switchToOrCreateOneToOneChat*(self: Module, chatId: string) =
method createOneToOneChat*(self: Module, communityID: string, chatId: string, ensName: string) =
if(self.controller.isCommunity()):
# initiate chat creation in the `Chat` seciton module.
self.controller.switchToOrCreateOneToOneChat(chatId, ensName)
return
# initiate chat creation in the `Chat` seciton module.
self.controller.switchToOrCreateOneToOneChat(chatId, ensName)
return
# Adding this call here we have the same as we had before (didn't inspect what are all cases when this
# `createOneToOneChat` is called), but I am sure that after checking all cases and inspecting them, this can be improved.