Update dependency org.matrix.rustcomponents:sdk-android to v0.2.33 (#3220)
* Update dependency org.matrix.rustcomponents:sdk-android to v0.2.33 * Fix API breaks --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jorge Martín <jorgem@element.io>
This commit is contained in:
parent
30154783e8
commit
8a2335f7aa
6 changed files with 12 additions and 47 deletions
|
|
@ -104,11 +104,6 @@ class JoinedRoomLoadedFlowNode @AssistedInject constructor(
|
||||||
inputs.room.subscribeToSync()
|
inputs.room.subscribeToSync()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPause = {
|
|
||||||
appCoroutineScope.launch {
|
|
||||||
inputs.room.unsubscribeFromSync()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onDestroy = {
|
onDestroy = {
|
||||||
Timber.v("OnDestroy")
|
Timber.v("OnDestroy")
|
||||||
appNavigationStateService.onLeavingRoom(id)
|
appNavigationStateService.onLeavingRoom(id)
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ jsoup = "org.jsoup:jsoup:1.18.1"
|
||||||
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
||||||
molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0"
|
molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0"
|
||||||
timber = "com.jakewharton.timber:timber:5.0.1"
|
timber = "com.jakewharton.timber:timber:5.0.1"
|
||||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.32"
|
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.33"
|
||||||
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
|
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
|
||||||
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
|
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
|
||||||
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,6 @@ interface MatrixRoom : Closeable {
|
||||||
|
|
||||||
suspend fun subscribeToSync()
|
suspend fun subscribeToSync()
|
||||||
|
|
||||||
suspend fun unsubscribeFromSync()
|
|
||||||
|
|
||||||
suspend fun powerLevels(): Result<MatrixRoomPowerLevels>
|
suspend fun powerLevels(): Result<MatrixRoomPowerLevels>
|
||||||
|
|
||||||
suspend fun updatePowerLevels(matrixRoomPowerLevels: MatrixRoomPowerLevels): Result<Unit>
|
suspend fun updatePowerLevels(matrixRoomPowerLevels: MatrixRoomPowerLevels): Result<Unit>
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class RoomSyncSubscriber(
|
||||||
private val roomListService: RoomListServiceInterface,
|
private val roomListService: RoomListServiceInterface,
|
||||||
private val dispatchers: CoroutineDispatchers,
|
private val dispatchers: CoroutineDispatchers,
|
||||||
) {
|
) {
|
||||||
private val subscriptionCounts = HashMap<RoomId, Int>()
|
private val subscribedRoomIds = mutableSetOf<RoomId>()
|
||||||
private val mutex = Mutex()
|
private val mutex = Mutex()
|
||||||
|
|
||||||
private val settings = RoomSubscription(
|
private val settings = RoomSubscription(
|
||||||
|
|
@ -54,14 +54,7 @@ class RoomSyncSubscriber(
|
||||||
suspend fun subscribe(roomId: RoomId) = mutex.withLock {
|
suspend fun subscribe(roomId: RoomId) = mutex.withLock {
|
||||||
withContext(dispatchers.io) {
|
withContext(dispatchers.io) {
|
||||||
try {
|
try {
|
||||||
val currentSubscription = subscriptionCounts.getOrElse(roomId) { 0 }
|
subscribeToRoom(roomId)
|
||||||
if (currentSubscription == 0) {
|
|
||||||
Timber.d("Subscribing to room $roomId}")
|
|
||||||
roomListService.room(roomId.value).use { roomListItem ->
|
|
||||||
roomListItem.subscribe(settings)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
subscriptionCounts[roomId] = currentSubscription + 1
|
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Timber.e("Failed to subscribe to room $roomId")
|
Timber.e("Failed to subscribe to room $roomId")
|
||||||
}
|
}
|
||||||
|
|
@ -72,14 +65,7 @@ class RoomSyncSubscriber(
|
||||||
withContext(dispatchers.io) {
|
withContext(dispatchers.io) {
|
||||||
for (roomId in roomIds) {
|
for (roomId in roomIds) {
|
||||||
try {
|
try {
|
||||||
val currentSubscription = subscriptionCounts.getOrElse(roomId) { 0 }
|
subscribeToRoom(roomId)
|
||||||
if (currentSubscription == 0) {
|
|
||||||
Timber.d("Subscribing to room $roomId}")
|
|
||||||
roomListService.room(roomId.value).use { roomListItem ->
|
|
||||||
roomListItem.subscribe(settings)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
subscriptionCounts[roomId] = currentSubscription + 1
|
|
||||||
} catch (cancellationException: CancellationException) {
|
} catch (cancellationException: CancellationException) {
|
||||||
throw cancellationException
|
throw cancellationException
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
|
|
@ -89,28 +75,17 @@ class RoomSyncSubscriber(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun unsubscribe(roomId: RoomId) = mutex.withLock {
|
private fun subscribeToRoom(roomId: RoomId) {
|
||||||
withContext(dispatchers.io) {
|
if (!isSubscribedTo(roomId)) {
|
||||||
try {
|
Timber.d("Subscribing to room $roomId}")
|
||||||
val currentSubscription = subscriptionCounts.getOrElse(roomId) { 0 }
|
roomListService.room(roomId.value).use { roomListItem ->
|
||||||
when (currentSubscription) {
|
roomListItem.subscribe(settings)
|
||||||
0 -> return@withContext
|
|
||||||
1 -> {
|
|
||||||
Timber.d("Unsubscribe from room $roomId")
|
|
||||||
roomListService.room(roomId.value).use { roomListItem ->
|
|
||||||
roomListItem.unsubscribe()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
subscriptionCounts[roomId] = currentSubscription - 1
|
|
||||||
} catch (exception: Exception) {
|
|
||||||
Timber.e("Failed to unsubscribe from room $roomId")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
subscribedRoomIds.add(roomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isSubscribedTo(roomId: RoomId): Boolean {
|
fun isSubscribedTo(roomId: RoomId): Boolean {
|
||||||
val subscriptionCount = subscriptionCounts[roomId] ?: return false
|
return subscribedRoomIds.contains(roomId)
|
||||||
return subscriptionCount > 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,8 +173,6 @@ class RustMatrixRoom(
|
||||||
|
|
||||||
override suspend fun subscribeToSync() = roomSyncSubscriber.subscribe(roomId)
|
override suspend fun subscribeToSync() = roomSyncSubscriber.subscribe(roomId)
|
||||||
|
|
||||||
override suspend fun unsubscribeFromSync() = roomSyncSubscriber.unsubscribe(roomId)
|
|
||||||
|
|
||||||
override suspend fun timelineFocusedOnEvent(eventId: EventId): Result<Timeline> {
|
override suspend fun timelineFocusedOnEvent(eventId: EventId): Result<Timeline> {
|
||||||
return runCatching {
|
return runCatching {
|
||||||
innerRoom.timelineFocusedOnEvent(
|
innerRoom.timelineFocusedOnEvent(
|
||||||
|
|
@ -582,7 +580,7 @@ class RustMatrixRoom(
|
||||||
room = innerRoom,
|
room = innerRoom,
|
||||||
widgetCapabilitiesProvider = object : WidgetCapabilitiesProvider {
|
widgetCapabilitiesProvider = object : WidgetCapabilitiesProvider {
|
||||||
override fun acquireCapabilities(capabilities: WidgetCapabilities): WidgetCapabilities {
|
override fun acquireCapabilities(capabilities: WidgetCapabilities): WidgetCapabilities {
|
||||||
return getElementCallRequiredPermissions(sessionId.value)
|
return getElementCallRequiredPermissions(sessionId.value, sessionData.deviceId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,6 @@ class FakeMatrixRoom(
|
||||||
|
|
||||||
override suspend fun subscribeToSync() = Unit
|
override suspend fun subscribeToSync() = Unit
|
||||||
|
|
||||||
override suspend fun unsubscribeFromSync() = Unit
|
|
||||||
override suspend fun powerLevels(): Result<MatrixRoomPowerLevels> {
|
override suspend fun powerLevels(): Result<MatrixRoomPowerLevels> {
|
||||||
return powerLevelsResult
|
return powerLevelsResult
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue