From 2da05c0025ed4d82509b79ad55f70ebbf9bfaabf Mon Sep 17 00:00:00 2001 From: PavelS Date: Thu, 29 Sep 2022 16:45:34 +0300 Subject: [PATCH] fix(@desktop/chat): update toast message logic Fixes #7487 --- src/app/modules/main/ephemeral_notification_item.nim | 5 +++++ src/app/modules/main/ephemeral_notification_model.nim | 4 ++++ ui/app/mainui/AppMain.qml | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/modules/main/ephemeral_notification_item.nim b/src/app/modules/main/ephemeral_notification_item.nim index 7f8f6832da..3be720dd3c 100644 --- a/src/app/modules/main/ephemeral_notification_item.nim +++ b/src/app/modules/main/ephemeral_notification_item.nim @@ -8,6 +8,7 @@ type type Item* = object id: int64 + timestamp: string title: string durationInMs: int subTitle: string @@ -28,6 +29,7 @@ proc initItem*(id: int64, details: NotificationDetails): Item = result = Item() result.id = id + result.timestamp = $id result.durationInMs = durationInMs result.title = title result.subTitle = subTitle @@ -40,6 +42,9 @@ proc initItem*(id: int64, proc id*(self: Item): int64 = self.id +proc timestamp*(self: Item): string = + self.timestamp + proc title*(self: Item): string = self.title diff --git a/src/app/modules/main/ephemeral_notification_model.nim b/src/app/modules/main/ephemeral_notification_model.nim index d4e2a95c8a..276e90bc2e 100644 --- a/src/app/modules/main/ephemeral_notification_model.nim +++ b/src/app/modules/main/ephemeral_notification_model.nim @@ -4,6 +4,7 @@ import ephemeral_notification_item type ModelRole {.pure.} = enum Id = UserRole + 1 + Timestamp DurationInMs Title SubTitle @@ -33,6 +34,7 @@ QtObject: method roleNames(self: Model): Table[int, string] = { ModelRole.Id.int:"id", + ModelRole.Timestamp.int:"timestamp", ModelRole.DurationInMs.int:"durationInMs", ModelRole.Title.int:"title", ModelRole.SubTitle.int:"subTitle", @@ -53,6 +55,8 @@ QtObject: case enumRole: of ModelRole.Id: result = newQVariant(item.id) + of ModelRole.Timestamp: + result = newQVariant(item.timestamp) of ModelRole.DurationInMs: result = newQVariant(item.durationInMs) of ModelRole.Title: diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index f1cae7f9f5..a752e0e58f 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1199,7 +1199,7 @@ Item { linkUrl: model.url duration: model.durationInMs onClicked: { - appMain.rootStore.mainModuleInst.ephemeralNotificationClicked(model.id) + appMain.rootStore.mainModuleInst.ephemeralNotificationClicked(model.timestamp) this.open = false } onLinkActivated: { @@ -1207,7 +1207,7 @@ Item { } onClose: { - appMain.rootStore.mainModuleInst.removeEphemeralNotification(model.id) + appMain.rootStore.mainModuleInst.removeEphemeralNotification(model.timestamp) } } }