mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-24 05:21:58 +00:00
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.activityCenterService
|
||||||
)
|
)
|
||||||
result.chatService = chat_service.newService(statusFoundation.events, result.contactsService)
|
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(
|
result.tokenService = token_service.newService(
|
||||||
statusFoundation.events, statusFoundation.threadpool, result.networkService
|
statusFoundation.events, statusFoundation.threadpool, result.networkService
|
||||||
)
|
)
|
||||||
@ -160,6 +158,8 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
|||||||
result.messageService = message_service.newService(
|
result.messageService = message_service.newService(
|
||||||
statusFoundation.events, statusFoundation.threadpool, result.contactsService, result.tokenService, result.walletAccountService, result.networkService
|
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.transactionService = transaction_service.newService(statusFoundation.events, statusFoundation.threadpool, result.networkService, result.settingsService, result.tokenService)
|
||||||
result.bookmarkService = bookmark_service.newService(statusFoundation.events)
|
result.bookmarkService = bookmark_service.newService(statusFoundation.events)
|
||||||
result.profileService = profile_service.newService(result.contactsService, result.settingsService)
|
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 ./dto/community as community_dto
|
||||||
|
|
||||||
import ../activity_center/service as activity_center_service
|
import ../activity_center/service as activity_center_service
|
||||||
|
import ../message/service as message_service
|
||||||
import ../chat/service as chat_service
|
import ../chat/service as chat_service
|
||||||
|
|
||||||
import ../../../app/global/global_singleton
|
import ../../../app/global/global_singleton
|
||||||
@ -134,6 +135,7 @@ QtObject:
|
|||||||
events: EventEmitter
|
events: EventEmitter
|
||||||
chatService: chat_service.Service
|
chatService: chat_service.Service
|
||||||
activityCenterService: activity_center_service.Service
|
activityCenterService: activity_center_service.Service
|
||||||
|
messageService: message_service.Service
|
||||||
communityTags: string # JSON string contraining tags map
|
communityTags: string # JSON string contraining tags map
|
||||||
joinedCommunities: Table[string, CommunityDto] # [community_id, CommunityDto]
|
joinedCommunities: Table[string, CommunityDto] # [community_id, CommunityDto]
|
||||||
curatedCommunities: Table[string, CuratedCommunity] # [community_id, CuratedCommunity]
|
curatedCommunities: Table[string, CuratedCommunity] # [community_id, CuratedCommunity]
|
||||||
@ -163,7 +165,8 @@ QtObject:
|
|||||||
events: EventEmitter,
|
events: EventEmitter,
|
||||||
threadpool: ThreadPool,
|
threadpool: ThreadPool,
|
||||||
chatService: chat_service.Service,
|
chatService: chat_service.Service,
|
||||||
activityCenterService: activity_center_service.Service
|
activityCenterService: activity_center_service.Service,
|
||||||
|
messageService: message_service.Service
|
||||||
): Service =
|
): Service =
|
||||||
result = Service()
|
result = Service()
|
||||||
result.QObject.setup
|
result.QObject.setup
|
||||||
@ -171,6 +174,7 @@ QtObject:
|
|||||||
result.threadpool = threadpool
|
result.threadpool = threadpool
|
||||||
result.chatService = chatService
|
result.chatService = chatService
|
||||||
result.activityCenterService = activityCenterService
|
result.activityCenterService = activityCenterService
|
||||||
|
result.messageService = messageService
|
||||||
result.communityTags = newString(0)
|
result.communityTags = newString(0)
|
||||||
result.joinedCommunities = initTable[string, CommunityDto]()
|
result.joinedCommunities = initTable[string, CommunityDto]()
|
||||||
result.curatedCommunities = initTable[string, CuratedCommunity]()
|
result.curatedCommunities = initTable[string, CuratedCommunity]()
|
||||||
@ -671,6 +675,7 @@ QtObject:
|
|||||||
chatDto.id = fullChatId
|
chatDto.id = fullChatId
|
||||||
# TODO find a way to populate missing infos like the color
|
# TODO find a way to populate missing infos like the color
|
||||||
self.chatService.updateOrAddChat(chatDto)
|
self.chatService.updateOrAddChat(chatDto)
|
||||||
|
self.messageService.asyncLoadInitialMessagesForChat(fullChatId)
|
||||||
|
|
||||||
self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[updatedCommunity]))
|
self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[updatedCommunity]))
|
||||||
self.events.emit(SIGNAL_COMMUNITY_SPECTATED, CommunityArgs(community: updatedCommunity, fromUserAction: true))
|
self.events.emit(SIGNAL_COMMUNITY_SPECTATED, CommunityArgs(community: updatedCommunity, fromUserAction: true))
|
||||||
@ -764,6 +769,9 @@ QtObject:
|
|||||||
self.allCommunities[communityId] = updatedCommunity
|
self.allCommunities[communityId] = updatedCommunity
|
||||||
self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[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
|
# remove this from the joinedCommunities list
|
||||||
self.joinedCommunities.del(communityId)
|
self.joinedCommunities.del(communityId)
|
||||||
self.events.emit(SIGNAL_COMMUNITY_LEFT, CommunityIdArgs(communityId: communityId))
|
self.events.emit(SIGNAL_COMMUNITY_LEFT, CommunityIdArgs(communityId: communityId))
|
||||||
|
@ -300,6 +300,11 @@ QtObject:
|
|||||||
proc initialMessagesFetched(self: Service, chatId: string): bool =
|
proc initialMessagesFetched(self: Service, chatId: string): bool =
|
||||||
return self.msgCursor.hasKey(chatId)
|
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 =
|
proc getMessageCursor(self: Service, chatId: string): MessageCursor =
|
||||||
if(not self.msgCursor.hasKey(chatId)):
|
if(not self.msgCursor.hasKey(chatId)):
|
||||||
self.msgCursor[chatId] = initMessageCursor(value="", pending=false, mostRecent=false)
|
self.msgCursor[chatId] = initMessageCursor(value="", pending=false, mostRecent=false)
|
||||||
|
2
vendor/status-go
vendored
2
vendor/status-go
vendored
@ -1 +1 @@
|
|||||||
Subproject commit d7bf19fdbb9805ffd7106d10b7b0211dbb614257
|
Subproject commit cee5313e0ec26a7bbca4e27a81621b3fb99c77b6
|
Loading…
x
Reference in New Issue
Block a user