mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 03:06:50 -06:00
Fix empty Maybe in student repository (#224)
This commit is contained in:
parent
189830e0f4
commit
941765a3a3
@ -7,6 +7,7 @@ import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.repositories.local.StudentLocal
|
||||
import io.github.wulkanowy.data.repositories.remote.StudentRemote
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.Maybe
|
||||
import io.reactivex.Single
|
||||
import java.net.UnknownHostException
|
||||
import javax.inject.Inject
|
||||
@ -41,7 +42,9 @@ class StudentRepository @Inject constructor(
|
||||
}
|
||||
|
||||
fun getCurrentStudent(decryptPass: Boolean = true): Single<Student> {
|
||||
return local.getCurrentStudent(decryptPass).toSingle()
|
||||
return local.getCurrentStudent(decryptPass)
|
||||
.switchIfEmpty(Maybe.error(NoSuchElementException("No current student")))
|
||||
.toSingle()
|
||||
}
|
||||
|
||||
fun saveStudent(student: Student): Single<Long> {
|
||||
|
@ -80,6 +80,7 @@ class SyncWorker : SimpleJobService() {
|
||||
val end = LocalDate.now().friday
|
||||
|
||||
if (start.isHolidays) return RESULT_FAIL_NORETRY
|
||||
if (!student.isStudentSaved) return RESULT_FAIL_RETRY
|
||||
|
||||
var error: Throwable? = null
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user