Skip to content

Commit 7edefb4

Browse files
committed
quickshell/notifications: persist notification time
1 parent 5462246 commit 7edefb4

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

home/services/quickshell/notifications/NotificationBox.qml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ WrapperMouseArea {
1616
hoverEnabled: true
1717

1818
property Notification n
19-
property int elapsed: 0
19+
property int elapsed: getElapsed()
2020
property string image: (n.image == "" && n.appIcon != "") ? n.appIcon : n.image
2121
property bool hasAppIcon: !(n.image == "" && n.appIcon != "")
2222
property real iconSize: 48
@@ -26,6 +26,10 @@ WrapperMouseArea {
2626

2727
property bool dismissOnClose: true
2828

29+
function getElapsed(): int {
30+
return Math.floor(Date.now() / 1000) - Math.floor(n.time / 1000);
31+
}
32+
2933
onClicked: mouse => {
3034
if (mouse.button == Qt.LeftButton && root.n?.actions != []) {
3135
root.n?.actions[0].invoke();
@@ -42,15 +46,14 @@ WrapperMouseArea {
4246
}
4347
}
4448

45-
ElapsedTimer {
46-
id: elapsedTimer
47-
}
48-
4949
Timer {
5050
running: root.showTime
5151
interval: 1000
5252
repeat: true
53-
onTriggered: root.elapsed = elapsedTimer.elapsed()
53+
onTriggered: {
54+
console.log(Math.floor(Date.now() % 1000), Math.floor(root.n.time / 1000), root.getElapsed());
55+
root.elapsed = root.getElapsed();
56+
}
5457
}
5558

5659
Rectangle {

home/services/quickshell/utils/NotificationState.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Singleton {
7979

8080
onNotification: notif => {
8181
notif.tracked = true;
82+
notif.time = Date.now();
8283
root.onNewNotif(notif);
8384
console.log("notif: appName", notif.appName || "null", ", appIcon", notif.appIcon || "null", ", image", notif.image || "null", ", expireTimeout", notif.expireTimeout)
8485

0 commit comments

Comments
 (0)