Skip to content

Commit 88e49be

Browse files
committed
Reorder initializing SiteComponent
The `SiteComponent` is now initialized before updating the state.
1 parent 0a266f4 commit 88e49be

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/tools/SelectedSite.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,18 @@ class SelectedSite @Inject constructor(
8787
@Suppress("DEPRECATION")
8888
@Synchronized
8989
fun set(siteModel: SiteModel) {
90+
// Create a new site component tied to the lifecycle of the selected site
91+
siteComponent = siteComponentProvider.get()
92+
.setSite(siteModel)
93+
.setCoroutineScope(createSiteCoroutineScope())
94+
.build()
95+
9096
wasReset = false
9197
state.value = siteModel
9298
PreferenceUtils.setInt(getPreferences(), SELECTED_SITE_LOCAL_ID, siteModel.id)
9399

94100
// Notify listeners
95101
getEventBus().post(SelectedSiteChangedEvent(siteModel))
96-
97-
// Create a new site component tied to the lifecycle of the selected site
98-
siteComponent = siteComponentProvider.get()
99-
.setSite(get())
100-
.setCoroutineScope(createSiteCoroutineScope())
101-
.build()
102102
}
103103

104104
@Synchronized

0 commit comments

Comments
 (0)