Mitigate notifications from old grades (#258)

Fixes #257
This commit is contained in:
Mikołaj Pich
2019-03-02 19:15:37 +01:00
committed by Rafał Borcz
parent f8ee5cb062
commit e910c7a48e
13 changed files with 227 additions and 15 deletions

View File

@ -27,10 +27,11 @@ class GradeRepository @Inject constructor(
}.flatMap { newGrades ->
local.getGrades(semester).toSingle(emptyList())
.doOnSuccess { oldGrades ->
val notifyBreakDate = oldGrades.maxBy { it.date }?.date ?: student.registrationDate.toLocalDate()
local.deleteGrades(oldGrades - newGrades)
local.saveGrades((newGrades - oldGrades)
.onEach {
if (student.registrationDate <= it.date.atStartOfDay()) {
if (it.date >= notifyBreakDate) {
if (notify) it.isNotified = false
it.isRead = false
}