mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2024-11-23 20:16:02 -06:00
Add checking current student in background services (#295)
This commit is contained in:
parent
36785f019a
commit
316cd2f7f9
@ -11,10 +11,10 @@ cache:
|
|||||||
- $HOME/.gradle/caches/
|
- $HOME/.gradle/caches/
|
||||||
- $HOME/.gradle/wrapper/
|
- $HOME/.gradle/wrapper/
|
||||||
|
|
||||||
#branches:
|
branches:
|
||||||
# only:
|
only:
|
||||||
# - master
|
- master
|
||||||
# - 0.7.x
|
- 0.7.x
|
||||||
|
|
||||||
android:
|
android:
|
||||||
licenses:
|
licenses:
|
||||||
|
@ -34,12 +34,17 @@ class SyncWorker @AssistedInject constructor(
|
|||||||
) : RxWorker(appContext, workerParameters) {
|
) : RxWorker(appContext, workerParameters) {
|
||||||
|
|
||||||
override fun createWork(): Single<Result> {
|
override fun createWork(): Single<Result> {
|
||||||
return studentRepository.getCurrentStudent()
|
return studentRepository.isStudentSaved()
|
||||||
.flatMapCompletable { student ->
|
.flatMapCompletable { isSaved ->
|
||||||
semesterRepository.getCurrentSemester(student, true)
|
if (isSaved) {
|
||||||
.flatMapCompletable { semester ->
|
studentRepository.getCurrentStudent()
|
||||||
Completable.mergeDelayError(works.map { it.create(student, semester) })
|
.flatMapCompletable { student ->
|
||||||
}
|
semesterRepository.getCurrentSemester(student)
|
||||||
|
.flatMapCompletable { semester ->
|
||||||
|
Completable.mergeDelayError(works.map { it.create(student, semester) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else Completable.complete()
|
||||||
}
|
}
|
||||||
.toSingleDefault(Result.success())
|
.toSingleDefault(Result.success())
|
||||||
.onErrorReturn {
|
.onErrorReturn {
|
||||||
|
@ -17,6 +17,7 @@ import io.github.wulkanowy.data.repositories.student.StudentRepository
|
|||||||
import io.github.wulkanowy.data.repositories.timetable.TimetableRepository
|
import io.github.wulkanowy.data.repositories.timetable.TimetableRepository
|
||||||
import io.github.wulkanowy.utils.SchedulersProvider
|
import io.github.wulkanowy.utils.SchedulersProvider
|
||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
|
import io.reactivex.Single
|
||||||
import org.threeten.bp.LocalDate
|
import org.threeten.bp.LocalDate
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
@ -51,9 +52,13 @@ class TimetableWidgetFactory(
|
|||||||
?.let { date ->
|
?.let { date ->
|
||||||
try {
|
try {
|
||||||
lessons = studentRepository.isStudentSaved()
|
lessons = studentRepository.isStudentSaved()
|
||||||
.flatMap { studentRepository.getCurrentStudent() }
|
.flatMap { isSaved ->
|
||||||
.flatMap { semesterRepository.getCurrentSemester(it) }
|
if (isSaved) {
|
||||||
.flatMap { timetableRepository.getTimetable(it, date, date) }
|
studentRepository.getCurrentStudent()
|
||||||
|
.flatMap { semesterRepository.getCurrentSemester(it) }
|
||||||
|
.flatMap { timetableRepository.getTimetable(it, date, date) }
|
||||||
|
} else Single.just(emptyList())
|
||||||
|
}
|
||||||
.map { item -> item.sortedBy { it.number } }
|
.map { item -> item.sortedBy { it.number } }
|
||||||
.subscribeOn(schedulers.backgroundThread)
|
.subscribeOn(schedulers.backgroundThread)
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
|
Loading…
Reference in New Issue
Block a user