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`.
pull/1509/head
Felix Wiemuth 3 years ago
parent 68f2639c77
commit 41743595d5

@ -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
}

Loading…
Cancel
Save