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()}") 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) room = coreContext.core.createChatRoom(params, localAddress, participants)
if (encrypted) { if (room != null) {
room?.addListener(listener) if (encrypted) {
} else { val state = room.state
if (room != null) { if (state == ChatRoom.State.Created) {
chatRoomCreatedEvent.value = Event(room) 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 { } 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 waitForChatRoomCreation.value = false
} }
} else { } else {

View file

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