From c78fb837748875b14f3080383656173d710eccd0 Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Thu, 24 Jan 2019 18:32:51 +0100 Subject: [PATCH] Fix receiving a lot of notifications after turning them off for a while (#225) --- .../io/github/wulkanowy/services/job/SyncWorker.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/services/job/SyncWorker.kt b/app/src/main/java/io/github/wulkanowy/services/job/SyncWorker.kt index 6e8566718..cf09728a6 100644 --- a/app/src/main/java/io/github/wulkanowy/services/job/SyncWorker.kt +++ b/app/src/main/java/io/github/wulkanowy/services/job/SyncWorker.kt @@ -84,18 +84,20 @@ class SyncWorker : SimpleJobService() { var error: Throwable? = null + val notify = prefRepository.isNotificationsEnable + disposable.add(student.getCurrentStudent() .flatMap { semester.getCurrentSemester(it, true).map { semester -> semester to it } } .flatMapPublisher { Single.merge( listOf( - gradesDetails.getGrades(it.first, true, true), + gradesDetails.getGrades(it.first, true, notify), gradesSummary.getGradesSummary(it.first, true), attendance.getAttendance(it.first, start, end, true), exam.getExams(it.first, start, end, true), timetable.getTimetable(it.first, start, end, true), - message.getMessages(it.second, RECEIVED, true, true), - note.getNotes(it.first, true, true), + message.getMessages(it.second, RECEIVED, true, notify), + note.getNotes(it.first, true, notify), homework.getHomework(it.first, LocalDate.now(), true), homework.getHomework(it.first, LocalDate.now().plusDays(1), true) ) @@ -104,7 +106,7 @@ class SyncWorker : SimpleJobService() { .subscribe({}, { error = it })) return if (null === error) { - if (prefRepository.isNotificationsEnable) sendNotifications() + if (notify) sendNotifications() Timber.d("Synchronization successful") RESULT_SUCCESS } else {