Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-11-15 18:06:23 +01:00
parent 574791c1bc
commit a133c2a3b9
No known key found for this signature in database
GPG key ID: F7AA2A8B65B50220
3 changed files with 11 additions and 21 deletions

View file

@ -266,7 +266,6 @@ class ConversationInfoActivity :
Snackbar.make(binding.root, R.string.conversation_read_only_failed, Snackbar.LENGTH_LONG).show() Snackbar.make(binding.root, R.string.conversation_read_only_failed, Snackbar.LENGTH_LONG).show()
} }
is ConversationInfoViewModel.SetConversationReadOnlyViewState.None -> { is ConversationInfoViewModel.SetConversationReadOnlyViewState.None -> {
} }
} }
} }

View file

@ -15,8 +15,6 @@ import com.nextcloud.talk.chat.data.network.ChatNetworkDataSource
import com.nextcloud.talk.conversationinfoedit.data.ConversationInfoEditRepository import com.nextcloud.talk.conversationinfoedit.data.ConversationInfoEditRepository
import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.models.domain.ConversationModel import com.nextcloud.talk.models.domain.ConversationModel
import com.nextcloud.talk.models.json.generic.GenericMeta
import com.nextcloud.talk.repositories.conversations.ConversationsRepositoryImpl.Companion.STATUS_CODE_OK
import io.reactivex.Observer import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
@ -80,12 +78,8 @@ class ConversationInfoEditViewModel @Inject constructor(
fun renameRoom(roomToken: String, newRoomName: String) { fun renameRoom(roomToken: String, newRoomName: String) {
viewModelScope.launch { viewModelScope.launch {
try { try {
val renameRoomResult = conversationInfoEditRepository.renameConversation(roomToken, newRoomName) conversationInfoEditRepository.renameConversation(roomToken, newRoomName)
val statusCode: GenericMeta? = renameRoomResult.ocs?.meta _renameRoomUiState.value = RenameRoomUiState.Success
val result = statusCode?.statusCode == STATUS_CODE_OK
if (result) {
_renameRoomUiState.value = RenameRoomUiState.Success(result)
}
} catch (exception: Exception) { } catch (exception: Exception) {
_renameRoomUiState.value = RenameRoomUiState.Error(exception) _renameRoomUiState.value = RenameRoomUiState.Error(exception)
} }
@ -95,15 +89,12 @@ class ConversationInfoEditViewModel @Inject constructor(
fun setConversationDescription(roomToken: String, conversationDescription: String?) { fun setConversationDescription(roomToken: String, conversationDescription: String?) {
viewModelScope.launch { viewModelScope.launch {
try { try {
val setConversationDescriptionResult = conversationInfoEditRepository.setConversationDescription( conversationInfoEditRepository.setConversationDescription(
roomToken, roomToken,
conversationDescription conversationDescription
) )
val statusCode: GenericMeta? = setConversationDescriptionResult.ocs?.meta
val result = statusCode?.statusCode == STATUS_CODE_OK _setConversationDescriptionUiState.value = SetConversationDescriptionUiState.Success
if (result) {
_setConversationDescriptionUiState.value = SetConversationDescriptionUiState.Success(result)
}
} catch (exception: Exception) { } catch (exception: Exception) {
_setConversationDescriptionUiState.value = SetConversationDescriptionUiState.Error(exception) _setConversationDescriptionUiState.value = SetConversationDescriptionUiState.Error(exception)
} }
@ -173,13 +164,13 @@ class ConversationInfoEditViewModel @Inject constructor(
sealed class RenameRoomUiState { sealed class RenameRoomUiState {
data object None : RenameRoomUiState() data object None : RenameRoomUiState()
data class Success(val result: Boolean) : RenameRoomUiState() data object Success : RenameRoomUiState()
data class Error(val exception: Exception) : RenameRoomUiState() data class Error(val exception: Exception) : RenameRoomUiState()
} }
sealed class SetConversationDescriptionUiState { sealed class SetConversationDescriptionUiState {
data object None : SetConversationDescriptionUiState() data object None : SetConversationDescriptionUiState()
data class Success(val result: Boolean) : SetConversationDescriptionUiState() data object Success : SetConversationDescriptionUiState()
data class Error(val exception: Exception) : SetConversationDescriptionUiState() data class Error(val exception: Exception) : SetConversationDescriptionUiState()
} }
} }