From d69bdb260db9ea2575cecd78ca5e8a89c3512767 Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Fri, 21 Oct 2022 18:47:16 +0200 Subject: [PATCH] Fixed scrolling to a tag/branch not working as expected --- src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt index 8b21eb4..20bcfe8 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt @@ -106,7 +106,6 @@ fun Log( } if (logStatus is LogStatus.Loaded) { - val coroutineScope = rememberCoroutineScope() val hasUncommitedChanges = logStatus.hasUncommitedChanges val commitList = logStatus.plotCommitList val verticalScrollState by logViewModel.verticalListState.collectAsState() @@ -117,13 +116,13 @@ fun Log( // the proper scroll position verticalScrollState.observeScrollChanges() - LaunchedEffect(Unit) { - coroutineScope.launch { + LaunchedEffect(verticalScrollState) { + launch { logViewModel.focusCommit.collect { commit -> scrollToCommit(verticalScrollState, commitList, commit) } } - coroutineScope.launch { + launch { logViewModel.scrollToUncommitedChanges.collect { scrollToUncommitedChanges(verticalScrollState, commitList) } @@ -382,7 +381,7 @@ fun MessagesList( ) } } - items(items = commitList) { graphNode -> + items(items = commitList, key = { it.name }) { graphNode -> CommitLine( graphWidth = graphWidth, logViewModel = logViewModel, @@ -479,7 +478,7 @@ fun GraphList( } } - items(items = commitList) { graphNode -> + items(items = commitList, key = { it.name }) { graphNode -> val nodeColor = colors[graphNode.lane.position % colors.size] Row(