fix: open activity center mentions messages (#14075)

This commit is contained in:
Mykhailo Prakhov 2024-03-21 15:52:45 +01:00 committed by GitHub
parent 9195595c00
commit 398a92b12e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 23 deletions

View File

@ -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/wallet_account/service as wallet_account_service
import ../../../../../../app_service/service/shared_urls/service as shared_urls_service import ../../../../../../app_service/service/shared_urls/service as shared_urls_service
import ../../../../../../app_service/common/types import ../../../../../../app_service/common/types
import ../../../../../global/app_signals
import ../../../../../core/eventemitter import ../../../../../core/eventemitter
import ../../../../../core/unique_event_emitter import ../../../../../core/unique_event_emitter
@ -205,12 +204,6 @@ proc init*(self: Controller) =
return return
self.delegate.onHistoryCleared() 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): self.events.on(SIGNAL_CHAT_MEMBER_UPDATED) do(e: Args):
let args = ChatMemberUpdatedArgs(e) let args = ChatMemberUpdatedArgs(e)
if (args.chatId != self.chatId): if (args.chatId != self.chatId):

View File

@ -1549,6 +1549,6 @@ method communityContainsChat*(self: Module, chatId: string): bool =
return self.chatContentModules.hasKey(chatId) return self.chatContentModules.hasKey(chatId)
method openCommunityChatAndScrollToMessage*(self: Module, chatId: string, messageId: string) = method openCommunityChatAndScrollToMessage*(self: Module, chatId: string, messageId: string) =
self.delegate.setActiveSectionById(self.getMySectionId()) if chatId in self.chatContentModules:
self.setActiveItem(chatId) self.setActiveItem(chatId)
self.chatContentModules[chatId].scrollToMessage(messageId) self.chatContentModules[chatId].scrollToMessage(messageId)

View File

@ -1,5 +1,4 @@
import chronicles, stint import chronicles, stint
import app/global/app_sections_config as conf
import app/global/global_singleton import app/global/global_singleton
import app/global/app_signals import app/global/app_signals
import app/core/signals/types as signal_types import app/core/signals/types as signal_types
@ -62,7 +61,6 @@ type
sharedUrlsService: urls_service.Service sharedUrlsService: urls_service.Service
# Forward declaration # Forward declaration
proc setActiveSection*(self: Controller, sectionId: string, skipSavingInSettings: bool = false)
proc getRemainingSupply*(self: Controller, chainId: int, contractAddress: string): Uint256 proc getRemainingSupply*(self: Controller, chainId: int, contractAddress: string): Uint256
proc getRemoteDestructedAmount*(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): self.events.on(SIGNAL_MAKE_SECTION_CHAT_ACTIVE) do(e: Args):
var args = ActiveSectionChatArgs(e) 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): self.events.on(SIGNAL_STATUS_URL_ACTIVATED) do(e: Args):
var args = StatusUrlArgs(e) var args = StatusUrlArgs(e)
@ -498,13 +500,6 @@ proc getChannelGroups*(self: Controller): seq[ChannelGroupDto] =
proc getActiveSectionId*(self: Controller): string = proc getActiveSectionId*(self: Controller): string =
result = self.activeSectionId 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] = proc getAllChats*(self: Controller): seq[ChatDto] =
result = self.chatService.getAllChats() result = self.chatService.getAllChats()

View File

@ -148,7 +148,7 @@ method emitMailserverWorking*(self: AccessInterface) {.base.} =
method emitMailserverNotWorking*(self: AccessInterface) {.base.} = method emitMailserverNotWorking*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") 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") raise newException(ValueError, "No implementation available")
method toggleSection*(self: AccessInterface, sectionType: SectionType) {.base.} = 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.} = method checkIfAddressWasCopied*(self: AccessInterface, value: string) {.base.} =
raise newException(ValueError, "No implementation available") 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 # This way (using concepts) is used only for the modules managed by AppController
type type
DelegateInterface* = concept c DelegateInterface* = concept c

View File

@ -821,7 +821,7 @@ method setActiveSection*[T](self: Module[T], item: SectionItem, skipSavingInSett
if(item.isEmpty()): if(item.isEmpty()):
echo "section is empty and cannot be made as active one" echo "section is empty and cannot be made as active one"
return return
self.controller.setActiveSection(item.id, skipSavingInSettings) self.activeSectionSet(item.id, skipSavingInSettings)
method setActiveSectionById*[T](self: Module[T], id: string) = method setActiveSectionById*[T](self: Module[T], id: string) =
let item = self.view.model().getItemById(id) 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... # 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: if self.view.activeSection.getId() == sectionId:
return return
let item = self.view.model().getItemById(sectionId) 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.model().setActiveSection(sectionId)
self.view.activeSectionSet(item) self.view.activeSectionSet(item)
if not skipSavingInSettings:
singletonInstance.localAccountSensitiveSettings.setActiveSection(sectionId)
self.notifySubModulesAboutChange(sectionId) self.notifySubModulesAboutChange(sectionId)
proc setSectionAvailability[T](self: Module[T], sectionType: SectionType, available: bool) = proc setSectionAvailability[T](self: Module[T], sectionType: SectionType, available: bool) =
@ -1636,6 +1639,10 @@ method checkIfAddressWasCopied*[T](self: Module[T], value: string) =
return return
self.addressWasShown(value) 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 = proc createMemberItem*[T](self: Module[T], memberId: string, state: MembershipRequestState, role: MemberRole): MemberItem =
let contactDetails = self.controller.getContactDetails(memberId) let contactDetails = self.controller.getContactDetails(memberId)
let status = self.controller.getStatusForContactWithId(memberId) let status = self.controller.getStatusForContactWithId(memberId)