[fenix] Close https://github.com/mozilla-mobile/fenix/issues/26198: Add debounce to account manager syncs

pull/600/head
Roger Yang 2 years ago committed by mergify[bot]
parent ac86fcc99b
commit 40509a528e

@ -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
)
}

@ -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)
}

@ -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

Loading…
Cancel
Save