mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +03:00
commit
e0c2dc0b2f
3 changed files with 10 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
|||
Changes in Element v.5.16 (2022-12-29)
|
||||
Changes in Element v1.5.16 (2022-12-29)
|
||||
======================================
|
||||
|
||||
Features ✨
|
||||
|
|
1
changelog.d/7870.bugfix
Normal file
1
changelog.d/7870.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Start DM will create a deadlock if user profile was never loaded
|
|
@ -21,7 +21,7 @@ import io.realm.Realm
|
|||
import io.realm.RealmConfiguration
|
||||
import io.realm.kotlin.createObject
|
||||
import kotlinx.coroutines.TimeoutCancellationException
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
|
@ -73,8 +73,9 @@ internal class DefaultCreateLocalRoomTask @Inject constructor(
|
|||
override suspend fun execute(params: CreateRoomParams): String {
|
||||
val createRoomBody = createRoomBodyBuilder.build(params)
|
||||
val roomId = RoomLocalEcho.createLocalEchoId()
|
||||
val eventList = createLocalRoomStateEventsTask.execute(CreateLocalRoomStateEventsTask.Params(createRoomBody))
|
||||
monarchy.awaitTransaction { realm ->
|
||||
createLocalRoomEntity(realm, roomId, createRoomBody)
|
||||
createLocalRoomEntity(realm, roomId, eventList)
|
||||
createLocalRoomSummaryEntity(realm, roomId, params, createRoomBody)
|
||||
}
|
||||
|
||||
|
@ -96,10 +97,10 @@ internal class DefaultCreateLocalRoomTask @Inject constructor(
|
|||
* Create a local room entity from the given room creation params.
|
||||
* This will also generate and store in database the chunk and the events related to the room params in order to retrieve and display the local room.
|
||||
*/
|
||||
private fun createLocalRoomEntity(realm: Realm, roomId: String, createRoomBody: CreateRoomBody) {
|
||||
private fun createLocalRoomEntity(realm: Realm, roomId: String, localStateEventList: List<Event>) {
|
||||
RoomEntity.getOrCreate(realm, roomId).apply {
|
||||
membership = Membership.JOIN
|
||||
chunks.add(createLocalRoomChunk(realm, roomId, createRoomBody))
|
||||
chunks.add(createLocalRoomChunk(realm, roomId, localStateEventList))
|
||||
membersLoadStatus = RoomMembersLoadStatusType.LOADED
|
||||
}
|
||||
}
|
||||
|
@ -145,23 +146,19 @@ internal class DefaultCreateLocalRoomTask @Inject constructor(
|
|||
*
|
||||
* @param realm the current instance of realm
|
||||
* @param roomId the id of the local room
|
||||
* @param createRoomBody the room creation params
|
||||
* @param localStateEventList list of local state events for that room
|
||||
*
|
||||
* @return a chunk entity
|
||||
*/
|
||||
private fun createLocalRoomChunk(realm: Realm, roomId: String, createRoomBody: CreateRoomBody): ChunkEntity {
|
||||
private fun createLocalRoomChunk(realm: Realm, roomId: String, localStateEventList: List<Event>): ChunkEntity {
|
||||
val chunkEntity = realm.createObject<ChunkEntity>().apply {
|
||||
isLastBackward = true
|
||||
isLastForward = true
|
||||
}
|
||||
|
||||
// Can't suspend when using realm as it could jump thread
|
||||
val eventList = runBlocking {
|
||||
createLocalRoomStateEventsTask.execute(CreateLocalRoomStateEventsTask.Params(createRoomBody))
|
||||
}
|
||||
val roomMemberContentsByUser = HashMap<String, RoomMemberContent?>()
|
||||
|
||||
for (event in eventList) {
|
||||
for (event in localStateEventList) {
|
||||
if (event.eventId == null || event.senderId == null || event.type == null) {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue