fix(notifications): fix notification setup called too soon

This commit is contained in:
Jonathan Rainville 2021-12-08 10:11:43 -05:00
parent 22181ea0ee
commit 1a0fb268e3
2 changed files with 10 additions and 5 deletions

View File

@ -50,3 +50,4 @@ proc delete*(self: AppService) =
proc onLoggedIn*(self: AppService) =
self.marathon.onLoggedIn()
self.osNotificationService.onLoggedIn()

View File

@ -11,15 +11,14 @@ QtObject:
type OsNotificationService* = ref object of QObject
status: Status
notification: StatusOSNotification
notificationSetUp: bool
proc setup(self: OsNotificationService, status: Status) =
self.QObject.setup
self.status = status
self.notification = newStatusOSNotification()
signalConnect(self.notification, "notificationClicked(QString)", self,
"onNotificationClicked(QString)", 2)
proc delete*(self: OsNotificationService) =
if self.notificationSetUp:
self.notification.delete
self.QObject.delete
@ -46,3 +45,8 @@ QtObject:
## This slot is called once user clicks a notificaiton bubble, "identifier"
## contains data which uniquely define that notification.
self.status.osnotifications.onNotificationClicked(identifier)
proc onLoggedIn*(self: OsNotificationService) =
self.notification = newStatusOSNotification()
self.notificationSetUp = true
signalConnect(self.notification, "notificationClicked(QString)", self, "onNotificationClicked(QString)", 2)