diff --git a/src/app/modules/main/chat_section/chat_content/messages/controller.nim b/src/app/modules/main/chat_section/chat_content/messages/controller.nim index ecf461586f..41b01310c4 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/controller.nim @@ -10,7 +10,6 @@ import ../../../../../../app_service/service/mailservers/service as mailservers_ import ../../../../../../app_service/service/wallet_account/service as wallet_account_service import ../../../../../../app_service/service/shared_urls/service as shared_urls_service import ../../../../../../app_service/common/types -import ../../../../../global/app_signals import ../../../../../core/eventemitter import ../../../../../core/unique_event_emitter @@ -205,12 +204,6 @@ proc init*(self: Controller) = return self.delegate.onHistoryCleared() - self.events.on(SIGNAL_MAKE_SECTION_CHAT_ACTIVE) do(e: Args): - let args = ActiveSectionChatArgs(e) - if(self.sectionId != args.sectionId or self.chatId != args.chatId): - return - self.delegate.scrollToMessage(args.messageId) - self.events.on(SIGNAL_CHAT_MEMBER_UPDATED) do(e: Args): let args = ChatMemberUpdatedArgs(e) if (args.chatId != self.chatId): diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 4d6af359c3..d8ca7bd88f 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -1549,6 +1549,6 @@ method communityContainsChat*(self: Module, chatId: string): bool = return self.chatContentModules.hasKey(chatId) method openCommunityChatAndScrollToMessage*(self: Module, chatId: string, messageId: string) = - self.delegate.setActiveSectionById(self.getMySectionId()) - self.setActiveItem(chatId) - self.chatContentModules[chatId].scrollToMessage(messageId) \ No newline at end of file + if chatId in self.chatContentModules: + self.setActiveItem(chatId) + self.chatContentModules[chatId].scrollToMessage(messageId) \ No newline at end of file diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index 1b4c64a94e..4099dfed91 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -1,5 +1,4 @@ import chronicles, stint -import app/global/app_sections_config as conf import app/global/global_singleton import app/global/app_signals import app/core/signals/types as signal_types @@ -62,7 +61,6 @@ type sharedUrlsService: urls_service.Service # Forward declaration -proc setActiveSection*(self: Controller, sectionId: string, skipSavingInSettings: bool = false) proc getRemainingSupply*(self: Controller, chainId: int, contractAddress: string): Uint256 proc getRemoteDestructedAmount*(self: Controller, chainId: int, contractAddress: string): Uint256 @@ -291,7 +289,11 @@ proc init*(self: Controller) = self.events.on(SIGNAL_MAKE_SECTION_CHAT_ACTIVE) do(e: Args): var args = ActiveSectionChatArgs(e) - self.setActiveSection(args.sectionId) + self.activeSectionId = args.sectionId + self.delegate.activeSectionSet(self.activeSectionId) + + if args.chatId != "": + self.delegate.openSectionChatAndMessage(args.sectionId, args.chatId, args.messageId) self.events.on(SIGNAL_STATUS_URL_ACTIVATED) do(e: Args): var args = StatusUrlArgs(e) @@ -498,13 +500,6 @@ proc getChannelGroups*(self: Controller): seq[ChannelGroupDto] = proc getActiveSectionId*(self: Controller): string = result = self.activeSectionId -proc setActiveSection*(self: Controller, sectionId: string, skipSavingInSettings: bool = false) = - self.activeSectionId = sectionId - if not skipSavingInSettings: - let sectionIdToSave = if (sectionId == conf.SETTINGS_SECTION_ID): "" else: sectionId - singletonInstance.localAccountSensitiveSettings.setActiveSection(sectionIdToSave) - self.delegate.activeSectionSet(self.activeSectionId) - proc getAllChats*(self: Controller): seq[ChatDto] = result = self.chatService.getAllChats() diff --git a/src/app/modules/main/io_interface.nim b/src/app/modules/main/io_interface.nim index a42ac63b67..a81303e9c5 100644 --- a/src/app/modules/main/io_interface.nim +++ b/src/app/modules/main/io_interface.nim @@ -148,7 +148,7 @@ method emitMailserverWorking*(self: AccessInterface) {.base.} = method emitMailserverNotWorking*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") -method activeSectionSet*(self: AccessInterface, sectionId: string) {.base.} = +method activeSectionSet*(self: AccessInterface, sectionId: string, skipSavingInSettings: bool = false) {.base.} = raise newException(ValueError, "No implementation available") method toggleSection*(self: AccessInterface, sectionType: SectionType) {.base.} = @@ -421,6 +421,9 @@ method addressWasShown*(self: AccessInterface, address: string) {.base.} = method checkIfAddressWasCopied*(self: AccessInterface, value: string) {.base.} = raise newException(ValueError, "No implementation available") +method openSectionChatAndMessage*(self: AccessInterface, sectionId: string, chatId: string, messageId: string) {.base.} = + raise newException(ValueError, "No implementation available") + # This way (using concepts) is used only for the modules managed by AppController type DelegateInterface* = concept c diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 9421843499..ae5f1c33fa 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -821,7 +821,7 @@ method setActiveSection*[T](self: Module[T], item: SectionItem, skipSavingInSett if(item.isEmpty()): echo "section is empty and cannot be made as active one" return - self.controller.setActiveSection(item.id, skipSavingInSettings) + self.activeSectionSet(item.id, skipSavingInSettings) method setActiveSectionById*[T](self: Module[T], id: string) = let item = self.view.model().getItemById(id) @@ -836,7 +836,7 @@ proc notifySubModulesAboutChange[T](self: Module[T], sectionId: string) = # If there is a need other section may be notified the same way from here... -method activeSectionSet*[T](self: Module[T], sectionId: string) = +method activeSectionSet*[T](self: Module[T], sectionId: string, skipSavingInSettings: bool = false) = if self.view.activeSection.getId() == sectionId: return let item = self.view.model().getItemById(sectionId) @@ -855,6 +855,9 @@ method activeSectionSet*[T](self: Module[T], sectionId: string) = self.view.model().setActiveSection(sectionId) self.view.activeSectionSet(item) + if not skipSavingInSettings: + singletonInstance.localAccountSensitiveSettings.setActiveSection(sectionId) + self.notifySubModulesAboutChange(sectionId) proc setSectionAvailability[T](self: Module[T], sectionType: SectionType, available: bool) = @@ -1636,6 +1639,10 @@ method checkIfAddressWasCopied*[T](self: Module[T], value: string) = return self.addressWasShown(value) +method openSectionChatAndMessage*[T](self: Module[T], sectionId: string, chatId: string, messageId: string) = + if sectionId in self.channelGroupModules: + self.channelGroupModules[sectionId].openCommunityChatAndScrollToMessage(chatId, messageId) + proc createMemberItem*[T](self: Module[T], memberId: string, state: MembershipRequestState, role: MemberRole): MemberItem = let contactDetails = self.controller.getContactDetails(memberId) let status = self.controller.getStatusForContactWithId(memberId)