Close #26198: Add debounce to account manager syncs

This commit is contained in:
Roger Yang 2022-08-10 12:19:31 -04:00 committed by mergify[bot]
parent f356df785c
commit 4204c43236
3 changed files with 12 additions and 3 deletions

View File

@ -340,8 +340,13 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
lifecycleScope.launch {
// If we're authenticated, kick-off a sync and a device state refresh.
components.backgroundServices.accountManager.authenticatedAccount()?.let {
val syncReason = when (isVisuallyComplete) {
true -> SyncReason.User
false -> SyncReason.Startup
}
components.backgroundServices.accountManager.syncNow(
SyncReason.Startup,
reason = syncReason,
debounce = true
)
}

View File

@ -60,7 +60,11 @@ class RecentSyncedTabFeature(
// Sync tabs storage will fail to retrieve tabs aren't refreshed, as that action
// is what populates the device constellation state
accountManager.withConstellation { refreshDevices() }
accountManager.syncNow(SyncReason.User, customEngineSubset = listOf(SyncEngine.Tabs))
accountManager.syncNow(
reason = SyncReason.User,
debounce = true,
customEngineSubset = listOf(SyncEngine.Tabs),
)
}
}.launchIn(coroutineScope)
}

View File

@ -128,7 +128,7 @@ class RecentSyncedTabFeatureTest {
verify { appStore.dispatch(AppAction.RecentSyncedTabStateChange(RecentSyncedTabState.Loading)) }
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