forked from github/wulkanowy-mirror
Fix homework sync (#1627)
This commit is contained in:
parent
07b1969a35
commit
fb2d92c749
@ -5,8 +5,7 @@ import io.github.wulkanowy.data.db.entities.Student
|
|||||||
import io.github.wulkanowy.data.repositories.HomeworkRepository
|
import io.github.wulkanowy.data.repositories.HomeworkRepository
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||||
import io.github.wulkanowy.services.sync.notifications.NewHomeworkNotification
|
import io.github.wulkanowy.services.sync.notifications.NewHomeworkNotification
|
||||||
import io.github.wulkanowy.utils.monday
|
import io.github.wulkanowy.utils.nextOrSameSchoolDay
|
||||||
import io.github.wulkanowy.utils.sunday
|
|
||||||
import io.github.wulkanowy.utils.waitForResult
|
import io.github.wulkanowy.utils.waitForResult
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import java.time.LocalDate.now
|
import java.time.LocalDate.now
|
||||||
@ -22,13 +21,13 @@ class HomeworkWork @Inject constructor(
|
|||||||
homeworkRepository.getHomework(
|
homeworkRepository.getHomework(
|
||||||
student = student,
|
student = student,
|
||||||
semester = semester,
|
semester = semester,
|
||||||
start = now().monday,
|
start = now().nextOrSameSchoolDay,
|
||||||
end = now().sunday,
|
end = now().nextOrSameSchoolDay,
|
||||||
forceRefresh = true,
|
forceRefresh = true,
|
||||||
notify = preferencesRepository.isNotificationsEnable
|
notify = preferencesRepository.isNotificationsEnable
|
||||||
).waitForResult()
|
).waitForResult()
|
||||||
|
|
||||||
homeworkRepository.getHomeworkFromDatabase(semester, now().monday, now().sunday).first()
|
homeworkRepository.getHomeworkFromDatabase(semester, now(), now().plusDays(7)).first()
|
||||||
.filter { !it.isNotified }.let {
|
.filter { !it.isNotified }.let {
|
||||||
if (it.isNotEmpty()) newHomeworkNotification.notify(it, student)
|
if (it.isNotEmpty()) newHomeworkNotification.notify(it, student)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user