From e3bf46377bb8c5573e3670bc2cbe5083b4febd1d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Apr 2026 02:53:53 +0000 Subject: [PATCH] fix(audio-rooms): unwrap hiddenUsers State for the feed key (audit walk #9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pre-existing bug surfaced during the user-walkthrough audit: WatchAccountForAudioRoomsScreen used `val hiddenUsers = hiddenUsers.flow.collectAsStateWithLifecycle()` (no `by`), so the LaunchedEffect captured a State object as a key rather than the unwrapped value. State equality is reference-based and the remembered State instance is stable across recompositions, so the effect never re-fired when the user muted someone — the rooms feed showed stale results until a manual refresh. Switching to `val hiddenUsers by ...` unwraps the value so LaunchedEffect re-keys when the hidden-users set changes. --- .../ui/screen/loggedIn/audiorooms/AudioRoomsScreen.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/audiorooms/AudioRoomsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/audiorooms/AudioRoomsScreen.kt index cb6414157..8f41daa61 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/audiorooms/AudioRoomsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/audiorooms/AudioRoomsScreen.kt @@ -133,9 +133,13 @@ fun WatchAccountForAudioRoomsScreen( accountViewModel: AccountViewModel, ) { val listState by accountViewModel.account.liveLiveStreamsFollowLists.collectAsStateWithLifecycle() - val hiddenUsers = - accountViewModel.account.hiddenUsers.flow - .collectAsStateWithLifecycle() + // Use `by` to unwrap the StateFlow's value into the LaunchedEffect + // key — without it, the State object is reference-stable across + // recompositions and the effect never re-fires when the user + // mutes someone, leaving the rooms feed stale until a manual + // refresh. + val hiddenUsers by accountViewModel.account.hiddenUsers.flow + .collectAsStateWithLifecycle() LaunchedEffect(accountViewModel, listState, hiddenUsers) { audioRoomsFeedState.checkKeysInvalidateDataAndSendToTop()