Skip to content

Commit

Permalink
Auto save note every 5 seconds while note screen is in composition
Browse files Browse the repository at this point in the history
  • Loading branch information
Eboreg committed Nov 2, 2023
1 parent d65e4e2 commit 37a91ab
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.delay
import org.burnoutcrew.reorderable.ReorderableLazyListState
import org.burnoutcrew.reorderable.reorderable
import us.huseli.retain.R
Expand Down Expand Up @@ -120,6 +121,19 @@ fun BaseNoteScreen(
}
}

LaunchedEffect(Unit) {
while (true) {
onSave(
viewModel.dirtyNote,
viewModel.dirtyChecklistItems,
viewModel.dirtyImages,
viewModel.deletedChecklistItemIds,
viewModel.deletedImageIds,
)
delay(5000L)
}
}

RetainScaffold(
snackbarHostState = snackbarHostState,
statusBarColor = appBarColor,
Expand Down

0 comments on commit 37a91ab

Please sign in to comment.