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
import android.content.Context
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.SettingsUseCase
import com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
......@@ -23,8 +27,8 @@ class SettingsInteractor @Inject constructor(
){
fun getSubscriptions(topic: SubscriptionTopic) =
subUc.getSubscriptions(topic)
fun getSubscriptions(): Observable<List<Subscription>?> =
subUc.getCurrentUserSubscriptions()
fun switchSubscription(model: SubscriptionModel, newState: Boolean): Completable =
when(newState){
......
......@@ -58,6 +58,9 @@ class SubscriptionUseCase @Inject constructor(
).subscribeOn(Schedulers.io())
}
fun getCurrentUserSubscriptions() = auth.currentUser().map { it.subscriptions }
fun getSubscriptions(topic: SubscriptionTopic): Observable<SubscriptionModel> =
auth.currentUser()
.map {
......
......@@ -34,6 +34,15 @@ class SettingsScreenPresenter @Inject constructor(
.map { settings }}
.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)
.flatMap {
......
package com.biganto.visual.roompark.presentation.screen.settings
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.SubscriptionModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/**
......@@ -16,4 +18,6 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() {
class SomeError(val exception: ExceptionString) : SettingsScreenViewState()
class SignOut() : SettingsScreenViewState()
class OnCacheDeleting(val progress:Float) : SettingsScreenViewState()
}
\ No newline at end of file
class LoadSubscriptions(val list:List<SubscriptionModel>) : SettingsScreenViewState()
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