quick crash fix

This commit is contained in:
Sale Djenic 2022-07-12 14:37:47 +02:00 committed by Iuri Matias
parent fa8c3c6efd
commit cd2d289af9
2 changed files with 12 additions and 3 deletions

View File

@ -133,7 +133,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.accountsService = accounts_service.newService(statusFoundation.fleetConfiguration) result.accountsService = accounts_service.newService(statusFoundation.fleetConfiguration)
result.networkService = network_service.newService(statusFoundation.events, result.settingsService) result.networkService = network_service.newService(statusFoundation.events, result.settingsService)
result.contactsService = contacts_service.newService( result.contactsService = contacts_service.newService(
statusFoundation.events, statusFoundation.threadpool, result.networkService statusFoundation.events, statusFoundation.threadpool, result.networkService, result.settingsService
) )
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, result.communityService = community_service.newService(statusFoundation.events,

View File

@ -6,7 +6,7 @@ import ../../../app/core/eventemitter
import ../../../app/core/tasks/[qt, threadpool] import ../../../app/core/tasks/[qt, threadpool]
import ../../common/types as common_types import ../../common/types as common_types
import ../settings/dto/settings import ../settings/service as settings_service
import ../network/service as network_service import ../network/service as network_service
import ./dto/contacts as contacts_dto import ./dto/contacts as contacts_dto
import ./dto/status_update as status_update_dto import ./dto/status_update as status_update_dto
@ -84,6 +84,7 @@ QtObject:
type Service* = ref object of QObject type Service* = ref object of QObject
threadpool: ThreadPool threadpool: ThreadPool
networkService: network_service.Service networkService: network_service.Service
settingsService: settings_service.Service
contacts: Table[string, ContactsDto] # [contact_id, ContactsDto] contacts: Table[string, ContactsDto] # [contact_id, ContactsDto]
contactsStatus: Table[string, StatusUpdateDto] # [contact_id, StatusUpdateDto] contactsStatus: Table[string, StatusUpdateDto] # [contact_id, StatusUpdateDto]
receivedIdentityRequests: Table[string, VerificationRequest] # [from_id, VerificationRequest] receivedIdentityRequests: Table[string, VerificationRequest] # [from_id, VerificationRequest]
@ -107,13 +108,15 @@ QtObject:
proc newService*( proc newService*(
events: EventEmitter, events: EventEmitter,
threadpool: ThreadPool, threadpool: ThreadPool,
networkService: network_service.Service networkService: network_service.Service,
settingsService: settings_service.Service
): Service = ): Service =
new(result, delete) new(result, delete)
result.QObject.setup result.QObject.setup
result.closingApp = false result.closingApp = false
result.events = events result.events = events
result.networkService = networkService result.networkService = networkService
result.settingsService = settingsService
result.threadpool = threadpool result.threadpool = threadpool
result.contacts = initTable[string, ContactsDto]() result.contacts = initTable[string, ContactsDto]()
result.contactsStatus = initTable[string, StatusUpdateDto]() result.contactsStatus = initTable[string, StatusUpdateDto]()
@ -330,6 +333,12 @@ QtObject:
self.addContact(result) self.addContact(result)
proc getStatusForContactWithId*(self: Service, publicKey: string): StatusUpdateDto = proc getStatusForContactWithId*(self: Service, publicKey: string): StatusUpdateDto =
if publicKey == singletonInstance.userProfile.getPubKey():
let currentUserStatus = self.settingsService.getCurrentUserStatus()
return StatusUpdateDto(publicKey: singletonInstance.userProfile.getPubKey(),
statusType: currentUserStatus.statusType,
clock: currentUserStatus.clock.uint64,
text: currentUserStatus.text)
# This proc will fetch current accurate status from `status-go` once we add an api point there for it. # This proc will fetch current accurate status from `status-go` once we add an api point there for it.
if(not self.contactsStatus.hasKey(publicKey)): if(not self.contactsStatus.hasKey(publicKey)):
# following line ensures that we have added a contact before setting status for it # following line ensures that we have added a contact before setting status for it