diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index 5507b96cbe..afcd8026d7 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -147,8 +147,6 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController = result.activityCenterService ) result.chatService = chat_service.newService(statusFoundation.events, result.contactsService) - result.communityService = community_service.newService(statusFoundation.events, - statusFoundation.threadpool, result.chatService, result.activityCenterService) result.tokenService = token_service.newService( statusFoundation.events, statusFoundation.threadpool, result.networkService ) @@ -160,6 +158,8 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController = result.messageService = message_service.newService( statusFoundation.events, statusFoundation.threadpool, result.contactsService, result.tokenService, result.walletAccountService, result.networkService ) + result.communityService = community_service.newService(statusFoundation.events, + statusFoundation.threadpool, result.chatService, result.activityCenterService, result.messageService) result.transactionService = transaction_service.newService(statusFoundation.events, statusFoundation.threadpool, result.networkService, result.settingsService, result.tokenService) result.bookmarkService = bookmark_service.newService(statusFoundation.events) result.profileService = profile_service.newService(result.contactsService, result.settingsService) diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index 55b9ada264..7b3e620319 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -3,6 +3,7 @@ import NimQml, Tables, json, sequtils, std/sets, std/algorithm, strformat, strut import ./dto/community as community_dto import ../activity_center/service as activity_center_service +import ../message/service as message_service import ../chat/service as chat_service import ../../../app/global/global_singleton @@ -134,6 +135,7 @@ QtObject: events: EventEmitter chatService: chat_service.Service activityCenterService: activity_center_service.Service + messageService: message_service.Service communityTags: string # JSON string contraining tags map joinedCommunities: Table[string, CommunityDto] # [community_id, CommunityDto] curatedCommunities: Table[string, CuratedCommunity] # [community_id, CuratedCommunity] @@ -163,7 +165,8 @@ QtObject: events: EventEmitter, threadpool: ThreadPool, chatService: chat_service.Service, - activityCenterService: activity_center_service.Service + activityCenterService: activity_center_service.Service, + messageService: message_service.Service ): Service = result = Service() result.QObject.setup @@ -171,6 +174,7 @@ QtObject: result.threadpool = threadpool result.chatService = chatService result.activityCenterService = activityCenterService + result.messageService = messageService result.communityTags = newString(0) result.joinedCommunities = initTable[string, CommunityDto]() result.curatedCommunities = initTable[string, CuratedCommunity]() @@ -671,6 +675,7 @@ QtObject: chatDto.id = fullChatId # TODO find a way to populate missing infos like the color self.chatService.updateOrAddChat(chatDto) + self.messageService.asyncLoadInitialMessagesForChat(fullChatId) self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[updatedCommunity])) self.events.emit(SIGNAL_COMMUNITY_SPECTATED, CommunityArgs(community: updatedCommunity, fromUserAction: true)) @@ -764,6 +769,9 @@ QtObject: self.allCommunities[communityId] = updatedCommunity self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[updatedCommunity])) + for chat in updatedCommunity.chats: + self.messageService.resetMessageCursor(chat.id) + # remove this from the joinedCommunities list self.joinedCommunities.del(communityId) self.events.emit(SIGNAL_COMMUNITY_LEFT, CommunityIdArgs(communityId: communityId)) diff --git a/src/app_service/service/message/service.nim b/src/app_service/service/message/service.nim index 9a8ee4cee5..10808c750d 100644 --- a/src/app_service/service/message/service.nim +++ b/src/app_service/service/message/service.nim @@ -300,6 +300,11 @@ QtObject: proc initialMessagesFetched(self: Service, chatId: string): bool = return self.msgCursor.hasKey(chatId) + proc resetMessageCursor*(self: Service, chatId: string) = + if(not self.msgCursor.hasKey(chatId)): + return + self.msgCursor.del(chatId) + proc getMessageCursor(self: Service, chatId: string): MessageCursor = if(not self.msgCursor.hasKey(chatId)): self.msgCursor[chatId] = initMessageCursor(value="", pending=false, mostRecent=false) diff --git a/vendor/status-go b/vendor/status-go index d7bf19fdbb..cee5313e0e 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit d7bf19fdbb9805ffd7106d10b7b0211dbb614257 +Subproject commit cee5313e0ec26a7bbca4e27a81621b3fb99c77b6