fix(community): fix messages being gone when we re-join a community
Fixes #7512 The problem was twofold. 1. We didn't try to fetch the messages when we re-joined, since the cursor was not reseted 2. The messages are not longer in the DB since they get deleted on joining. I fixed 1. by reseting the cursor on leave and calling fetch on spectate I fixed 2. in the status-go PR so that we no longer delete the messages when leaving.
This commit is contained in:
parent
9067cc408c
commit
59a05243af
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d7bf19fdbb9805ffd7106d10b7b0211dbb614257
|
||||
Subproject commit cee5313e0ec26a7bbca4e27a81621b3fb99c77b6
|
Loading…
Reference in New Issue