Commit 29c64683 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

switch to test user token for deals subs

set settings subs as unclickable (switch subs by click item)
fix minor issues
parent 66ac5bdb
...@@ -59,7 +59,11 @@ class SubscriptionRepository @Inject constructor( ...@@ -59,7 +59,11 @@ class SubscriptionRepository @Inject constructor(
deviceToken: String, deviceToken: String,
topic: String, topic: String,
topic_id: String? topic_id: String?
): Completable = api.subscribeTopic(deviceToken = deviceToken ,topicName = topic,userToken = user.authToken) ): Completable = api.subscribeTopic(
userToken = if (topic_id!=null) TEST_DEAL_TOKEN else user.authToken,
deviceToken = deviceToken
,topicName = topic
,topicId = topic_id)
.doOnNext { Timber.d("UUUUUUUU $it") } .doOnNext { Timber.d("UUUUUUUU $it") }
.flatMapCompletable { .flatMapCompletable {
if (it.status == SUBSCRIPTION_RESULT_STATUS){ if (it.status == SUBSCRIPTION_RESULT_STATUS){
...@@ -76,7 +80,11 @@ class SubscriptionRepository @Inject constructor( ...@@ -76,7 +80,11 @@ class SubscriptionRepository @Inject constructor(
topic: String, topic: String,
topic_id: String? topic_id: String?
): Completable = ): Completable =
api.unSuubscribeTopic(deviceToken = deviceToken ,topicName = topic,userToken = user.authToken) api.unSuubscribeTopic(
userToken = if (topic_id!=null) TEST_DEAL_TOKEN else user.authToken,
deviceToken = deviceToken
,topicName = topic
,topicId = topic_id)
.doOnNext { Timber.d("$it") } .doOnNext { Timber.d("$it") }
.flatMapCompletable { .flatMapCompletable {
if (it.status == SUBSCRIPTION_RESULT_STATUS){ if (it.status == SUBSCRIPTION_RESULT_STATUS){
......
...@@ -15,13 +15,15 @@ interface IRoomParkApi { ...@@ -15,13 +15,15 @@ interface IRoomParkApi {
fun subscribeTopic( fun subscribeTopic(
userToken: String, userToken: String,
deviceToken: String, deviceToken: String,
topicName: String topicName: String,
topicId:String?
): Observable<StatusResponse> ): Observable<StatusResponse>
fun unSuubscribeTopic( fun unSuubscribeTopic(
userToken: String, userToken: String,
deviceToken: String, deviceToken: String,
topicName: String topicName: String,
topicId:String?
): Observable<StatusResponse> ): Observable<StatusResponse>
fun getDeals(userToken: String): Observable<List<DealRaw>> fun getDeals(userToken: String): Observable<List<DealRaw>>
......
...@@ -48,6 +48,7 @@ interface IRoomParkMobileApi{ ...@@ -48,6 +48,7 @@ interface IRoomParkMobileApi{
const val UNSUBSCRIBE_METHOD="users.unsubscribe" const val UNSUBSCRIBE_METHOD="users.unsubscribe"
const val DEVICE_TOKEN_SUBSCRIBTION_PARAM="deviceToken" const val DEVICE_TOKEN_SUBSCRIBTION_PARAM="deviceToken"
const val TOPIC_SUBSCRIBTION_PARAM="topic" const val TOPIC_SUBSCRIBTION_PARAM="topic"
const val TOPIC_SUBSCRIBTION_TOPIC_ID_PARAM="estate_id"
val topicTypes = arrayOf( val topicTypes = arrayOf(
"deals", "deals",
"progress-1", "progress-1",
...@@ -149,7 +150,8 @@ interface IRoomParkMobileApi{ ...@@ -149,7 +150,8 @@ interface IRoomParkMobileApi{
@Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION, @Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION,
@Query(AUTH_TOKEN) token: String, @Query(AUTH_TOKEN) token: String,
@Field(DEVICE_TOKEN_SUBSCRIBTION_PARAM) deviceToken: String, @Field(DEVICE_TOKEN_SUBSCRIBTION_PARAM) deviceToken: String,
@Field(TOPIC_SUBSCRIBTION_PARAM) topic: String @Field(TOPIC_SUBSCRIBTION_PARAM) topic: String,
@Field(TOPIC_SUBSCRIBTION_TOPIC_ID_PARAM) estateId: String?
): Observable<Response<StatusResponse>> ): Observable<Response<StatusResponse>>
@POST("$API_URL${UNSUBSCRIBE_METHOD}$DELIMITER") @POST("$API_URL${UNSUBSCRIBE_METHOD}$DELIMITER")
...@@ -160,7 +162,8 @@ interface IRoomParkMobileApi{ ...@@ -160,7 +162,8 @@ interface IRoomParkMobileApi{
@Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION, @Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION,
@Query(AUTH_TOKEN) token: String, @Query(AUTH_TOKEN) token: String,
@Field(DEVICE_TOKEN_SUBSCRIBTION_PARAM) deviceToken: String, @Field(DEVICE_TOKEN_SUBSCRIBTION_PARAM) deviceToken: String,
@Field(TOPIC_SUBSCRIBTION_PARAM) topic: String @Field(TOPIC_SUBSCRIBTION_PARAM) topic: String,
@Field(TOPIC_SUBSCRIBTION_TOPIC_ID_PARAM) estateId: String?
): Observable<Response<StatusResponse>> ): Observable<Response<StatusResponse>>
@GET("$API_URL$DEALS_METHOD$DELIMITER") @GET("$API_URL$DEALS_METHOD$DELIMITER")
......
...@@ -35,18 +35,20 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi ...@@ -35,18 +35,20 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi
override fun subscribeTopic( override fun subscribeTopic(
userToken: String, userToken: String,
deviceToken: String, deviceToken: String,
topicName: String topicName: String,
topicId:String?
): Observable<StatusResponse> = ): Observable<StatusResponse> =
api.subscribe(token = userToken, deviceToken = deviceToken, topic = topicName) api.subscribe(token = userToken, deviceToken = deviceToken, topic = topicName,estateId = topicId)
.doOnError { Timber.w(" WTFF ???") } .doOnError { Timber.w(" WTFF ???") }
.compose(RetrofitResponseValidation()) .compose(RetrofitResponseValidation())
override fun unSuubscribeTopic( override fun unSuubscribeTopic(
userToken: String, userToken: String,
deviceToken: String, deviceToken: String,
topicName: String topicName: String,
topicId:String?
): Observable<StatusResponse> = ): Observable<StatusResponse> =
api.unsubscribe(token = userToken, deviceToken = deviceToken, topic = topicName) api.unsubscribe(token = userToken, deviceToken = deviceToken, topic = topicName,estateId = topicId)
.compose(RetrofitResponseValidation()) .compose(RetrofitResponseValidation())
......
...@@ -162,11 +162,13 @@ class ArticlesScreenController : ...@@ -162,11 +162,13 @@ class ArticlesScreenController :
} }
private fun render(viewState: ArticlesScreenViewState.SubscriptionStatus) { private fun render(viewState: ArticlesScreenViewState.SubscriptionStatus) {
val sw = toolBar.headerToolbar.findViewById<SwitchMaterial>(R.id.switch1) val sw = toolBar.headerToolbar.findViewById<SwitchMaterial>(R.id.switch1)
Timber.d("substatus: ${sw.isChecked} $silentCheck ${viewState.subState}")
if (sw.isChecked != viewState.subState) if (sw.isChecked != viewState.subState)
{ {
silentCheck = true silentCheck = true
sw.isChecked != sw.isChecked sw.isChecked = viewState.subState
} }
} }
......
...@@ -63,10 +63,12 @@ class SettingsScreenPresenter @Inject constructor( ...@@ -63,10 +63,12 @@ class SettingsScreenPresenter @Inject constructor(
} }
) )
.doOnError { Timber.e(it) }
.onErrorReturn { SettingsScreenViewState.SubscriptionError(sub.id, sub.state) } .onErrorReturn { SettingsScreenViewState.SubscriptionError(sub.id, sub.state) }
} }
val fetchSettings = interactor.fetchSettings() val fetchSettings = interactor.fetchSettings()
.doOnNext { restoreModel.offlineStoreData = it.offlineStoreData.toMutableList() }
.map { SettingsScreenViewState.LoadSettingsList(it) } .map { SettingsScreenViewState.LoadSettingsList(it) }
val fetchCache = interactor.getCacheInfo() val fetchCache = interactor.getCacheInfo()
...@@ -75,6 +77,7 @@ class SettingsScreenPresenter @Inject constructor( ...@@ -75,6 +77,7 @@ class SettingsScreenPresenter @Inject constructor(
.map { SettingsScreenViewState.LoadCachInfo(it) } .map { SettingsScreenViewState.LoadCachInfo(it) }
val fetchSubscriptions = interactor.getSubscriptions() val fetchSubscriptions = interactor.getSubscriptions()
.doOnNext { restoreModel.subs = it.toMutableList() }
.map { SettingsScreenViewState.LoadSubscriptions(it) } .map { SettingsScreenViewState.LoadSubscriptions(it) }
val onSignOut = intent(SettingsScreen::signOut) val onSignOut = intent(SettingsScreen::signOut)
......
...@@ -123,6 +123,8 @@ class PushViewHolder(itemView: View) : CommonViewHolder<TitledSubscriptionModel> ...@@ -123,6 +123,8 @@ class PushViewHolder(itemView: View) : CommonViewHolder<TitledSubscriptionModel>
override fun onViewBound(model: TitledSubscriptionModel) { override fun onViewBound(model: TitledSubscriptionModel) {
Timber.d("model is : $model") Timber.d("model is : $model")
bellTitle.text = model.title bellTitle.text = model.title
switcher.findViewById<SwitchMaterial>(R.id.switch1).isFocusable = false
switcher.findViewById<SwitchMaterial>(R.id.switch1).isClickable = false
switcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked = model.subModel.state switcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked = model.subModel.state
} }
} }
......
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