From d2da136d3b4d7db436535d56c0c9561b88910143 Mon Sep 17 00:00:00 2001 From: Torsten Grote <t@grobox.de> Date: Mon, 17 Jul 2023 14:32:32 -0300 Subject: [PATCH] Let unread FABs info depend on (unread) posts Otherwise the FABs may not always recompose when the posts state changes. --- .../kotlin/org/briarproject/briar/desktop/blog/FeedScreen.kt | 2 +- .../briar/desktop/threadedgroup/conversation/UnreadFabs.kt | 2 +- .../kotlin/org/briarproject/briar/desktop/ui/UnreadFabs.kt | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/blog/FeedScreen.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/blog/FeedScreen.kt index 30c041d3a6..049d725120 100644 --- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/blog/FeedScreen.kt +++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/blog/FeedScreen.kt @@ -106,7 +106,7 @@ fun FeedScreen( ) } } - UnreadFabs(scrollState, unreadFabsInfo) + UnreadFabs(scrollState, unreadFabsInfo, posts) VerticalScrollbar( adapter = rememberScrollbarAdapter(scrollState), modifier = Modifier.align(CenterEnd).fillMaxHeight() diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/threadedgroup/conversation/UnreadFabs.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/threadedgroup/conversation/UnreadFabs.kt index f3a6a70b71..85c7e0ad33 100644 --- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/threadedgroup/conversation/UnreadFabs.kt +++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/threadedgroup/conversation/UnreadFabs.kt @@ -26,5 +26,5 @@ import org.briarproject.briar.desktop.ui.UnreadFabs @Composable fun BoxScope.UnreadFabs(strings: ThreadedGroupStrings, scrollState: LazyListState, postsState: Loaded) { - UnreadFabs(scrollState, postsState, strings.unreadJumpToPrevious, strings.unreadJumpToNext) + UnreadFabs(scrollState, postsState, postsState, strings.unreadJumpToPrevious, strings.unreadJumpToNext) } diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/ui/UnreadFabs.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/ui/UnreadFabs.kt index 34a47a456b..1536048ee0 100644 --- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/ui/UnreadFabs.kt +++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/ui/UnreadFabs.kt @@ -60,6 +60,7 @@ class UnreadPostInfo( fun BoxScope.UnreadFabs( scrollState: LazyListState, unreadFabsInfo: UnreadFabsInfo, + changeKey: Any, contentDescriptionUp: String = i18n("access.forums.jump_to_prev_unread"), contentDescriptionDown: String = i18n("access.forums.jump_to_next_unread"), ) { @@ -70,7 +71,7 @@ fun BoxScope.UnreadFabs( scrollState.firstReallyVisibleItemIndex } // remember unread info to avoid unnecessary re-computations - val unreadInfo = remember(unreadFabsInfo, firstReallyVisibleItemIndex) { + val unreadInfo = remember(changeKey, firstReallyVisibleItemIndex) { unreadFabsInfo.unreadBeforeIndex(firstReallyVisibleItemIndex) } AnimatedVisibility( @@ -99,7 +100,7 @@ fun BoxScope.UnreadFabs( scrollState.lastReallyVisibleItemIndex } // remember unread info to avoid unnecessary re-computations - val bottomUnreadInfo = remember(unreadFabsInfo, lastReallyVisibleItemIndex) { + val bottomUnreadInfo = remember(changeKey, lastReallyVisibleItemIndex) { unreadFabsInfo.unreadAfterIndex(lastReallyVisibleItemIndex) } AnimatedVisibility( -- GitLab