From 30b71cf90b6937ecaa67163a95a51ff53e354afc Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 7 Oct 2026 10:40:54 +0200 Subject: [PATCH] Use derivedStateOf for selectedAccount too --- .../libraries/roomselect/impl/RoomSelectPresenter.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt index 8026dbdd6d..11e6c65415 100644 --- a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt +++ b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt @@ -72,8 +72,12 @@ class RoomSelectPresenter( list.map { it.toMatrixUser() } } }.collectAsState(initial = emptyList()) - // Fallback to a MatrixUser with only the userId until the sessions are loaded - val selectedAccount = accounts.find { it.userId == selectedSessionId } ?: MatrixUser(selectedSessionId) + val selectedAccount by remember { + derivedStateOf { + // Fallback to a MatrixUser with only the userId until the sessions are loaded + accounts.find { it.userId == selectedSessionId } ?: MatrixUser(selectedSessionId) + } + } val otherAccounts by remember { derivedStateOf { accounts.filter { it.userId != selectedSessionId }.toImmutableList()