From 20a2d48eea7641b845ccd4f0fcb5e978f63b8676 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 2 Feb 2022 13:56:47 -0500 Subject: [PATCH] fix(notifications): [re-add] fix notification setup called too soon Fixes #4702 --- src/app/boot/app_controller.nim | 2 ++ src/app_service/service/os_notification/service.nim | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index 5229857a63..8b651b9f9b 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -339,6 +339,8 @@ proc userLoggedIn*(self: AppController) = if(importedAccount.isValid()): self.privacyService.removeMnemonic() + self.osNotificationService.userLoggedIn() + proc buildAndRegisterLocalAccountSensitiveSettings(self: AppController) = var pubKey = self.settingsService.getPublicKey() singletonInstance.localAccountSensitiveSettings.setFileName(pubKey) diff --git a/src/app_service/service/os_notification/service.nim b/src/app_service/service/os_notification/service.nim index 99e1883740..5227d9103e 100644 --- a/src/app_service/service/os_notification/service.nim +++ b/src/app_service/service/os_notification/service.nim @@ -17,15 +17,15 @@ QtObject: type Service* = ref object of QObject events: EventEmitter notification: StatusOSNotification + notificationSetUp: bool proc setup(self: Service, events: EventEmitter) = self.QObject.setup self.events = events - self.notification = newStatusOSNotification() - signalConnect(self.notification, "notificationClicked(QString)", self, "onNotificationClicked(QString)", 2) proc delete*(self: Service) = - self.notification.delete + if self.notificationSetUp: + self.notification.delete self.QObject.delete proc newService*(events: EventEmitter): Service = @@ -51,4 +51,9 @@ QtObject: ## This slot is called once user clicks a notificaiton bubble, "identifier" ## contains data which uniquely define that notification. let details = toOsNotificationDetails(parseJson(identifier)) - self.events.emit(SIGNAL_OS_NOTIFICATION_CLICKED, OsNotificationsArgs(details: details)) \ No newline at end of file + self.events.emit(SIGNAL_OS_NOTIFICATION_CLICKED, OsNotificationsArgs(details: details)) + +proc userLoggedIn*(self: Service) = + self.notification = newStatusOSNotification() + signalConnect(self.notification, "notificationClicked(QString)", self, "onNotificationClicked(QString)", 2) + self.notificationSetUp = true \ No newline at end of file