From 371acb2d2ad99e9e3285ba0fdb9ee4fe2e1069c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Sun, 15 Mar 2020 20:01:23 +0100 Subject: [PATCH] [Events] Disable shared notification for past events. --- .../pl/szczodrzynski/edziennik/data/api/task/AppSync.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/AppSync.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/AppSync.kt index 3d0e37d6..56d5132a 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/AppSync.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/task/AppSync.kt @@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.data.api.szkolny.SzkolnyApi import pl.szczodrzynski.edziennik.data.db.entity.Metadata import pl.szczodrzynski.edziennik.data.db.entity.Notification import pl.szczodrzynski.edziennik.data.db.entity.Profile +import pl.szczodrzynski.edziennik.utils.models.Date class AppSync(val app: App, val notifications: MutableList, val profiles: List, val api: SzkolnyApi) { companion object { @@ -31,13 +32,15 @@ class AppSync(val app: App, val notifications: MutableList, val pr app.config.sync.lastAppSync = System.currentTimeMillis() if (events.isNotEmpty()) { + val today = Date.getToday() app.db.metadataDao().addAllIgnore(events.map { event -> + val isPast = event.eventDate < today Metadata( event.profileId, Metadata.TYPE_EVENT, event.id, - markAsSeen || event.seen, - markAsSeen || event.notified, + isPast || markAsSeen || event.seen, + isPast || markAsSeen || event.notified, event.addedDate ) })