|
|
|
@ -14,8 +14,8 @@ import io.element.android.libraries.matrix.api.core.DeviceId
@@ -14,8 +14,8 @@ import io.element.android.libraries.matrix.api.core.DeviceId
|
|
|
|
|
import io.element.android.libraries.matrix.api.core.RoomId |
|
|
|
|
import io.element.android.libraries.matrix.api.core.SessionId |
|
|
|
|
import io.element.android.libraries.matrix.api.notificationsettings.NotificationSettingsService |
|
|
|
|
import io.element.android.libraries.matrix.api.room.InvitedRoom |
|
|
|
|
import io.element.android.libraries.matrix.api.room.MatrixRoom |
|
|
|
|
import io.element.android.libraries.matrix.api.room.PendingRoom |
|
|
|
|
import io.element.android.libraries.matrix.api.roomlist.RoomListService |
|
|
|
|
import io.element.android.libraries.matrix.api.roomlist.awaitLoaded |
|
|
|
|
import io.element.android.libraries.matrix.impl.roomlist.fullRoomWithTimeline |
|
|
|
@ -35,6 +35,7 @@ import timber.log.Timber
@@ -35,6 +35,7 @@ import timber.log.Timber
|
|
|
|
|
import org.matrix.rustcomponents.sdk.RoomListService as InnerRoomListService |
|
|
|
|
|
|
|
|
|
private const val CACHE_SIZE = 16 |
|
|
|
|
private val PENDING_MEMBERSHIPS = setOf(Membership.INVITED, Membership.KNOCKED) |
|
|
|
|
|
|
|
|
|
class RustRoomFactory( |
|
|
|
|
private val sessionId: SessionId, |
|
|
|
@ -49,6 +50,7 @@ class RustRoomFactory(
@@ -49,6 +50,7 @@ class RustRoomFactory(
|
|
|
|
|
private val roomSyncSubscriber: RoomSyncSubscriber, |
|
|
|
|
private val timelineEventTypeFilterFactory: TimelineEventTypeFilterFactory, |
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalCoroutinesApi::class) |
|
|
|
|
private val dispatcher = dispatchers.io.limitedParallelism(1) |
|
|
|
|
private val mutex = Mutex() |
|
|
|
@ -120,7 +122,7 @@ class RustRoomFactory(
@@ -120,7 +122,7 @@ class RustRoomFactory(
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
suspend fun createInvitedRoom(roomId: RoomId): InvitedRoom? = withContext(dispatcher) { |
|
|
|
|
suspend fun createPendingRoom(roomId: RoomId): PendingRoom? = withContext(dispatcher) { |
|
|
|
|
if (isDestroyed) { |
|
|
|
|
Timber.d("Room factory is destroyed, returning null for $roomId") |
|
|
|
|
return@withContext null |
|
|
|
@ -130,20 +132,19 @@ class RustRoomFactory(
@@ -130,20 +132,19 @@ class RustRoomFactory(
|
|
|
|
|
Timber.d("Room not found for $roomId") |
|
|
|
|
return@withContext null |
|
|
|
|
} |
|
|
|
|
if (roomListItem.membership() != Membership.INVITED) { |
|
|
|
|
Timber.d("Room $roomId is not in invited state") |
|
|
|
|
if (roomListItem.membership() !in PENDING_MEMBERSHIPS) { |
|
|
|
|
Timber.d("Room $roomId is not in pending state") |
|
|
|
|
return@withContext null |
|
|
|
|
} |
|
|
|
|
val invitedRoom = try { |
|
|
|
|
roomListItem.invitedRoom() |
|
|
|
|
val innerRoom = try { |
|
|
|
|
roomListItem.roomWithoutTimeline() |
|
|
|
|
} catch (e: RoomListException) { |
|
|
|
|
Timber.e(e, "Failed to get invited room for $roomId") |
|
|
|
|
Timber.e(e, "Failed to get pending room for $roomId") |
|
|
|
|
return@withContext null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RustInvitedRoom( |
|
|
|
|
RustPendingRoom( |
|
|
|
|
sessionId = sessionId, |
|
|
|
|
invitedRoom = invitedRoom, |
|
|
|
|
inner = innerRoom, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|