From ffe2d5cffb04b052a1f6c35a2861463cc94fdfc1 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sun, 12 May 2024 22:09:27 +0200 Subject: [PATCH] Scroll timeline to the top when synchronization is over --- .../readrops/app/compose/timelime/TimelineScreenModel.kt | 4 +++- .../com/readrops/app/compose/timelime/TimelineTab.kt | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/appcompose/src/main/java/com/readrops/app/compose/timelime/TimelineScreenModel.kt b/appcompose/src/main/java/com/readrops/app/compose/timelime/TimelineScreenModel.kt index 36ecba6e..472292ea 100644 --- a/appcompose/src/main/java/com/readrops/app/compose/timelime/TimelineScreenModel.kt +++ b/appcompose/src/main/java/com/readrops/app/compose/timelime/TimelineScreenModel.kt @@ -322,7 +322,9 @@ class TimelineScreenModel( } } - + fun resetEndSynchronizing() { + _timelineState.update { it.copy(endSynchronizing = false) } + } } @Stable diff --git a/appcompose/src/main/java/com/readrops/app/compose/timelime/TimelineTab.kt b/appcompose/src/main/java/com/readrops/app/compose/timelime/TimelineTab.kt index 1c4b2efc..1089f63c 100644 --- a/appcompose/src/main/java/com/readrops/app/compose/timelime/TimelineTab.kt +++ b/appcompose/src/main/java/com/readrops/app/compose/timelime/TimelineTab.kt @@ -102,6 +102,13 @@ object TimelineTab : Tab { } } + LaunchedEffect(state.endSynchronizing) { + if (state.endSynchronizing) { + lazyListState.animateScrollToItem(0) + viewModel.resetEndSynchronizing() + } + } + val drawerState = rememberDrawerState( initialValue = DrawerValue.Closed, confirmStateChange = { @@ -147,7 +154,7 @@ object TimelineTab : Tab { } } } - + LaunchedEffect(state.syncError) { if (state.syncError != null) { snackbarHostState.showSnackbar(ErrorMessage.get(state.syncError!!, context))