From cd2d289af91546c3c916ca7ea98c033d3f3b6db4 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Tue, 12 Jul 2022 14:37:47 +0200 Subject: [PATCH] quick crash fix --- src/app/boot/app_controller.nim | 2 +- src/app_service/service/contacts/service.nim | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index b57750dcbe..b9be6c9452 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -133,7 +133,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController = result.accountsService = accounts_service.newService(statusFoundation.fleetConfiguration) result.networkService = network_service.newService(statusFoundation.events, result.settingsService) 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.communityService = community_service.newService(statusFoundation.events, diff --git a/src/app_service/service/contacts/service.nim b/src/app_service/service/contacts/service.nim index 287446a439..68189cca88 100644 --- a/src/app_service/service/contacts/service.nim +++ b/src/app_service/service/contacts/service.nim @@ -6,7 +6,7 @@ import ../../../app/core/eventemitter import ../../../app/core/tasks/[qt, threadpool] import ../../common/types as common_types -import ../settings/dto/settings +import ../settings/service as settings_service import ../network/service as network_service import ./dto/contacts as contacts_dto import ./dto/status_update as status_update_dto @@ -84,6 +84,7 @@ QtObject: type Service* = ref object of QObject threadpool: ThreadPool networkService: network_service.Service + settingsService: settings_service.Service contacts: Table[string, ContactsDto] # [contact_id, ContactsDto] contactsStatus: Table[string, StatusUpdateDto] # [contact_id, StatusUpdateDto] receivedIdentityRequests: Table[string, VerificationRequest] # [from_id, VerificationRequest] @@ -107,13 +108,15 @@ QtObject: proc newService*( events: EventEmitter, threadpool: ThreadPool, - networkService: network_service.Service + networkService: network_service.Service, + settingsService: settings_service.Service ): Service = new(result, delete) result.QObject.setup result.closingApp = false result.events = events result.networkService = networkService + result.settingsService = settingsService result.threadpool = threadpool result.contacts = initTable[string, ContactsDto]() result.contactsStatus = initTable[string, StatusUpdateDto]() @@ -330,6 +333,12 @@ QtObject: self.addContact(result) 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. if(not self.contactsStatus.hasKey(publicKey)): # following line ensures that we have added a contact before setting status for it