Commit 1b404678 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fetch all subs

parent 99b3335f
...@@ -2,7 +2,11 @@ package com.biganto.visual.roompark.domain.interactor ...@@ -2,7 +2,11 @@ package com.biganto.visual.roompark.domain.interactor
import android.content.Context import android.content.Context
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.* import com.biganto.visual.roompark.data.repository.db.requrey.model.Subscription
import com.biganto.visual.roompark.domain.model.CachedDataModel
import com.biganto.visual.roompark.domain.model.PushSwitchModel
import com.biganto.visual.roompark.domain.model.SettingsModel
import com.biganto.visual.roompark.domain.model.SubscriptionModel
import com.biganto.visual.roompark.domain.use_case.AuthUseCase import com.biganto.visual.roompark.domain.use_case.AuthUseCase
import com.biganto.visual.roompark.domain.use_case.SettingsUseCase import com.biganto.visual.roompark.domain.use_case.SettingsUseCase
import com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase import com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
...@@ -23,8 +27,8 @@ class SettingsInteractor @Inject constructor( ...@@ -23,8 +27,8 @@ class SettingsInteractor @Inject constructor(
){ ){
fun getSubscriptions(topic: SubscriptionTopic) = fun getSubscriptions(): Observable<List<Subscription>?> =
subUc.getSubscriptions(topic) subUc.getCurrentUserSubscriptions()
fun switchSubscription(model: SubscriptionModel, newState: Boolean): Completable = fun switchSubscription(model: SubscriptionModel, newState: Boolean): Completable =
when(newState){ when(newState){
......
...@@ -58,6 +58,9 @@ class SubscriptionUseCase @Inject constructor( ...@@ -58,6 +58,9 @@ class SubscriptionUseCase @Inject constructor(
).subscribeOn(Schedulers.io()) ).subscribeOn(Schedulers.io())
} }
fun getCurrentUserSubscriptions() = auth.currentUser().map { it.subscriptions }
fun getSubscriptions(topic: SubscriptionTopic): Observable<SubscriptionModel> = fun getSubscriptions(topic: SubscriptionTopic): Observable<SubscriptionModel> =
auth.currentUser() auth.currentUser()
.map { .map {
......
...@@ -34,6 +34,15 @@ class SettingsScreenPresenter @Inject constructor( ...@@ -34,6 +34,15 @@ class SettingsScreenPresenter @Inject constructor(
.map { settings }} .map { settings }}
.map { SettingsScreenViewState.LoadSettingsList(it)} .map { SettingsScreenViewState.LoadSettingsList(it)}
val fetchCache = interactor.getCacheInfo()
.doOnNext { cached -> cached.sortBy { it.id } }
.map { SettingsScreenViewState.LoadCachInfo(it) }
val fetchSubscriptions = interactor.getSubscriptions()
.doOnNext { cached -> cached.sortBy { it.id } }
.map { SettingsScreenViewState.LoadCachInfo(it) }
val onSignOut = intent(SettingsScreen::signOut) val onSignOut = intent(SettingsScreen::signOut)
.flatMap { .flatMap {
......
package com.biganto.visual.roompark.presentation.screen.settings package com.biganto.visual.roompark.presentation.screen.settings
import com.biganto.visual.roompark.conductor.BigantoBaseViewState import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.CachedDataModel
import com.biganto.visual.roompark.domain.model.SettingsModel import com.biganto.visual.roompark.domain.model.SettingsModel
import com.biganto.visual.roompark.domain.model.SubscriptionModel
import com.biganto.visual.roompark.util.monades.ExceptionString import com.biganto.visual.roompark.util.monades.ExceptionString
/** /**
...@@ -16,4 +18,6 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() { ...@@ -16,4 +18,6 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() {
class SomeError(val exception: ExceptionString) : SettingsScreenViewState() class SomeError(val exception: ExceptionString) : SettingsScreenViewState()
class SignOut() : SettingsScreenViewState() class SignOut() : SettingsScreenViewState()
class OnCacheDeleting(val progress:Float) : SettingsScreenViewState() class OnCacheDeleting(val progress:Float) : SettingsScreenViewState()
} class LoadSubscriptions(val list:List<SubscriptionModel>) : SettingsScreenViewState()
\ No newline at end of file class LoadCachInfo(val list: List<CachedDataModel>)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment