mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-25 13:06:08 +00:00
refactor: make sure we only set active the active chat of active section
Fixes #9236 and #9438
This commit is contained in:
parent
5352ba8c6f
commit
9b840bfbd0
@ -23,6 +23,7 @@ type
|
||||
sectionId: string
|
||||
isCommunitySection: bool
|
||||
activeItemId: string
|
||||
isCurrentSectionActive: bool
|
||||
events: EventEmitter
|
||||
settingsService: settings_service.Service
|
||||
nodeConfigurationService: node_configuration_service.Service
|
||||
@ -42,6 +43,7 @@ proc newController*(delegate: io_interface.AccessInterface, sectionId: string, i
|
||||
result.delegate = delegate
|
||||
result.sectionId = sectionId
|
||||
result.isCommunitySection = isCommunity
|
||||
result.isCurrentSectionActive = false
|
||||
result.events = events
|
||||
result.settingsService = settingsService
|
||||
result.nodeConfigurationService = nodeConfigurationService
|
||||
@ -58,6 +60,12 @@ proc delete*(self: Controller) =
|
||||
proc getActiveChatId*(self: Controller): string =
|
||||
return self.activeItemId
|
||||
|
||||
proc getIsCurrentSectionActive*(self: Controller): bool =
|
||||
return self.isCurrentSectionActive
|
||||
|
||||
proc setIsCurrentSectionActive*(self: Controller, active: bool) =
|
||||
self.isCurrentSectionActive = active
|
||||
|
||||
proc init*(self: Controller) =
|
||||
self.events.on(SIGNAL_SENDING_SUCCESS) do(e:Args):
|
||||
let args = MessageSendingSuccess(e)
|
||||
@ -282,6 +290,9 @@ proc getCommunityCategoryDetails*(self: Controller, communityId: string, categor
|
||||
|
||||
proc setActiveItem*(self: Controller, itemId: string) =
|
||||
self.activeItemId = itemId
|
||||
let isSectionActive = self.getIsCurrentSectionActive()
|
||||
if not isSectionActive:
|
||||
return
|
||||
if self.activeItemId != "":
|
||||
self.messageService.asyncLoadInitialMessagesForChat(self.activeItemId)
|
||||
|
||||
|
@ -329,9 +329,10 @@ method load*(
|
||||
self.usersModule.load()
|
||||
|
||||
let activeChatId = self.controller.getActiveChatId()
|
||||
let isCurrentSectionActive = self.controller.getIsCurrentSectionActive()
|
||||
for chatId, cModule in self.chatContentModules:
|
||||
cModule.load()
|
||||
if chatId == activeChatId:
|
||||
if isCurrentSectionActive and chatId == activeChatId:
|
||||
cModule.onMadeActive()
|
||||
|
||||
proc checkIfModuleDidLoad(self: Module) =
|
||||
@ -426,8 +427,15 @@ method updateLastMessageTimestamp*(self: Module, chatId: string, lastMessageTime
|
||||
|
||||
method onActiveSectionChange*(self: Module, sectionId: string) =
|
||||
if(sectionId != self.controller.getMySectionId()):
|
||||
self.controller.setIsCurrentSectionActive(false)
|
||||
return
|
||||
|
||||
self.controller.setIsCurrentSectionActive(true)
|
||||
let activeChatId = self.controller.getActiveChatId()
|
||||
if activeChatId == "":
|
||||
self.setFirstChannelAsActive()
|
||||
else:
|
||||
self.setActiveItem(activeChatId)
|
||||
self.delegate.onActiveChatChange(self.controller.getMySectionId(), self.controller.getActiveChatId())
|
||||
|
||||
method chatsModel*(self: Module): chats_model.Model =
|
||||
|
Loading…
x
Reference in New Issue
Block a user