mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
retain conversation successfully
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
1ed89b2a53
commit
01b80a0753
@ -258,4 +258,7 @@ interface NcApiCoroutines {
|
||||
|
||||
@GET
|
||||
suspend fun getProfile(@Header("Authorization") authorization: String, @Url url: String): ProfileOverall
|
||||
|
||||
@DELETE
|
||||
suspend fun unbindRoom(@Header("Authorization") authorization: String, @Url url: String): GenericOverall
|
||||
}
|
||||
|
@ -1073,6 +1073,27 @@ class ChatActivity :
|
||||
binding.voiceRecordingLock.y -= y
|
||||
}
|
||||
|
||||
chatViewModel.unbindRoomResult.observe(this) { uiState ->
|
||||
when (uiState) {
|
||||
is ChatViewModel.UnbindRoomUiState.Success -> {
|
||||
binding.conversationDeleteNotice.visibility = View.GONE
|
||||
Snackbar.make(
|
||||
binding.root,
|
||||
context.getString(R.string.nc_room_retention),
|
||||
Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
is ChatViewModel.UnbindRoomUiState.Error -> {
|
||||
Snackbar.make(
|
||||
binding.root,
|
||||
context.getString(R.string.nc_common_error_sorry),
|
||||
Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
else -> { }
|
||||
}
|
||||
}
|
||||
|
||||
chatViewModel.outOfOfficeViewState.observe(this) { uiState ->
|
||||
when (uiState) {
|
||||
is ChatViewModel.OutOfOfficeUIState.Error -> {
|
||||
@ -1207,13 +1228,11 @@ class ChatActivity :
|
||||
}
|
||||
|
||||
binding.conversationDeleteNotice.findViewById<MaterialButton>(R.id.keep_button).setOnClickListener {
|
||||
|
||||
chatViewModel.unbindRoom(credentials!!, conversationUser?.baseUrl!!, currentConversation?.token!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun deleteConversationDialog(context: Context) {
|
||||
|
||||
val dialogBuilder = MaterialAlertDialogBuilder(context)
|
||||
.setIcon(
|
||||
viewThemeUtils.dialog
|
||||
@ -1236,7 +1255,6 @@ class ChatActivity :
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
||||
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
|
@ -76,4 +76,5 @@ interface ChatNetworkDataSource {
|
||||
limit: Int
|
||||
): List<ChatMessageJson>
|
||||
suspend fun getOpenGraph(credentials: String, baseUrl: String, extractedLinkToPreview: String): Reference?
|
||||
suspend fun unbindRoom(credentials: String, baseUrl: String, roomToken: String): GenericOverall
|
||||
}
|
||||
|
@ -217,4 +217,9 @@ class RetrofitChatNetwork(
|
||||
extractedLinkToPreview
|
||||
).blockingFirst().ocs?.data?.references?.entries?.iterator()?.next()?.value
|
||||
}
|
||||
|
||||
override suspend fun unbindRoom(credentials: String, baseUrl: String, roomToken: String): GenericOverall {
|
||||
val url = ApiUtils.getUrlForUnbindingRoom(baseUrl, roomToken)
|
||||
return ncApiCoroutines.unbindRoom(credentials, url)
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +146,10 @@ class ChatViewModel @Inject constructor(
|
||||
val outOfOfficeViewState: LiveData<OutOfOfficeUIState>
|
||||
get() = _outOfOfficeViewState
|
||||
|
||||
private val _unbindRoomResult = MutableLiveData<UnbindRoomUiState>(UnbindRoomUiState.None)
|
||||
val unbindRoomResult: LiveData<UnbindRoomUiState>
|
||||
get() = _unbindRoomResult
|
||||
|
||||
private val _voiceMessagePlaybackSpeedPreferences: MutableLiveData<Map<String, PlaybackSpeed>> = MutableLiveData()
|
||||
val voiceMessagePlaybackSpeedPreferences: LiveData<Map<String, PlaybackSpeed>>
|
||||
get() = _voiceMessagePlaybackSpeedPreferences
|
||||
@ -804,6 +808,17 @@ class ChatViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun unbindRoom(credentials: String, baseUrl: String, roomToken: String) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val response = chatNetworkDataSource.unbindRoom(credentials, baseUrl, roomToken)
|
||||
_unbindRoomResult.value = UnbindRoomUiState.Success(response.ocs?.meta?.statusCode!!)
|
||||
} catch (exception: Exception) {
|
||||
_unbindRoomResult.value = UnbindRoomUiState.Error(exception.message.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun resendMessage(credentials: String, urlForChat: String, message: ChatMessage) {
|
||||
viewModelScope.launch {
|
||||
chatRepository.resendChatMessage(
|
||||
@ -855,4 +870,10 @@ class ChatViewModel @Inject constructor(
|
||||
data class Success(val userAbsence: UserAbsenceData) : OutOfOfficeUIState()
|
||||
data class Error(val exception: Exception) : OutOfOfficeUIState()
|
||||
}
|
||||
|
||||
sealed class UnbindRoomUiState {
|
||||
data object None : UnbindRoomUiState()
|
||||
data class Success(val statusCode: Int) : UnbindRoomUiState()
|
||||
data class Error(val message: String) : UnbindRoomUiState()
|
||||
}
|
||||
}
|
||||
|
@ -449,6 +449,10 @@ object ApiUtils {
|
||||
return "$baseUrl$OCS_API_VERSION/cloud/users/search/by-phone"
|
||||
}
|
||||
|
||||
fun getUrlForUnbindingRoom(baseUrl: String, roomToken: String): String {
|
||||
return "$baseUrl/ocs/v2.php/apps/spreed/api/v4/room/$roomToken/object"
|
||||
}
|
||||
|
||||
fun getUrlForFileUpload(baseUrl: String, user: String, remotePath: String): String {
|
||||
return "$baseUrl/remote.php/dav/files/$user$remotePath"
|
||||
}
|
||||
|
@ -521,6 +521,7 @@ How to translate with transifex:
|
||||
leaked to other services</string>
|
||||
<string name="startCallForbidden">You are not allowed to start a call</string>
|
||||
<string name="nc_last_moderator_leaving_room_warning">You need to promote a new moderator before you can leave the conversation</string>
|
||||
<string name="nc_room_retention">Room was retained successfully</string>
|
||||
|
||||
<string name="share">Share</string>
|
||||
<string name="send_to">Send to</string>
|
||||
|
Loading…
Reference in New Issue
Block a user