Skip to content

Commit eda59a3

Browse files
Refactor logic to fetch sites and user info for site credentials login
1 parent c15c09d commit eda59a3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/AppInitializer.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,15 @@ class AppInitializer @Inject constructor() : ApplicationLifecycleListener {
192192
}
193193

194194
override fun onFirstActivityResumed() {
195-
// Update the WP.com account details, settings, and site list every time the app is completely restarted,
196-
// only if the logged in
197-
if (networkStatus.isConnected() && accountStore.hasAccessToken()) {
198-
dispatcher.dispatch(AccountActionBuilder.newFetchAccountAction())
199-
dispatcher.dispatch(AccountActionBuilder.newFetchSettingsAction())
195+
// App is completely restarted
196+
if (networkStatus.isConnected()) {
197+
if (accountStore.hasAccessToken()) {
198+
// Update the WPCom account if the user is signed in using a WPCom account
199+
dispatcher.dispatch(AccountActionBuilder.newFetchAccountAction())
200+
dispatcher.dispatch(AccountActionBuilder.newFetchSettingsAction())
201+
}
202+
203+
// Update the list of sites
200204
appCoroutineScope.launch {
201205
wooCommerceStore.fetchWooCommerceSites()
202206

@@ -212,7 +216,7 @@ class AppInitializer @Inject constructor() : ApplicationLifecycleListener {
212216
}
213217
}
214218

215-
// Update the user info for the currently logged in user
219+
// Update the user info
216220
if (selectedSite.exists()) {
217221
userEligibilityFetcher.fetchUserEligibility()
218222
}

0 commit comments

Comments
 (0)