1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 04:39:09 -05:00

Fix empty Maybe in student repository (#224)

This commit is contained in:
Rafał Borcz 2019-01-23 18:28:51 +01:00 committed by Mikołaj Pich
parent 189830e0f4
commit 941765a3a3
2 changed files with 5 additions and 1 deletions

View File

@ -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> {

View File

@ -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