forked from github/wulkanowy-mirror
Add missing sdk initialization in lucky number repository (#752)
This commit is contained in:
parent
bf61dd1bad
commit
3612326628
@ -2,6 +2,7 @@ package io.github.wulkanowy.data.repositories.luckynumber
|
||||
|
||||
import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
|
||||
import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings
|
||||
import io.github.wulkanowy.data.SdkHelper
|
||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.reactivex.Completable
|
||||
@ -15,11 +16,13 @@ import javax.inject.Singleton
|
||||
class LuckyNumberRepository @Inject constructor(
|
||||
private val settings: InternetObservingSettings,
|
||||
private val local: LuckyNumberLocal,
|
||||
private val remote: LuckyNumberRemote
|
||||
private val remote: LuckyNumberRemote,
|
||||
private val sdkHelper: SdkHelper
|
||||
) {
|
||||
|
||||
fun getLuckyNumber(student: Student, forceRefresh: Boolean = false, notify: Boolean = false): Maybe<LuckyNumber> {
|
||||
return local.getLuckyNumber(student, LocalDate.now()).filter { !forceRefresh }
|
||||
return Maybe.just(sdkHelper.init(student)).flatMap {
|
||||
local.getLuckyNumber(student, LocalDate.now()).filter { !forceRefresh }
|
||||
.switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings)
|
||||
.flatMapMaybe {
|
||||
if (it) remote.getLuckyNumber(student)
|
||||
@ -43,6 +46,7 @@ class LuckyNumberRepository @Inject constructor(
|
||||
{ local.getLuckyNumber(student, LocalDate.now()) })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun getNotNotifiedLuckyNumber(student: Student): Maybe<LuckyNumber> {
|
||||
return local.getLuckyNumber(student, LocalDate.now()).filter { !it.isNotified }
|
||||
|
Loading…
x
Reference in New Issue
Block a user