mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-19 10:45:13 +01:00
convert rxjava to coroutine - unfavourite conversation
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
e9d2a866a7
commit
9ba07f575f
@ -125,6 +125,12 @@ interface NcApiCoroutines {
|
|||||||
@Url url: String
|
@Url url: String
|
||||||
): GenericOverall
|
): GenericOverall
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
suspend fun removeConversationFromFavorites(
|
||||||
|
@Header("Authorization") authorization: String,
|
||||||
|
@Url url: String
|
||||||
|
): GenericOverall
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
suspend fun setReadStatusPrivacy(
|
suspend fun setReadStatusPrivacy(
|
||||||
@Header("Authorization") authorization: String,
|
@Header("Authorization") authorization: String,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.nextcloud.talk.ui.dialog
|
package com.nextcloud.talk.ui.dialog
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
@ -201,6 +202,7 @@ class ConversationsListBottomDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("StringFormatInvalid")
|
||||||
private fun addConversationToFavorites() {
|
private fun addConversationToFavorites() {
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
|
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
|
||||||
val url = ApiUtils.getUrlForRoomFavorite(apiVersion, currentUser.baseUrl!!, conversation.token)
|
val url = ApiUtils.getUrlForRoomFavorite(apiVersion, currentUser.baseUrl!!, conversation.token)
|
||||||
@ -226,44 +228,30 @@ class ConversationsListBottomDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("StringFormatInvalid")
|
||||||
private fun removeConversationFromFavorites() {
|
private fun removeConversationFromFavorites() {
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
|
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
|
||||||
ncApi.removeConversationFromFavorites(
|
val url = ApiUtils.getUrlForRoomFavorite(apiVersion, currentUser.baseUrl!!, conversation.token)
|
||||||
credentials,
|
lifecycleScope.launch {
|
||||||
ApiUtils.getUrlForRoomFavorite(
|
try {
|
||||||
apiVersion,
|
withContext(Dispatchers.IO) {
|
||||||
currentUser.baseUrl!!,
|
ncApiCoroutines.removeConversationFromFavorites(credentials, url)
|
||||||
conversation.token
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.retry(1)
|
|
||||||
.subscribe(object : Observer<GenericOverall> {
|
|
||||||
override fun onSubscribe(d: Disposable) {
|
|
||||||
// unused atm
|
|
||||||
}
|
}
|
||||||
|
activity.fetchRooms()
|
||||||
override fun onNext(genericOverall: GenericOverall) {
|
activity.showSnackbar(
|
||||||
activity.fetchRooms()
|
String.format(
|
||||||
activity.showSnackbar(
|
context.resources.getString(R.string.removed_from_favorites),
|
||||||
String.format(
|
conversation.displayName
|
||||||
context.resources.getString(R.string.removed_from_favorites),
|
|
||||||
conversation.displayName
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
dismiss()
|
)
|
||||||
}
|
dismiss()
|
||||||
|
} catch (e: Exception) {
|
||||||
override fun onError(e: Throwable) {
|
withContext(Dispatchers.Main) {
|
||||||
activity.showSnackbar(context.resources.getString(R.string.nc_common_error_sorry))
|
activity.showSnackbar(context.resources.getString(R.string.nc_common_error_sorry))
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
override fun onComplete() {
|
}
|
||||||
// unused atm
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun markConversationAsUnread() {
|
private fun markConversationAsUnread() {
|
||||||
@ -283,6 +271,7 @@ class ConversationsListBottomDialog(
|
|||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("StringFormatInvalid")
|
||||||
override fun onNext(genericOverall: GenericOverall) {
|
override fun onNext(genericOverall: GenericOverall) {
|
||||||
activity.fetchRooms()
|
activity.fetchRooms()
|
||||||
activity.showSnackbar(
|
activity.showSnackbar(
|
||||||
@ -329,6 +318,7 @@ class ConversationsListBottomDialog(
|
|||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("StringFormatInvalid")
|
||||||
override fun onNext(genericOverall: GenericOverall) {
|
override fun onNext(genericOverall: GenericOverall) {
|
||||||
activity.fetchRooms()
|
activity.fetchRooms()
|
||||||
activity.showSnackbar(
|
activity.showSnackbar(
|
||||||
@ -365,6 +355,7 @@ class ConversationsListBottomDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("StringFormatInvalid")
|
||||||
private fun leaveConversation() {
|
private fun leaveConversation() {
|
||||||
val dataBuilder = Data.Builder()
|
val dataBuilder = Data.Builder()
|
||||||
dataBuilder.putString(KEY_ROOM_TOKEN, conversation.token)
|
dataBuilder.putString(KEY_ROOM_TOKEN, conversation.token)
|
||||||
|
Loading…
Reference in New Issue
Block a user