Commit 0a690861 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

up database version due subscriptions table changes

parent 3c99913b
...@@ -50,6 +50,7 @@ class AuthContractModule @Inject constructor( ...@@ -50,6 +50,7 @@ class AuthContractModule @Inject constructor(
override fun currentUser(): Observable<UserEntity> = override fun currentUser(): Observable<UserEntity> =
local.recentUser() local.recentUser()
.doOnNext { Timber.w("recentUSer: $it") }
.flatMap{ when(it){ .flatMap{ when(it){
is UserState.NotAuthenticated -> throw CustomApiException.NotAuthorizedException() is UserState.NotAuthenticated -> throw CustomApiException.NotAuthorizedException()
is UserState.Authenticated -> db.fetchUser(it.uuid.toInt()) is UserState.Authenticated -> db.fetchUser(it.uuid.toInt())
......
...@@ -21,7 +21,7 @@ const val ESTATES_CACHE_LIMIT_SECONDS_INACTIVE = 200L ...@@ -21,7 +21,7 @@ const val ESTATES_CACHE_LIMIT_SECONDS_INACTIVE = 200L
const val FILES_CACHE_LIMIT_SIZE = 10000 const val FILES_CACHE_LIMIT_SIZE = 10000
const val FILES_CACHE_LIMIT_SECONDS_INACTIVE = 60L const val FILES_CACHE_LIMIT_SECONDS_INACTIVE = 60L
const val DATABASE_VERSION = 11 const val DATABASE_VERSION = 12
@Module @Module
abstract class AppModule{ abstract class AppModule{
......
...@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.domain.model.SubscriptionTopic ...@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.domain.model.SubscriptionTopic
import com.biganto.visual.roompark.domain.model.fromEntity import com.biganto.visual.roompark.domain.model.fromEntity
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.rxkotlin.Observables import io.reactivex.rxkotlin.Observables
import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
//import io.reactivex.rxkotlin //import io.reactivex.rxkotlin
...@@ -47,6 +48,7 @@ class SubscriptionUseCase @Inject constructor( ...@@ -47,6 +48,7 @@ class SubscriptionUseCase @Inject constructor(
fun getSubscriptions(topic: SubscriptionTopic): Observable<SubscriptionModel> = fun getSubscriptions(topic: SubscriptionTopic): Observable<SubscriptionModel> =
auth.currentUser() auth.currentUser()
.map { .map {
Timber.w("user is : $it")
var sub = it.subscriptions var sub = it.subscriptions
?.firstOrNull { it.topic == topic.topicName && it.number == topic.topicId } ?.firstOrNull { it.topic == topic.topicName && it.number == topic.topicId }
if (sub == null) { if (sub == null) {
...@@ -56,6 +58,7 @@ class SubscriptionUseCase @Inject constructor( ...@@ -56,6 +58,7 @@ class SubscriptionUseCase @Inject constructor(
sub.setNumber(topic.topicId) sub.setNumber(topic.topicId)
sub.setState(false) sub.setState(false)
} }
Timber.w("sub is : $sub")
subscription.saveSubscribeState(sub as SubscriptionEntity).blockingFirst() subscription.saveSubscribeState(sub as SubscriptionEntity).blockingFirst()
} }
.map(::fromEntity) .map(::fromEntity)
......
...@@ -38,6 +38,7 @@ class ArticlesScreenPresenter @Inject constructor( ...@@ -38,6 +38,7 @@ class ArticlesScreenPresenter @Inject constructor(
Timber.d("feedId : $feedId") Timber.d("feedId : $feedId")
val onSubChecked = intent(ArticlesScreen::feedSubscription) val onSubChecked = intent(ArticlesScreen::feedSubscription)
.filter { restoreModel.sub!=null }
.flatMap { newState -> .flatMap { newState ->
interactor.switchSubscription(restoreModel.sub!!,newState) interactor.switchSubscription(restoreModel.sub!!,newState)
.andThen(Observable.just<ArticlesScreenViewState>(ArticlesScreenViewState.SubscriptionStatus(newState))) .andThen(Observable.just<ArticlesScreenViewState>(ArticlesScreenViewState.SubscriptionStatus(newState)))
...@@ -61,6 +62,7 @@ class ArticlesScreenPresenter @Inject constructor( ...@@ -61,6 +62,7 @@ class ArticlesScreenPresenter @Inject constructor(
.onErrorReturn(::parseError) .onErrorReturn(::parseError)
val fetchSubscription = interactor.getSubscriptions(feedId) val fetchSubscription = interactor.getSubscriptions(feedId)
.doOnNext { Timber.w("got smthng: $it") }
.doAfterNext { restoreModel.sub = it } .doAfterNext { restoreModel.sub = it }
.map<ArticlesScreenViewState> { ArticlesScreenViewState.SubscriptionStatus(it.state) } .map<ArticlesScreenViewState> { ArticlesScreenViewState.SubscriptionStatus(it.state) }
.startWith(Observable.just<ArticlesScreenViewState>(ArticlesScreenViewState.Idle())) .startWith(Observable.just<ArticlesScreenViewState>(ArticlesScreenViewState.Idle()))
......
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