From 600bc540b11fd16b6e5175b7fb1d349d50297223 Mon Sep 17 00:00:00 2001 From: machiav3lli Date: Tue, 10 Dec 2024 15:54:28 +0100 Subject: [PATCH] Fix: Reseting sort/filter model on start --- .../com/machiav3lli/backup/sheets/SortFilterSheet.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/machiav3lli/backup/sheets/SortFilterSheet.kt b/src/main/java/com/machiav3lli/backup/sheets/SortFilterSheet.kt index dd7fd8ab72..095a72f22a 100644 --- a/src/main/java/com/machiav3lli/backup/sheets/SortFilterSheet.kt +++ b/src/main/java/com/machiav3lli/backup/sheets/SortFilterSheet.kt @@ -36,6 +36,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment @@ -97,15 +98,19 @@ fun SortFilterSheet( val context = LocalContext.current val nestedScrollConnection = rememberNestedScrollInteropConnection() val packageList by viewModel.notBlockedList.collectAsState() - var model by rememberSaveable { + val state by remember(sourcePage) { mutableStateOf( when (sourcePage) { NavItem.Backup -> viewModel.backupState NavItem.Restore -> viewModel.restoreState else -> viewModel.homeState // NavItem.Home - }.value.sortFilter + } ) } + val stateModel by state.collectAsState() + var model by rememberSaveable(stateModel.sortFilter) { + mutableStateOf(state.value.sortFilter) + } fun currentStats() = getStats( packageList.applyFilter(