Remove 1-1 chat room creation fragment from back stack + update chat rooms list when enabling/disabling ephemeral

This commit is contained in:
Sylvain Berfini 2021-11-10 14:30:45 +01:00
parent 50370b78e0
commit dfa6175b71
3 changed files with 9 additions and 2 deletions

View file

@ -317,7 +317,7 @@ internal fun ChatRoomCreationFragment.navigateToChatRoom(args: Bundle) {
findNavController().navigate(
R.id.action_chatRoomCreationFragment_to_detailChatRoomFragment,
args,
popupTo(R.id.detailChatRoomFragment, true)
popupTo(R.id.chatRoomCreationFragment, true)
)
}
}

View file

@ -74,6 +74,8 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
val peerSipUri = MutableLiveData<String>()
val ephemeralEnabled = MutableLiveData<Boolean>()
val oneToOneChatRoom: Boolean = chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())
val encryptedChatRoom: Boolean = chatRoom.hasCapability(ChatRoomCapabilities.Encrypted.toInt())
@ -199,6 +201,10 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
lastMessageText.value = formatLastMessage(chatRoom.lastMessageInHistory)
}
override fun onEphemeralEvent(chatRoom: ChatRoom, eventLog: EventLog) {
ephemeralEnabled.value = chatRoom.ephemeralEnabled()
}
override fun onParticipantAdminStatusChanged(chatRoom: ChatRoom, eventLog: EventLog) {
meAdmin.value = chatRoom.me?.isAdmin ?: false
}
@ -216,6 +222,7 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
subject.value = chatRoom.subject
updateSecurityIcon()
meAdmin.value = chatRoom.me?.isAdmin ?: false
ephemeralEnabled.value = chatRoom.ephemeralEnabled()
contactLookup()
updateParticipants()

View file

@ -124,7 +124,7 @@
android:maxLines="2" />
<ImageView
android:visibility="@{viewModel.chatRoom.ephemeralEnabled() ? View.VISIBLE : View.GONE, default=gone}"
android:visibility="@{viewModel.ephemeralEnabled ? View.VISIBLE : View.GONE, default=gone}"
android:id="@+id/ephemeral"
android:contentDescription="@string/content_description_ephemeral_chat_room"
android:layout_width="20dp"