fix(notifs): only process notifs once the loading screen is done

Fixes #10912
This commit is contained in:
Jonathan Rainville 2023-11-21 13:26:26 -05:00
parent d4277f0732
commit 4e296d5acf
6 changed files with 39 additions and 27 deletions

View File

@ -19,15 +19,9 @@ const SIGNAL_DISPLAY_APP_NOTIFICATION* = "displayAppNotification"
const SIGNAL_DISPLAY_WINDOWS_OS_NOTIFICATION* = "displayWindowsOsNotification" const SIGNAL_DISPLAY_WINDOWS_OS_NOTIFICATION* = "displayWindowsOsNotification"
const SIGNAL_OS_NOTIFICATION_CLICKED* = "osNotificationClicked" const SIGNAL_OS_NOTIFICATION_CLICKED* = "osNotificationClicked"
# Notification preferences
const NOTIFY_ABOUT_ALL_MESSAGES = 0
const NOTIFY_JUST_ABOUT_MENTIONS = 1
const NOTIFY_NOTHING_ABOUT = 2
# Anonymous preferences # Anonymous preferences
const PREVIEW_ANONYMOUS = 0 const PREVIEW_ANONYMOUS = 0
const PREVIEW_NAME_ONLY = 1 const PREVIEW_NAME_ONLY = 1
const PREVIEW_NAME_AND_MESSAGE = 2
type type
NotificationArgs* = ref object of Args NotificationArgs* = ref object of Args
@ -64,7 +58,7 @@ QtObject:
new(result, delete) new(result, delete)
result.setup(events, settingsService) result.setup(events, settingsService)
proc init*(self: NotificationsManager) = proc onAppReady(self: NotificationsManager) =
self.osNotification = newStatusOSNotification() self.osNotification = newStatusOSNotification()
self.soundManager = newStatusSoundManager() self.soundManager = newStatusSoundManager()
@ -96,6 +90,10 @@ QtObject:
self.notificationSetUp = true self.notificationSetUp = true
proc init*(self: NotificationsManager) =
self.events.once(FAKE_LOADING_SCREEN_FINISHED) do(e:Args):
self.onAppReady()
proc showOSNotification(self: NotificationsManager, title: string, message: string, identifier: string) = proc showOSNotification(self: NotificationsManager, title: string, message: string, identifier: string) =
if defined(windows): if defined(windows):
let data = NotificationArgs(title: title, message: message) let data = NotificationArgs(title: title, message: message)
@ -208,10 +206,10 @@ QtObject:
self.osNotification.showIconBadgeNotification(allMentions) self.osNotification.showIconBadgeNotification(allMentions)
proc notificationCheck(self: NotificationsManager, title: string, message: string, details: NotificationDetails, proc notificationCheck(self: NotificationsManager, title: string, message: string, details: NotificationDetails,
notificationWay: string) = notificationWay: string) =
var data = NotificationArgs(title: title, message: message, details: details) var data = NotificationArgs(title: title, message: message, details: details)
# All but the NewMessage notifications go to Activity Center # All but the NewMessage notifications go to Activity Center
if(details.notificationType != NotificationType.NewMessage): if details.notificationType != NotificationType.NewMessage:
debug "Add AC notification", title=title, message=message debug "Add AC notification", title=title, message=message
self.events.emit(SIGNAL_ADD_NOTIFICATION_TO_ACTIVITY_CENTER, data) self.events.emit(SIGNAL_ADD_NOTIFICATION_TO_ACTIVITY_CENTER, data)
@ -220,28 +218,28 @@ QtObject:
let appIsActive = app_isActive(singletonInstance.engine) let appIsActive = app_isActive(singletonInstance.engine)
if(details.notificationType == NotificationType.NewMessage or if details.notificationType == NotificationType.NewMessage or
details.notificationType == NotificationType.NewMessageWithPersonalMention or
details.notificationType == NotificationType.NewMessageWithGlobalMention or
details.notificationType == NotificationType.NewContactRequest or
details.notificationType == NotificationType.ContactRemoved or
details.notificationType == NotificationType.IdentityVerificationRequest):
if(notificationWay == VALUE_NOTIF_DELIVER_QUIETLY):
return
if((details.notificationType == NotificationType.NewMessage or
details.notificationType == NotificationType.NewMessageWithPersonalMention or details.notificationType == NotificationType.NewMessageWithPersonalMention or
details.notificationType == NotificationType.NewMessageWithGlobalMention) and details.notificationType == NotificationType.NewMessageWithGlobalMention or
details.sectionActive and details.notificationType == NotificationType.NewContactRequest or
details.chatActive and appIsActive): details.notificationType == NotificationType.ContactRemoved or
details.notificationType == NotificationType.IdentityVerificationRequest:
if notificationWay == VALUE_NOTIF_DELIVER_QUIETLY:
return return
if(appIsActive): if (details.notificationType == NotificationType.NewMessage or
details.notificationType == NotificationType.NewMessageWithPersonalMention or
details.notificationType == NotificationType.NewMessageWithGlobalMention) and
details.sectionActive and
details.chatActive and appIsActive:
return
if appIsActive:
debug "Add APP notification", title=title, message=message debug "Add APP notification", title=title, message=message
self.events.emit(SIGNAL_DISPLAY_APP_NOTIFICATION, data) self.events.emit(SIGNAL_DISPLAY_APP_NOTIFICATION, data)
if(not appIsActive or details.notificationType == NotificationType.TestNotification): if not appIsActive or details.notificationType == NotificationType.TestNotification:
# Check anonymity level # Check anonymity level
if(self.settingsService.getNotificationMessagePreview() == PREVIEW_ANONYMOUS): if(self.settingsService.getNotificationMessagePreview() == PREVIEW_ANONYMOUS):
data.title = "Status" data.title = "Status"
@ -253,7 +251,7 @@ QtObject:
debug "Add OS notification", title=data.title, message=data.message, identifier=identifier debug "Add OS notification", title=data.title, message=data.message, identifier=identifier
self.showOSNotification(data.title, data.message, identifier) self.showOSNotification(data.title, data.message, identifier)
if(self.settingsService.getNotificationSoundsEnabled()): if self.settingsService.getNotificationSoundsEnabled():
self.soundManager.setPlayerVolume(self.settingsService.getNotificationVolume()) self.soundManager.setPlayerVolume(self.settingsService.getNotificationVolume())
self.soundManager.playSound(NOTIFICATION_SOUND) self.soundManager.playSound(NOTIFICATION_SOUND)

