mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2024-11-23 18:06:01 -06:00
Fix no current student in services after logout all accounts (#342)
This commit is contained in:
parent
667c4b6af7
commit
0977282a4b
@ -11,10 +11,10 @@ cache:
|
||||
- $HOME/.gradle/caches/
|
||||
- $HOME/.gradle/wrapper/
|
||||
|
||||
#branches:
|
||||
# only:
|
||||
# - master
|
||||
# - 0.8.x
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- 0.8.x
|
||||
|
||||
android:
|
||||
licenses:
|
||||
|
@ -22,6 +22,8 @@ class StudentRepository @Inject constructor(
|
||||
|
||||
fun isStudentSaved(): Single<Boolean> = local.getStudents(false).isEmpty.map { !it }
|
||||
|
||||
fun isCurrentStudentSet(): Single<Boolean> = local.getCurrentStudent(false).isEmpty.map { !it }
|
||||
|
||||
fun getStudents(email: String, password: String, endpoint: String, symbol: String = ""): Single<List<Student>> {
|
||||
return ReactiveNetwork.checkInternetConnectivity(settings)
|
||||
.flatMap {
|
||||
|
@ -35,7 +35,7 @@ class SyncWorker @AssistedInject constructor(
|
||||
|
||||
override fun createWork(): Single<Result> {
|
||||
Timber.i("SyncWorker is starting")
|
||||
return studentRepository.isStudentSaved()
|
||||
return studentRepository.isCurrentStudentSet()
|
||||
.filter { true }
|
||||
.flatMap { studentRepository.getCurrentStudent().toMaybe() }
|
||||
.flatMapCompletable { student ->
|
||||
|
@ -100,8 +100,9 @@ class LuckyNumberWidgetProvider : BroadcastReceiver() {
|
||||
when {
|
||||
student != null -> Maybe.just(student)
|
||||
studentId != 0L -> {
|
||||
studentRepository.getCurrentStudent(false)
|
||||
.toMaybe()
|
||||
studentRepository.isCurrentStudentSet()
|
||||
.filter { true }
|
||||
.flatMap { studentRepository.getCurrentStudent(false).toMaybe() }
|
||||
.doOnSuccess { sharedPref.putLong(getStudentWidgetKey(appWidgetId), it.id) }
|
||||
}
|
||||
else -> Maybe.empty()
|
||||
|
@ -14,7 +14,7 @@ class SplashPresenter @Inject constructor(
|
||||
|
||||
override fun onAttachView(view: SplashView) {
|
||||
super.onAttachView(view)
|
||||
disposable.add(studentRepository.isStudentSaved()
|
||||
disposable.add(studentRepository.isCurrentStudentSet()
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({
|
||||
|
@ -161,8 +161,9 @@ class TimetableWidgetProvider : BroadcastReceiver() {
|
||||
when {
|
||||
student != null -> Maybe.just(student)
|
||||
studentId != 0L -> {
|
||||
studentRepository.getCurrentStudent(false)
|
||||
.toMaybe()
|
||||
studentRepository.isCurrentStudentSet()
|
||||
.filter { true }
|
||||
.flatMap { studentRepository.getCurrentStudent(false).toMaybe() }
|
||||
.doOnSuccess { sharedPref.putLong(getStudentWidgetKey(appWidgetId), it.id) }
|
||||
}
|
||||
else -> Maybe.empty()
|
||||
|
@ -32,14 +32,14 @@ class SplashPresenterTest {
|
||||
|
||||
@Test
|
||||
fun testOpenLoginView() {
|
||||
doReturn(Single.just(false)).`when`(studentRepository).isStudentSaved()
|
||||
doReturn(Single.just(false)).`when`(studentRepository).isCurrentStudentSet()
|
||||
presenter.onAttachView(splashView)
|
||||
verify(splashView).openLoginView()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMainMainView() {
|
||||
doReturn(Single.just(true)).`when`(studentRepository).isStudentSaved()
|
||||
doReturn(Single.just(true)).`when`(studentRepository).isCurrentStudentSet()
|
||||
presenter.onAttachView(splashView)
|
||||
verify(splashView).openMainView()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user