mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 21:06:44 -06:00
[Events] Disable shared notification for past events.
This commit is contained in:
parent
454f82e139
commit
371acb2d2a
@ -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.Metadata
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Notification
|
import pl.szczodrzynski.edziennik.data.db.entity.Notification
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
import pl.szczodrzynski.edziennik.data.db.entity.Profile
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
|
||||||
class AppSync(val app: App, val notifications: MutableList<Notification>, val profiles: List<Profile>, val api: SzkolnyApi) {
|
class AppSync(val app: App, val notifications: MutableList<Notification>, val profiles: List<Profile>, val api: SzkolnyApi) {
|
||||||
companion object {
|
companion object {
|
||||||
@ -31,13 +32,15 @@ class AppSync(val app: App, val notifications: MutableList<Notification>, val pr
|
|||||||
app.config.sync.lastAppSync = System.currentTimeMillis()
|
app.config.sync.lastAppSync = System.currentTimeMillis()
|
||||||
|
|
||||||
if (events.isNotEmpty()) {
|
if (events.isNotEmpty()) {
|
||||||
|
val today = Date.getToday()
|
||||||
app.db.metadataDao().addAllIgnore(events.map { event ->
|
app.db.metadataDao().addAllIgnore(events.map { event ->
|
||||||
|
val isPast = event.eventDate < today
|
||||||
Metadata(
|
Metadata(
|
||||||
event.profileId,
|
event.profileId,
|
||||||
Metadata.TYPE_EVENT,
|
Metadata.TYPE_EVENT,
|
||||||
event.id,
|
event.id,
|
||||||
markAsSeen || event.seen,
|
isPast || markAsSeen || event.seen,
|
||||||
markAsSeen || event.notified,
|
isPast || markAsSeen || event.notified,
|
||||||
event.addedDate
|
event.addedDate
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user