From 41743595d5cd65208561a9ee331e0d09d6ce8d3f Mon Sep 17 00:00:00 2001 From: Felix Wiemuth <533601+felixwiemuth@users.noreply.github.com> Date: Sun, 18 Sep 2022 10:22:29 +0200 Subject: [PATCH] Remove `shown` field from `NotificationData` It is not necessary to keep this field as in the map of active notifications (and its persisted form) this field is always `true`. --- .../org/isoron/uhabits/core/ui/NotificationTray.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/ui/NotificationTray.kt b/uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/ui/NotificationTray.kt index 09bb9596a..a5a46333c 100644 --- a/uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/ui/NotificationTray.kt +++ b/uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/ui/NotificationTray.kt @@ -87,7 +87,7 @@ class NotificationTray @Inject constructor( fun show(habit: Habit, timestamp: Timestamp, reminderTime: Long) { val data = NotificationData(timestamp, reminderTime) - taskRunner.execute(ShowNotificationTask(habit, data)) + taskRunner.execute(ShowNotificationTask(habit, data, false)) } fun startListening() { @@ -107,7 +107,7 @@ class NotificationTray @Inject constructor( fun reshowAll() { for ((habit, data) in active.entries) { - taskRunner.execute(ShowNotificationTask(habit, data)) + taskRunner.execute(ShowNotificationTask(habit, data, true)) } } @@ -128,12 +128,12 @@ class NotificationTray @Inject constructor( internal class NotificationData( val timestamp: Timestamp, val reminderTime: Long, - var shown: Boolean = false ) private inner class ShowNotificationTask( private val habit: Habit, - private val data: NotificationData + private val data: NotificationData, + private val shown: Boolean ) : Task { var isCompleted = false @@ -193,9 +193,9 @@ class NotificationTray @Inject constructor( getNotificationId(habit), data.timestamp, data.reminderTime, - silent = data.shown + silent = shown ) - if (data.shown) { + if (shown) { systemTray.log( String.format( Locale.US, @@ -204,7 +204,6 @@ class NotificationTray @Inject constructor( ) ) } - data.shown = true active[habit] = data }