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) { fun show(habit: Habit, timestamp: Timestamp, reminderTime: Long) {
val data = NotificationData(timestamp, reminderTime) val data = NotificationData(timestamp, reminderTime)
taskRunner.execute(ShowNotificationTask(habit, data)) taskRunner.execute(ShowNotificationTask(habit, data, false))
} }
fun startListening() { fun startListening() {
@ -107,7 +107,7 @@ class NotificationTray @Inject constructor(
fun reshowAll() { fun reshowAll() {
for ((habit, data) in active.entries) { 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( internal class NotificationData(
val timestamp: Timestamp, val timestamp: Timestamp,
val reminderTime: Long, val reminderTime: Long,
var shown: Boolean = false
) )
private inner class ShowNotificationTask( private inner class ShowNotificationTask(
private val habit: Habit, private val habit: Habit,
private val data: NotificationData private val data: NotificationData,
private val shown: Boolean
) : ) :
Task { Task {
var isCompleted = false var isCompleted = false
@ -193,9 +193,9 @@ class NotificationTray @Inject constructor(
getNotificationId(habit), getNotificationId(habit),
data.timestamp, data.timestamp,
data.reminderTime, data.reminderTime,
silent = data.shown silent = shown
) )
if (data.shown) { if (shown) {
systemTray.log( systemTray.log(
String.format( String.format(
Locale.US, Locale.US,
@ -204,7 +204,6 @@ class NotificationTray @Inject constructor(
) )
) )
} }
data.shown = true
active[habit] = data active[habit] = data
} }

Loading…
Cancel
Save