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