mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-08-19 05:45:41 +00:00
fix(sync): restore foreground refresh behavior
This commit is contained in:
parent
2f19d06fd3
commit
7210e7cc68
3 changed files with 17 additions and 4 deletions
|
|
@ -1221,7 +1221,7 @@ private fun MainAppContent(
|
|||
val activeProfileId = profileState.activeProfile?.profileIndex ?: return@LaunchedEffect
|
||||
SyncManager.pullAllForProfile(activeProfileId)
|
||||
AppForegroundMonitor.events().collect {
|
||||
SyncManager.requestForegroundPull(activeProfileId)
|
||||
SyncManager.requestForegroundPull(activeProfileId, force = true)
|
||||
}
|
||||
}
|
||||
var resumePromptItem by remember { mutableStateOf<ContinueWatchingItem?>(null) }
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ object SimklProgressRepository {
|
|||
}
|
||||
}
|
||||
|
||||
internal fun simklProgressRefreshIntent(sourceChanged: Boolean): TrackingRefreshIntent =
|
||||
if (sourceChanged) TrackingRefreshIntent.INVALIDATED else TrackingRefreshIntent.AUTOMATIC
|
||||
|
||||
object SimklTrackingProgressProvider : TrackingProgressProvider {
|
||||
override val providerId: TrackingProviderId = TrackingProviderId.SIMKL
|
||||
override val changes: Flow<Unit> = SimklProgressRepository.uiState.map { Unit }
|
||||
|
|
@ -179,9 +182,7 @@ object SimklTrackingProgressProvider : TrackingProgressProvider {
|
|||
override fun onProfileChanged() = SimklProgressRepository.ensureLoaded()
|
||||
|
||||
override suspend fun refresh(force: Boolean, sourceChanged: Boolean) =
|
||||
SimklProgressRepository.refresh(
|
||||
if (sourceChanged) TrackingRefreshIntent.INVALIDATED else TrackingRefreshIntent.AUTOMATIC,
|
||||
)
|
||||
SimklProgressRepository.refresh(simklProgressRefreshIntent(sourceChanged))
|
||||
|
||||
override fun snapshot(): TrackingProgressSnapshot {
|
||||
val state = SimklProgressRepository.uiState.value
|
||||
|
|
|
|||
|
|
@ -10,6 +10,18 @@ import kotlin.test.assertFalse
|
|||
import kotlin.test.assertTrue
|
||||
|
||||
class SimklRefreshPolicyTest {
|
||||
@Test
|
||||
fun `progress refresh keeps provider policy unless the source changes`() {
|
||||
assertEquals(
|
||||
TrackingRefreshIntent.AUTOMATIC,
|
||||
simklProgressRefreshIntent(sourceChanged = false),
|
||||
)
|
||||
assertEquals(
|
||||
TrackingRefreshIntent.INVALIDATED,
|
||||
simklProgressRefreshIntent(sourceChanged = true),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `automatic refresh is throttled for fifteen minutes`() {
|
||||
val lastCheckedAt = 1_000L
|
||||
|
|
|
|||
Loading…
Reference in a new issue