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