Close #26198: Add debounce to account manager syncs
This commit is contained in:
parent
f356df785c
commit
4204c43236
|
@ -340,8 +340,13 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
// If we're authenticated, kick-off a sync and a device state refresh.
|
// If we're authenticated, kick-off a sync and a device state refresh.
|
||||||
components.backgroundServices.accountManager.authenticatedAccount()?.let {
|
components.backgroundServices.accountManager.authenticatedAccount()?.let {
|
||||||
|
val syncReason = when (isVisuallyComplete) {
|
||||||
|
true -> SyncReason.User
|
||||||
|
false -> SyncReason.Startup
|
||||||
|
}
|
||||||
|
|
||||||
components.backgroundServices.accountManager.syncNow(
|
components.backgroundServices.accountManager.syncNow(
|
||||||
SyncReason.Startup,
|
reason = syncReason,
|
||||||
debounce = true
|
debounce = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,11 @@ class RecentSyncedTabFeature(
|
||||||
// Sync tabs storage will fail to retrieve tabs aren't refreshed, as that action
|
// Sync tabs storage will fail to retrieve tabs aren't refreshed, as that action
|
||||||
// is what populates the device constellation state
|
// is what populates the device constellation state
|
||||||
accountManager.withConstellation { refreshDevices() }
|
accountManager.withConstellation { refreshDevices() }
|
||||||
accountManager.syncNow(SyncReason.User, customEngineSubset = listOf(SyncEngine.Tabs))
|
accountManager.syncNow(
|
||||||
|
reason = SyncReason.User,
|
||||||
|
debounce = true,
|
||||||
|
customEngineSubset = listOf(SyncEngine.Tabs),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}.launchIn(coroutineScope)
|
}.launchIn(coroutineScope)
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ class RecentSyncedTabFeatureTest {
|
||||||
|
|
||||||
verify { appStore.dispatch(AppAction.RecentSyncedTabStateChange(RecentSyncedTabState.Loading)) }
|
verify { appStore.dispatch(AppAction.RecentSyncedTabStateChange(RecentSyncedTabState.Loading)) }
|
||||||
coVerify { accountManager.withConstellation { refreshDevices() } }
|
coVerify { accountManager.withConstellation { refreshDevices() } }
|
||||||
coVerify { accountManager.syncNow(reason = SyncReason.User, debounce = false, customEngineSubset = listOf(SyncEngine.Tabs)) }
|
coVerify { accountManager.syncNow(reason = SyncReason.User, debounce = true, customEngineSubset = listOf(SyncEngine.Tabs)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue
Block a user