forked from github/wulkanowy-mirror
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/caches/
|
||||||
- $HOME/.gradle/wrapper/
|
- $HOME/.gradle/wrapper/
|
||||||
|
|
||||||
#branches:
|
branches:
|
||||||
# only:
|
only:
|
||||||
# - master
|
- master
|
||||||
# - 0.8.x
|
- 0.8.x
|
||||||
|
|
||||||
android:
|
android:
|
||||||
licenses:
|
licenses:
|
||||||
|
@ -22,6 +22,8 @@ class StudentRepository @Inject constructor(
|
|||||||
|
|
||||||
fun isStudentSaved(): Single<Boolean> = local.getStudents(false).isEmpty.map { !it }
|
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>> {
|
fun getStudents(email: String, password: String, endpoint: String, symbol: String = ""): Single<List<Student>> {
|
||||||
return ReactiveNetwork.checkInternetConnectivity(settings)
|
return ReactiveNetwork.checkInternetConnectivity(settings)
|
||||||
.flatMap {
|
.flatMap {
|
||||||
|
@ -35,7 +35,7 @@ class SyncWorker @AssistedInject constructor(
|
|||||||
|
|
||||||
override fun createWork(): Single<Result> {
|
override fun createWork(): Single<Result> {
|
||||||
Timber.i("SyncWorker is starting")
|
Timber.i("SyncWorker is starting")
|
||||||
return studentRepository.isStudentSaved()
|
return studentRepository.isCurrentStudentSet()
|
||||||
.filter { true }
|
.filter { true }
|
||||||
.flatMap { studentRepository.getCurrentStudent().toMaybe() }
|
.flatMap { studentRepository.getCurrentStudent().toMaybe() }
|
||||||
.flatMapCompletable { student ->
|
.flatMapCompletable { student ->
|
||||||
|
@ -100,8 +100,9 @@ class LuckyNumberWidgetProvider : BroadcastReceiver() {
|
|||||||
when {
|
when {
|
||||||
student != null -> Maybe.just(student)
|
student != null -> Maybe.just(student)
|
||||||
studentId != 0L -> {
|
studentId != 0L -> {
|
||||||
studentRepository.getCurrentStudent(false)
|
studentRepository.isCurrentStudentSet()
|
||||||
.toMaybe()
|
.filter { true }
|
||||||
|
.flatMap { studentRepository.getCurrentStudent(false).toMaybe() }
|
||||||
.doOnSuccess { sharedPref.putLong(getStudentWidgetKey(appWidgetId), it.id) }
|
.doOnSuccess { sharedPref.putLong(getStudentWidgetKey(appWidgetId), it.id) }
|
||||||
}
|
}
|
||||||
else -> Maybe.empty()
|
else -> Maybe.empty()
|
||||||
|
@ -14,7 +14,7 @@ class SplashPresenter @Inject constructor(
|
|||||||
|
|
||||||
override fun onAttachView(view: SplashView) {
|
override fun onAttachView(view: SplashView) {
|
||||||
super.onAttachView(view)
|
super.onAttachView(view)
|
||||||
disposable.add(studentRepository.isStudentSaved()
|
disposable.add(studentRepository.isCurrentStudentSet()
|
||||||
.subscribeOn(schedulers.backgroundThread)
|
.subscribeOn(schedulers.backgroundThread)
|
||||||
.observeOn(schedulers.mainThread)
|
.observeOn(schedulers.mainThread)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
|
@ -161,8 +161,9 @@ class TimetableWidgetProvider : BroadcastReceiver() {
|
|||||||
when {
|
when {
|
||||||
student != null -> Maybe.just(student)
|
student != null -> Maybe.just(student)
|
||||||
studentId != 0L -> {
|
studentId != 0L -> {
|
||||||
studentRepository.getCurrentStudent(false)
|
studentRepository.isCurrentStudentSet()
|
||||||
.toMaybe()
|
.filter { true }
|
||||||
|
.flatMap { studentRepository.getCurrentStudent(false).toMaybe() }
|
||||||
.doOnSuccess { sharedPref.putLong(getStudentWidgetKey(appWidgetId), it.id) }
|
.doOnSuccess { sharedPref.putLong(getStudentWidgetKey(appWidgetId), it.id) }
|
||||||
}
|
}
|
||||||
else -> Maybe.empty()
|
else -> Maybe.empty()
|
||||||
|
@ -32,14 +32,14 @@ class SplashPresenterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testOpenLoginView() {
|
fun testOpenLoginView() {
|
||||||
doReturn(Single.just(false)).`when`(studentRepository).isStudentSaved()
|
doReturn(Single.just(false)).`when`(studentRepository).isCurrentStudentSet()
|
||||||
presenter.onAttachView(splashView)
|
presenter.onAttachView(splashView)
|
||||||
verify(splashView).openLoginView()
|
verify(splashView).openLoginView()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testMainMainView() {
|
fun testMainMainView() {
|
||||||
doReturn(Single.just(true)).`when`(studentRepository).isStudentSaved()
|
doReturn(Single.just(true)).`when`(studentRepository).isCurrentStudentSet()
|
||||||
presenter.onAttachView(splashView)
|
presenter.onAttachView(splashView)
|
||||||
verify(splashView).openMainView()
|
verify(splashView).openMainView()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user