Fixed issue when trying to create a One to One encrypted chat room that already exists

This commit is contained in:
Sylvain Berfini 2022-05-30 09:33:34 +02:00
parent 61bfb1fcff
commit 8515e2fcaf
2 changed files with 16 additions and 7 deletions

View file

@ -108,14 +108,23 @@ class ChatRoomCreationViewModel : ContactsSelectionViewModel() {
Log.w("[Chat Room Creation] Couldn't find existing 1-1 chat room with remote ${address.asStringUriOnly()}, encryption=$encrypted and local identity ${localAddress?.asStringUriOnly()}")
room = coreContext.core.createChatRoom(params, localAddress, participants)
if (encrypted) {
room?.addListener(listener)
} else {
if (room != null) {
chatRoomCreatedEvent.value = Event(room)
if (room != null) {
if (encrypted) {
val state = room.state
if (state == ChatRoom.State.Created) {
Log.i("[Chat Room Creation] Found already created chat room, using it")
chatRoomCreatedEvent.value = Event(room)
waitForChatRoomCreation.value = false
} else {
Log.i("[Chat Room Creation] Chat room creation is pending [$state], waiting for Created state")
room.addListener(listener)
}
} else {
Log.e("[Chat Room Creation] Couldn't create chat room with remote ${address.asStringUriOnly()} and local identity ${localAddress?.asStringUriOnly()}")
chatRoomCreatedEvent.value = Event(room)
waitForChatRoomCreation.value = false
}
} else {
Log.e("[Chat Room Creation] Couldn't create chat room with remote ${address.asStringUriOnly()} and local identity ${localAddress?.asStringUriOnly()}")
waitForChatRoomCreation.value = false
}
} else {

View file

@ -116,7 +116,7 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
private val contactsUpdatedListener = object : ContactsUpdatedListenerStub() {
override fun onContactsUpdated() {
Log.i("[Chat Room] Contacts have changed")
Log.d("[Chat Room] Contacts have changed")
contactLookup()
updateLastMessageToDisplay()
}