View File

@ -39,4 +39,5 @@ type
url*: string url*: string
userId*: string # can be public key or ens name userId*: string # can be public key or ens name
const SIGNAL_STATUS_URL_ACTIVATED* = "statusUrlActivated" const SIGNAL_STATUS_URL_ACTIVATED* = "statusUrlActivated"
const FAKE_LOADING_SCREEN_FINISHED* = "fakeLoadingScreenFinished"

View File

@ -392,6 +392,9 @@ method insertMockedKeycardAction*(self: AccessInterface, cardIndex: int) {.base.
method removeMockedKeycardAction*(self: AccessInterface) {.base.} = method removeMockedKeycardAction*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method fakeLoadingScreenFinished*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method onCommunityTokensDetailsLoaded*(self: AccessInterface, communityId: string, method onCommunityTokensDetailsLoaded*(self: AccessInterface, communityId: string,
communityTokens: seq[CommunityTokenDto], communityTokenJsonItems: JsonNode) {.base.} = communityTokens: seq[CommunityTokenDto], communityTokenJsonItems: JsonNode) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -1570,4 +1570,7 @@ method insertMockedKeycardAction*[T](self: Module[T], cardIndex: int) =
method removeMockedKeycardAction*[T](self: Module[T]) = method removeMockedKeycardAction*[T](self: Module[T]) =
self.keycardService.removeMockedKeycardAction() self.keycardService.removeMockedKeycardAction()
method fakeLoadingScreenFinished*[T](self: Module[T]) =
self.events.emit(FAKE_LOADING_SCREEN_FINISHED, Args())
{.pop.} {.pop.}

View File

@ -323,3 +323,6 @@ QtObject:
proc removeMockedKeycardAction*(self: View) {.slot.} = proc removeMockedKeycardAction*(self: View) {.slot.} =
self.delegate.removeMockedKeycardAction() self.delegate.removeMockedKeycardAction()
proc fakeLoadingScreenFinished*(self: View) {.slot.} =
self.delegate.fakeLoadingScreenFinished()

View File

@ -196,6 +196,9 @@ StatusWindow {
// We set main module to the Global singleton once user is logged in and we move to the main app. // We set main module to the Global singleton once user is logged in and we move to the main app.
appLoadingAnimation.active = localAppSettings && localAppSettings.fakeLoadingScreenEnabled appLoadingAnimation.active = localAppSettings && localAppSettings.fakeLoadingScreenEnabled
appLoadingAnimation.runningProgressAnimation = localAppSettings && localAppSettings.fakeLoadingScreenEnabled appLoadingAnimation.runningProgressAnimation = localAppSettings && localAppSettings.fakeLoadingScreenEnabled
if (!appLoadingAnimation.runningProgressAnimation) {
mainModule.fakeLoadingScreenFinished()
}
Global.userProfile = userProfile Global.userProfile = userProfile
Global.appIsReady = true Global.appIsReady = true
@ -382,6 +385,7 @@ StatusWindow {
onProgressChanged: { onProgressChanged: {
if (progress === 1) { if (progress === 1) {
appLoadingAnimation.active = false appLoadingAnimation.active = false
mainModule.fakeLoadingScreenFinished()
} }
} }
} }