Keep the channel tree's scroll position while the chat replaces it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.KeyboardArrowDown
|
||||
@@ -100,9 +101,9 @@ fun ChannelTree(
|
||||
/** The rows the find bar matched, and the one it is on, which a reveal does not flash. */
|
||||
found: Set<TreeRef> = emptySet(),
|
||||
foundCurrent: TreeRef? = null,
|
||||
listState: LazyListState = rememberLazyListState(),
|
||||
) {
|
||||
val rows = remember(tree, collapsed, currentChannel) { flatten(tree, collapsed, currentChannel) }
|
||||
val listState = rememberLazyListState()
|
||||
var flashing by remember { mutableStateOf<TreeRef?>(null) }
|
||||
LaunchedEffect(reveal, rows) {
|
||||
val ref = reveal ?: return@LaunchedEffect
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowDropDown
|
||||
@@ -113,6 +114,8 @@ fun ServerScreen(
|
||||
val collapsed by server.collapsed.collectAsStateWithLifecycle()
|
||||
|
||||
var showChat by rememberSaveable { mutableStateOf(false) }
|
||||
// Out here, so the tree keeps its place while the chat or another screen replaces it.
|
||||
val treeList = rememberLazyListState()
|
||||
var chatKey by rememberSaveable(stateSaver = ChatKeySaver) { mutableStateOf<ChatKey>(ChatKey.Channel) }
|
||||
val conversation = chats[chatKey] ?: chats.channel
|
||||
var clientSheet by remember { mutableStateOf<Int?>(null) }
|
||||
@@ -280,6 +283,7 @@ fun ServerScreen(
|
||||
onRevealed = { reveal = null },
|
||||
found = remember(treeHits) { treeHits.mapTo(HashSet()) { TreeRef(treeFind.channels, it) } },
|
||||
foundCurrent = treeAt?.takeIf { it in treeHits }?.let { TreeRef(treeFind.channels, it) },
|
||||
listState = treeList,
|
||||
)
|
||||
} else {
|
||||
ChatPane(
|
||||
|
||||
Reference in New Issue
Block a user