Skip to content

Commit

Permalink
fix(ui): commit diffs before running in background
Browse files Browse the repository at this point in the history
  • Loading branch information
JunkFood02 committed Nov 23, 2024
1 parent e55f2c9 commit 4be5197
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/src/main/java/me/ash/reader/ui/page/home/flow/FlowPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.eventFlow
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.NavHostController
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.work.WorkInfo
Expand Down Expand Up @@ -169,6 +172,13 @@ fun FlowPage(
}

DisposableEffect(owner) {
scope.launch {
owner.lifecycle.eventFlow.collect {
if (it == Lifecycle.Event.ON_PAUSE) {
flowViewModel.commitDiff()
}
}
}
homeViewModel.syncWorkLiveData.observe(owner) { workInfoList ->
workInfoList.let {
isSyncing = it.any { workInfo -> workInfo.state == WorkInfo.State.RUNNING }
Expand Down

0 comments on commit 4be5197

Please sign in to comment.