fix(notifications): fix windows tray icon and notifications
Fixes #4263
This commit is contained in:
parent
d42a34ff3a
commit
d2d57036b5
|
@ -33,6 +33,7 @@ import ../../app_service/service/ens/service as ens_service
|
||||||
|
|
||||||
import ../modules/startup/module as startup_module
|
import ../modules/startup/module as startup_module
|
||||||
import ../modules/main/module as main_module
|
import ../modules/main/module as main_module
|
||||||
|
import ../core/notifications/notifications_manager
|
||||||
|
|
||||||
import ../global/global_singleton
|
import ../global/global_singleton
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ import ../core/[main]
|
||||||
type
|
type
|
||||||
AppController* = ref object of RootObj
|
AppController* = ref object of RootObj
|
||||||
statusFoundation: StatusFoundation
|
statusFoundation: StatusFoundation
|
||||||
|
notificationsManager*: NotificationsManager
|
||||||
|
|
||||||
# Global
|
# Global
|
||||||
localAppSettingsVariant: QVariant
|
localAppSettingsVariant: QVariant
|
||||||
|
@ -108,6 +110,7 @@ proc connect(self: AppController) =
|
||||||
proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
||||||
result = AppController()
|
result = AppController()
|
||||||
result.statusFoundation = statusFoundation
|
result.statusFoundation = statusFoundation
|
||||||
|
result.notificationsManager = newNotificationsManager(statusFoundation.events)
|
||||||
|
|
||||||
# Global
|
# Global
|
||||||
result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings)
|
result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings)
|
||||||
|
@ -222,6 +225,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
||||||
|
|
||||||
proc delete*(self: AppController) =
|
proc delete*(self: AppController) =
|
||||||
singletonInstance.delete
|
singletonInstance.delete
|
||||||
|
self.notificationsManager.delete
|
||||||
self.keychainService.delete
|
self.keychainService.delete
|
||||||
self.contactsService.delete
|
self.contactsService.delete
|
||||||
self.bookmarkService.delete
|
self.bookmarkService.delete
|
||||||
|
@ -287,6 +291,8 @@ proc start*(self: AppController) =
|
||||||
self.startupModule.load()
|
self.startupModule.load()
|
||||||
|
|
||||||
proc load(self: AppController) =
|
proc load(self: AppController) =
|
||||||
|
self.notificationsManager.init()
|
||||||
|
|
||||||
self.settingsService.init()
|
self.settingsService.init()
|
||||||
self.nodeConfigurationService.init()
|
self.nodeConfigurationService.init()
|
||||||
self.contactsService.init()
|
self.contactsService.init()
|
||||||
|
|
|
@ -4,18 +4,16 @@ import
|
||||||
./fleets/fleet_configuration,
|
./fleets/fleet_configuration,
|
||||||
./tasks/marathon,
|
./tasks/marathon,
|
||||||
./tasks/threadpool,
|
./tasks/threadpool,
|
||||||
./signals/signals_manager,
|
./signals/signals_manager
|
||||||
./notifications/notifications_manager
|
|
||||||
|
|
||||||
export eventemitter
|
export eventemitter
|
||||||
export marathon, task_runner, signals_manager, fleet_configuration, notifications_manager
|
export marathon, task_runner, signals_manager, fleet_configuration
|
||||||
|
|
||||||
type StatusFoundation* = ref object
|
type StatusFoundation* = ref object
|
||||||
events*: EventEmitter
|
events*: EventEmitter
|
||||||
fleetConfiguration*: FleetConfiguration
|
fleetConfiguration*: FleetConfiguration
|
||||||
threadpool*: ThreadPool
|
threadpool*: ThreadPool
|
||||||
signalsManager*: SignalsManager
|
signalsManager*: SignalsManager
|
||||||
notificationsManager*: NotificationsManager
|
|
||||||
|
|
||||||
proc newStatusFoundation*(fleetConfig: string): StatusFoundation =
|
proc newStatusFoundation*(fleetConfig: string): StatusFoundation =
|
||||||
result = StatusFoundation()
|
result = StatusFoundation()
|
||||||
|
@ -23,10 +21,8 @@ proc newStatusFoundation*(fleetConfig: string): StatusFoundation =
|
||||||
result.fleetConfiguration = newFleetConfiguration(fleetConfig)
|
result.fleetConfiguration = newFleetConfiguration(fleetConfig)
|
||||||
result.threadpool = newThreadPool()
|
result.threadpool = newThreadPool()
|
||||||
result.signalsManager = newSignalsManager(result.events)
|
result.signalsManager = newSignalsManager(result.events)
|
||||||
result.notificationsManager = newNotificationsManager(result.events)
|
|
||||||
|
|
||||||
proc delete*(self: StatusFoundation) =
|
proc delete*(self: StatusFoundation) =
|
||||||
self.threadpool.teardown()
|
self.threadpool.teardown()
|
||||||
self.fleetConfiguration.delete()
|
self.fleetConfiguration.delete()
|
||||||
self.signalsManager.delete()
|
self.signalsManager.delete()
|
||||||
self.notificationsManager.delete()
|
|
|
@ -40,12 +40,25 @@ QtObject:
|
||||||
events: EventEmitter
|
events: EventEmitter
|
||||||
osNotification: StatusOSNotification
|
osNotification: StatusOSNotification
|
||||||
soundManager: StatusSoundManager
|
soundManager: StatusSoundManager
|
||||||
|
notificationSetUp: bool
|
||||||
|
|
||||||
proc processNotification(self: NotificationsManager, title: string, message: string, details: NotificationDetails)
|
proc processNotification(self: NotificationsManager, title: string, message: string, details: NotificationDetails)
|
||||||
|
|
||||||
proc setup(self: NotificationsManager, events: EventEmitter) =
|
proc setup(self: NotificationsManager, events: EventEmitter) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
self.events = events
|
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.osNotification = newStatusOSNotification()
|
||||||
self.soundManager = newStatusSoundManager()
|
self.soundManager = newStatusSoundManager()
|
||||||
|
|
||||||
|
@ -62,14 +75,7 @@ QtObject:
|
||||||
self, "onMyRequestToJoinCommunityHasBeenAcccepted(QString, QString, QString)", 2)
|
self, "onMyRequestToJoinCommunityHasBeenAcccepted(QString, QString, QString)", 2)
|
||||||
signalConnect(singletonInstance.globalEvents, "myRequestToJoinCommunityHasBeenRejected(QString, QString, QString)",
|
signalConnect(singletonInstance.globalEvents, "myRequestToJoinCommunityHasBeenRejected(QString, QString, QString)",
|
||||||
self, "onMyRequestToJoinCommunityHasBeenRejected(QString, QString, QString)", 2)
|
self, "onMyRequestToJoinCommunityHasBeenRejected(QString, QString, QString)", 2)
|
||||||
|
self.notificationSetUp = true
|
||||||
proc delete*(self: NotificationsManager) =
|
|
||||||
self.osNotification.delete
|
|
||||||
self.QObject.delete
|
|
||||||
|
|
||||||
proc newNotificationsManager*(events: EventEmitter): NotificationsManager =
|
|
||||||
new(result, delete)
|
|
||||||
result.setup(events)
|
|
||||||
|
|
||||||
proc showOSNotification(self: NotificationsManager, title: string, message: string, identifier: string) =
|
proc showOSNotification(self: NotificationsManager, title: string, message: string, identifier: string) =
|
||||||
## This method will add new notification to the OS Notification center. Param
|
## This method will add new notification to the OS Notification center. Param
|
||||||
|
|
|
@ -636,10 +636,9 @@ method onContactDetailsUpdated*(self: Module, publicKey: string) =
|
||||||
|
|
||||||
method onNewMessagesReceived*(self: Module, chatId: string, unviewedMessagesCount: int, unviewedMentionsCount: int,
|
method onNewMessagesReceived*(self: Module, chatId: string, unviewedMessagesCount: int, unviewedMentionsCount: int,
|
||||||
messages: seq[MessageDto]) =
|
messages: seq[MessageDto]) =
|
||||||
if(self.controller.getMySectionId() == self.delegate.getActiveSectionId() and
|
if(self.controller.getMySectionId() != self.delegate.getActiveSectionId() or
|
||||||
self.controller.getActiveChatId() == chatId):
|
self.controller.getActiveChatId() != chatId):
|
||||||
return
|
self.updateBadgeNotifications(chatId, unviewedMessagesCount, unviewedMentionsCount)
|
||||||
self.updateBadgeNotifications(chatId, unviewedMessagesCount, unviewedMentionsCount)
|
|
||||||
|
|
||||||
# Prepare bubble notification
|
# Prepare bubble notification
|
||||||
let myPK = singletonInstance.userProfile.getPubKey()
|
let myPK = singletonInstance.userProfile.getPubKey()
|
||||||
|
|
Loading…
Reference in New Issue