1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2025-01-31 19:02:45 +01:00

Fix receiving a lot of notifications after turning them off for a while (#225)

This commit is contained in:
Kacper Ziubryniewicz 2019-01-24 18:32:51 +01:00 committed by Rafał Borcz
parent 941765a3a3
commit c78fb83774

View File

@ -84,18 +84,20 @@ class SyncWorker : SimpleJobService() {
var error: Throwable? = null var error: Throwable? = null
val notify = prefRepository.isNotificationsEnable
disposable.add(student.getCurrentStudent() disposable.add(student.getCurrentStudent()
.flatMap { semester.getCurrentSemester(it, true).map { semester -> semester to it } } .flatMap { semester.getCurrentSemester(it, true).map { semester -> semester to it } }
.flatMapPublisher { .flatMapPublisher {
Single.merge( Single.merge(
listOf( listOf(
gradesDetails.getGrades(it.first, true, true), gradesDetails.getGrades(it.first, true, notify),
gradesSummary.getGradesSummary(it.first, true), gradesSummary.getGradesSummary(it.first, true),
attendance.getAttendance(it.first, start, end, true), attendance.getAttendance(it.first, start, end, true),
exam.getExams(it.first, start, end, true), exam.getExams(it.first, start, end, true),
timetable.getTimetable(it.first, start, end, true), timetable.getTimetable(it.first, start, end, true),
message.getMessages(it.second, RECEIVED, true, true), message.getMessages(it.second, RECEIVED, true, notify),
note.getNotes(it.first, true, true), note.getNotes(it.first, true, notify),
homework.getHomework(it.first, LocalDate.now(), true), homework.getHomework(it.first, LocalDate.now(), true),
homework.getHomework(it.first, LocalDate.now().plusDays(1), true) homework.getHomework(it.first, LocalDate.now().plusDays(1), true)
) )
@ -104,7 +106,7 @@ class SyncWorker : SimpleJobService() {
.subscribe({}, { error = it })) .subscribe({}, { error = it }))
return if (null === error) { return if (null === error) {
if (prefRepository.isNotificationsEnable) sendNotifications() if (notify) sendNotifications()
Timber.d("Synchronization successful") Timber.d("Synchronization successful")
RESULT_SUCCESS RESULT_SUCCESS
} else { } else {