Commit 09ccdde3 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

get feeds worklflow

parent 2ca86258
...@@ -13,6 +13,7 @@ import io.reactivex.Observable ...@@ -13,6 +13,7 @@ import io.reactivex.Observable
import io.reactivex.Single import io.reactivex.Single
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
import timber.log.Timber.e
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -31,6 +32,7 @@ class FeedsContractModule @Inject constructor( ...@@ -31,6 +32,7 @@ class FeedsContractModule @Inject constructor(
override fun fetchFeeds(): Observable<List<FeedModel>> = override fun fetchFeeds(): Observable<List<FeedModel>> =
fetchAllFeeds(session.token) fetchAllFeeds(session.token)
.doOnError (::e)
override fun fetchFeedObservable(id: Int): Observable<ArticlesPreviewModel> { override fun fetchFeedObservable(id: Int): Observable<ArticlesPreviewModel> {
......
...@@ -30,7 +30,7 @@ class DbModule{ ...@@ -30,7 +30,7 @@ class DbModule{
Timber.d("Kotlin store creating..") Timber.d("Kotlin store creating..")
val source = DatabaseSource(context, Models.DEFAULT, "BigantoPerfect", DATABASE_VERSION) val source = DatabaseSource(context, Models.DEFAULT, "BigantoPerfect", DATABASE_VERSION)
source.setLoggingEnabled(false) source.setLoggingEnabled(true)
val store = KotlinEntityDataStore<Persistable>(source.configuration) val store = KotlinEntityDataStore<Persistable>(source.configuration)
Timber.d("Kotlin store %s",source) Timber.d("Kotlin store %s",source)
......
...@@ -22,9 +22,9 @@ interface Article : Persistable { ...@@ -22,9 +22,9 @@ interface Article : Persistable {
val preview : String? val preview : String?
@get:Nullable @get:Nullable
val body : String? val body : String?
@get:ForeignKey(references = Feed::class, referencedColumn = "alias") // @get:ForeignKey(references = Feed::class, referencedColumn = "alias")
@get:ManyToOne @get:ManyToOne
val feed : Feed val feed : Feed?
@get:Convert(TitledPhotoListConverter::class) @get:Convert(TitledPhotoListConverter::class)
val photo : List<TitledPhoto>? val photo : List<TitledPhoto>?
} }
\ No newline at end of file
...@@ -13,9 +13,9 @@ interface Feed : Persistable { ...@@ -13,9 +13,9 @@ interface Feed : Persistable {
@get:Key @get:Key
val id: Int val id: Int
val title:String val title:String
@get:Key // @get:Key
val alias: String val alias: String
@get:OneToMany(mappedBy = "id") @get:JunctionTable(name= "FeedArticlesRule")
@get:Nullable @get:OneToMany( cascade = arrayOf(CascadeAction.DELETE))
val articles:Set<Article>? val articles:Set<Article>?
} }
\ No newline at end of file
...@@ -21,8 +21,7 @@ class UserSessionService @Inject constructor( ...@@ -21,8 +21,7 @@ class UserSessionService @Inject constructor(
private var _token:String? = null private var _token:String? = null
override val token = _token?: throw CustomApiException override val token = _token?: ""
.UnknownCustomApiException(-1, R.string.unauthorized_user_request)
val disposable = val disposable =
...@@ -51,9 +50,9 @@ class UserSessionService @Inject constructor( ...@@ -51,9 +50,9 @@ class UserSessionService @Inject constructor(
is UserState.Authenticated ->it.uuid is UserState.Authenticated ->it.uuid
is UserState.NotAuthenticated -> is UserState.NotAuthenticated ->
CustomApiException CustomApiException
.UnknownCustomApiException(-1, R.string.unauthorized_user_request) .UnknownCustomApiException(-1, R.string.unauthorized_user_request,null)
else -> CustomApiException else -> CustomApiException
.UnknownCustomApiException(-1, R.string.unauthorized_user_request) .UnknownCustomApiException(-1, R.string.unauthorized_user_request,null)
} }
} }
......
...@@ -128,14 +128,14 @@ sealed class CustomApiException(val code:Int,@StringRes val messageStringId: In ...@@ -128,14 +128,14 @@ sealed class CustomApiException(val code:Int,@StringRes val messageStringId: In
class TourByIdNotFoundException() : CustomApiException( class TourByIdNotFoundException() : CustomApiException(
CUSTOM_API_ERROR_RESPONSE_CODE_TOUR_NOT_FOUND CUSTOM_API_ERROR_RESPONSE_CODE_TOUR_NOT_FOUND
,messageStringId= CUSTOM_API_ERROR_RESPONSE_CODE_TOUR_NOT_FOUND_MESSAGE_ID) ,messageStringId= CUSTOM_API_ERROR_RESPONSE_CODE_TOUR_NOT_FOUND_MESSAGE_ID)
class UnknownCustomApiException(code: Int, @StringRes messageStringId: Int?) class UnknownCustomApiException(code: Int, @StringRes messageStringId: Int?, apiMessage:String?)
: CustomApiException(code,messageStringId,apiMessage) : CustomApiException(code,messageStringId,apiMessage)
} }
//as an agreement error message should be correct for user (and localized, if needed) on server-side //as an agreement error message should be correct for user (and localized, if needed) on server-side
fun parseException(err: ErrorRaw) = fun parseException(err: ErrorRaw) =
CustomApiException.UnknownCustomApiException(err.code, null) CustomApiException.UnknownCustomApiException(err.code, null, err.message)
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.domain.interactor ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.model.* import com.biganto.visual.roompark.domain.model.*
import com.biganto.visual.roompark.domain.use_case.FeedUseCase import com.biganto.visual.roompark.domain.use_case.FeedUseCase
import io.reactivex.Observable
import io.reactivex.Single import io.reactivex.Single
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
...@@ -14,10 +15,10 @@ class FeedsInteractor @Inject constructor( ...@@ -14,10 +15,10 @@ class FeedsInteractor @Inject constructor(
private val feedsUseCase:FeedUseCase private val feedsUseCase:FeedUseCase
) { ) {
fun fetchTopFeeds(): Single<FeedsHeaderModel> = fun fetchTopFeeds(): Observable<FeedsHeaderModel> =
feedsUseCase.getFeeds().map { feedsUseCase.getFeeds().map {
FeedsHeaderModel(it) FeedsHeaderModel(it)
}.single(FeedsHeaderModel(arrayListOf())) }
//Single.just(testFeeds) //Single.just(testFeeds)
fun fetchArticles(feedId: Int): Single<ArticlesPreviewModel> = Single.just( fun fetchArticles(feedId: Int): Single<ArticlesPreviewModel> = Single.just(
......
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