fix(notifications): fix windows tray icon and notifications

Fixes #4263
This commit is contained in:
Jonathan Rainville 2022-02-25 14:45:52 -05:00
parent d42a34ff3a
commit d2d57036b5
4 changed files with 26 additions and 19 deletions

View File

@ -33,6 +33,7 @@ import ../../app_service/service/ens/service as ens_service
import ../modules/startup/module as startup_module
import ../modules/main/module as main_module
import ../core/notifications/notifications_manager
import ../global/global_singleton
@ -41,6 +42,7 @@ import ../core/[main]
type
AppController* = ref object of RootObj
statusFoundation: StatusFoundation
notificationsManager*: NotificationsManager
# Global
localAppSettingsVariant: QVariant
@ -108,6 +110,7 @@ proc connect(self: AppController) =
proc newAppController*(statusFoundation: StatusFoundation): AppController =
result = AppController()
result.statusFoundation = statusFoundation
result.notificationsManager = newNotificationsManager(statusFoundation.events)
# Global
result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings)
@ -222,6 +225,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
proc delete*(self: AppController) =
singletonInstance.delete
self.notificationsManager.delete
self.keychainService.delete
self.contactsService.delete
self.bookmarkService.delete
@ -287,6 +291,8 @@ proc start*(self: AppController) =
self.startupModule.load()
proc load(self: AppController) =
self.notificationsManager.init()
self.settingsService.init()
self.nodeConfigurationService.init()
self.contactsService.init()

View File

@ -4,18 +4,16 @@ import
./fleets/fleet_configuration,
./tasks/marathon,
./tasks/threadpool,
./signals/signals_manager,
./notifications/notifications_manager
./signals/signals_manager
export eventemitter
export marathon, task_runner, signals_manager, fleet_configuration, notifications_manager
export marathon, task_runner, signals_manager, fleet_configuration
type StatusFoundation* = ref object
events*: EventEmitter
fleetConfiguration*: FleetConfiguration
threadpool*: ThreadPool
signalsManager*: SignalsManager
notificationsManager*: NotificationsManager
proc newStatusFoundation*(fleetConfig: string): StatusFoundation =
result = StatusFoundation()
@ -23,10 +21,8 @@ proc newStatusFoundation*(fleetConfig: string): StatusFoundation =
result.fleetConfiguration = newFleetConfiguration(fleetConfig)
result.threadpool = newThreadPool()
result.signalsManager = newSignalsManager(result.events)
result.notificationsManager = newNotificationsManager(result.events)
proc delete*(self: StatusFoundation) =
self.threadpool.teardown()
self.fleetConfiguration.delete()
self.signalsManager.delete()
self.notificationsManager.delete()
self.signalsManager.delete()

View File

@ -40,12 +40,25 @@ QtObject:
events: EventEmitter
osNotification: StatusOSNotification
soundManager: StatusSoundManager
notificationSetUp: bool
proc processNotification(self: NotificationsManager, title: string, message: string, details: NotificationDetails)
proc setup(self: NotificationsManager, events: EventEmitter) =
self.QObject.setup
self.events = events
proc delete*(self: NotificationsManager) =
if self.notificationSetUp:
self.osNotification.delete
self.soundManager.delete
self.QObject.delete
proc newNotificationsManager*(events: EventEmitter): NotificationsManager =
new(result, delete)
result.setup(events)
proc init*(self: NotificationsManager) =
self.osNotification = newStatusOSNotification()
self.soundManager = newStatusSoundManager()
@ -62,14 +75,7 @@ QtObject:
self, "onMyRequestToJoinCommunityHasBeenAcccepted(QString, QString, QString)", 2)
signalConnect(singletonInstance.globalEvents, "myRequestToJoinCommunityHasBeenRejected(QString, QString, QString)",
self, "onMyRequestToJoinCommunityHasBeenRejected(QString, QString, QString)", 2)
proc delete*(self: NotificationsManager) =
self.osNotification.delete
self.QObject.delete
proc newNotificationsManager*(events: EventEmitter): NotificationsManager =
new(result, delete)
result.setup(events)
self.notificationSetUp = true
proc showOSNotification(self: NotificationsManager, title: string, message: string, identifier: string) =
## This method will add new notification to the OS Notification center. Param

View File

@ -636,10 +636,9 @@ method onContactDetailsUpdated*(self: Module, publicKey: string) =
method onNewMessagesReceived*(self: Module, chatId: string, unviewedMessagesCount: int, unviewedMentionsCount: int,
messages: seq[MessageDto]) =
if(self.controller.getMySectionId() == self.delegate.getActiveSectionId() and
self.controller.getActiveChatId() == chatId):
return
self.updateBadgeNotifications(chatId, unviewedMessagesCount, unviewedMentionsCount)
if(self.controller.getMySectionId() != self.delegate.getActiveSectionId() or
self.controller.getActiveChatId() != chatId):
self.updateBadgeNotifications(chatId, unviewedMessagesCount, unviewedMentionsCount)
# Prepare bubble notification
let myPK = singletonInstance.userProfile.getPubKey()