fix(@desktop/notifications): nothing happens after clicking on any notification
Fixes: #5935
This commit is contained in:
parent
4cd9e0c96e
commit
73abf3a982
|
@ -6,6 +6,7 @@ include ../../../app_service/common/json_utils
|
|||
|
||||
type
|
||||
NotificationType* {.pure.} = enum
|
||||
UnknownNotification,
|
||||
TestNotification,
|
||||
NewContactRequest,
|
||||
AcceptedContactRequest,
|
||||
|
@ -18,7 +19,7 @@ type
|
|||
IdentityVerificationRequest
|
||||
|
||||
NotificationDetails* = object
|
||||
notificationType*: NotificationType
|
||||
notificationType*: NotificationType # the default value is `UnknownNotification`
|
||||
sectionId*: string
|
||||
isCommunitySection*: bool
|
||||
sectionActive*: bool
|
||||
|
@ -28,6 +29,9 @@ type
|
|||
isGroupChat*: bool
|
||||
messageId*: string
|
||||
|
||||
proc isEmpty*(self: NotificationDetails): bool =
|
||||
return self.notificationType == NotificationType.UnknownNotification
|
||||
|
||||
proc toNotificationDetails*(jsonObj: JsonNode): NotificationDetails =
|
||||
var notificationType: int
|
||||
if (not (jsonObj.getProp("notificationType", notificationType) and
|
||||
|
|
|
@ -98,6 +98,9 @@ QtObject:
|
|||
app_makeItActive(singletonInstance.engine)
|
||||
|
||||
let details = toNotificationDetails(parseJson(identifier))
|
||||
if(details.isEmpty()):
|
||||
info "Notification details are empty"
|
||||
return
|
||||
if(details.notificationType == NotificationType.TestNotification):
|
||||
info "Test notification was clicked"
|
||||
return
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import ../../core/notifications/details
|
||||
|
||||
type
|
||||
EphemeralNotificationType* {.pure.} = enum
|
||||
Default = 0
|
||||
|
@ -13,6 +15,7 @@ type
|
|||
loading: bool
|
||||
ephNotifType: EphemeralNotificationType
|
||||
url: string
|
||||
details: NotificationDetails
|
||||
|
||||
proc initItem*(id: int64,
|
||||
title: string,
|
||||
|
@ -21,7 +24,8 @@ proc initItem*(id: int64,
|
|||
icon = "",
|
||||
loading = false,
|
||||
ephNotifType = EphemeralNotificationType.Default,
|
||||
url = ""): Item =
|
||||
url = "",
|
||||
details: NotificationDetails): Item =
|
||||
result = Item()
|
||||
result.id = id
|
||||
result.durationInMs = durationInMs
|
||||
|
@ -31,6 +35,7 @@ proc initItem*(id: int64,
|
|||
result.loading = loading
|
||||
result.ephNotifType = ephNotifType
|
||||
result.url = url
|
||||
result.details = details
|
||||
|
||||
proc id*(self: Item): int64 =
|
||||
self.id
|
||||
|
@ -55,3 +60,6 @@ proc ephNotifType*(self: Item): EphemeralNotificationType =
|
|||
|
||||
proc url*(self: Item): string =
|
||||
self.url
|
||||
|
||||
proc details*(self: Item): NotificationDetails =
|
||||
self.details
|
|
@ -73,6 +73,12 @@ QtObject:
|
|||
if(self.items[i].id == id):
|
||||
return i
|
||||
return -1
|
||||
|
||||
proc getItemWithId*(self: Model, id: int64): Item =
|
||||
let ind = self.findIndexById(id)
|
||||
if(ind == -1):
|
||||
return
|
||||
return self.items[ind]
|
||||
|
||||
proc addItem*(self: Model, item: Item) =
|
||||
let parentModelIndex = newQModelIndex()
|
||||
|
|
|
@ -137,12 +137,15 @@ method displayEphemeralNotification*(self: AccessInterface, title: string, subTi
|
|||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method displayEphemeralNotification*(self: AccessInterface, title: string, subTitle: string, icon: string, loading: bool,
|
||||
ephNotifType: int, url: string) {.base.} =
|
||||
ephNotifType: int, url: string, details = NotificationDetails()) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method removeEphemeralNotification*(self: AccessInterface, id: int64) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method ephemeralNotificationClicked*(self: AccessInterface, id: int64) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method newCommunityMembershipRequestReceived*(self: AccessInterface, membershipRequest: CommunityMembershipRequestDto)
|
||||
{.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
|
@ -781,32 +781,43 @@ method meMentionedCountChanged*[T](self: Module[T], allMentions: int) =
|
|||
singletonInstance.globalEvents.meMentionedIconBadgeNotification(allMentions)
|
||||
|
||||
method displayEphemeralNotification*[T](self: Module[T], title: string, subTitle: string, icon: string, loading: bool,
|
||||
ephNotifType: int, url: string) =
|
||||
ephNotifType: int, url: string, details = NotificationDetails()) =
|
||||
let now = getTime()
|
||||
let id = now.toUnix * 1000000000 + now.nanosecond
|
||||
var finalEphNotifType = EphemeralNotificationType.Default
|
||||
if(ephNotifType == EphemeralNotificationType.Success.int):
|
||||
finalEphNotifType = EphemeralNotificationType.Success
|
||||
let item = ephemeral_notification_item.initItem(id, title, TOAST_MESSAGE_VISIBILITY_DURATION_IN_MS, subTitle, icon,
|
||||
loading, finalEphNotifType, url)
|
||||
loading, finalEphNotifType, url, details)
|
||||
self.view.ephemeralNotificationModel().addItem(item)
|
||||
|
||||
method displayEphemeralNotification*[T](self: Module[T], title: string, subTitle: string, details: NotificationDetails) =
|
||||
if(details.notificationType == NotificationType.NewMessage or
|
||||
details.notificationType == NotificationType.NewMessageWithPersonalMention or
|
||||
details.notificationType == NotificationType.NewMessageWithGlobalMention):
|
||||
self.displayEphemeralNotification(title, subTitle, "", false, EphemeralNotificationType.Default.int, "")
|
||||
self.displayEphemeralNotification(title, subTitle, "", false, EphemeralNotificationType.Default.int, "", details)
|
||||
|
||||
elif(details.notificationType == NotificationType.NewContactRequest or
|
||||
details.notificationType == NotificationType.IdentityVerificationRequest):
|
||||
self.displayEphemeralNotification(title, subTitle, "contact", false, EphemeralNotificationType.Default.int, "")
|
||||
self.displayEphemeralNotification(title, subTitle, "contact", false, EphemeralNotificationType.Default.int, "", details)
|
||||
|
||||
elif(details.notificationType == NotificationType.AcceptedContactRequest):
|
||||
self.displayEphemeralNotification(title, subTitle, "checkmark-circle", false, EphemeralNotificationType.Success.int, "")
|
||||
self.displayEphemeralNotification(title, subTitle, "checkmark-circle", false, EphemeralNotificationType.Success.int, "", details)
|
||||
|
||||
method removeEphemeralNotification*[T](self: Module[T], id: int64) =
|
||||
self.view.ephemeralNotificationModel().removeItemWithId(id)
|
||||
|
||||
method ephemeralNotificationClicked*[T](self: Module[T], id: int64) =
|
||||
let item = self.view.ephemeralNotificationModel().getItemWithId(id)
|
||||
if(item.details.isEmpty()):
|
||||
return
|
||||
if(item.details.notificationType == NotificationType.NewMessage or
|
||||
item.details.notificationType == NotificationType.NewMessageWithPersonalMention or
|
||||
item.details.notificationType == NotificationType.NewMessageWithGlobalMention):
|
||||
self.controller.switchTo(item.details.sectionId, item.details.chatId, item.details.messageId)
|
||||
else:
|
||||
self.osNotificationClicked(item.details)
|
||||
|
||||
method onStatusUrlRequested*[T](self: Module[T], action: StatusUrlAction, communityId: string, chatId: string,
|
||||
url: string, userId: string, groupName: string, listOfUserIds: seq[string]) =
|
||||
|
||||
|
|
|
@ -105,6 +105,9 @@ QtObject:
|
|||
proc removeEphemeralNotification*(self: View, id: string) {.slot.} =
|
||||
self.delegate.removeEphemeralNotification(id.parseInt)
|
||||
|
||||
proc ephemeralNotificationClicked*(self: View, id: string) {.slot.} =
|
||||
self.delegate.ephemeralNotificationClicked(id.parseInt)
|
||||
|
||||
proc openStoreToKeychainPopup*(self: View) {.signal.}
|
||||
|
||||
proc offerToStorePassword*(self: View) =
|
||||
|
|
|
@ -986,6 +986,10 @@ Item {
|
|||
type: model.ephNotifType
|
||||
linkUrl: model.url
|
||||
duration: model.durationInMs
|
||||
onClicked: {
|
||||
appMain.rootStore.mainModuleInst.ephemeralNotificationClicked(model.id)
|
||||
this.open = false
|
||||
}
|
||||
onLinkActivated: {
|
||||
Qt.openUrlExternally(link);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue