Fixed chat room UI not updated when kicked/invited back while in it
This commit is contained in:
parent
eecbfccc2c
commit
7219cfbdf7
1 changed files with 11 additions and 0 deletions
|
@ -107,9 +107,19 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
|
||||||
stopVoiceRecordPlayer()
|
stopVoiceRecordPlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val chatRoomListener: ChatRoomListenerStub = object : ChatRoomListenerStub() {
|
||||||
|
override fun onStateChanged(chatRoom: ChatRoom, state: ChatRoom.State) {
|
||||||
|
if (state == ChatRoom.State.Created || state == ChatRoom.State.Terminated) {
|
||||||
|
isReadOnly.value = chatRoom.hasBeenLeft()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
chatRoom.addListener(chatRoomListener)
|
||||||
|
|
||||||
attachments.value = arrayListOf()
|
attachments.value = arrayListOf()
|
||||||
|
|
||||||
attachFileEnabled.value = true
|
attachFileEnabled.value = true
|
||||||
|
@ -138,6 +148,7 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
|
||||||
voiceRecordingPlayer.removeListener(playerListener)
|
voiceRecordingPlayer.removeListener(playerListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chatRoom.removeListener(chatRoomListener)
|
||||||
scope.cancel()
|
scope.cancel()
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue