Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit ed3c683

Browse files
Offload fetching sites to a background thread
1 parent 82a9b48 commit ed3c683

File tree

1 file changed

+11
-6
lines changed
  • fluxc/src/main/java/org/wordpress/android/fluxc/store

1 file changed

+11
-6
lines changed

fluxc/src/main/java/org/wordpress/android/fluxc/store/SiteStore.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,12 +1341,15 @@ open class SiteStore @Inject constructor(
13411341
}
13421342

13431343
suspend fun fetchSite(site: SiteModel): OnSiteChanged {
1344-
val updatedSite = if (site.isUsingWpComRestApi) {
1345-
siteRestClient.fetchSite(site)
1346-
} else {
1347-
siteXMLRPCClient.fetchSite(site)
1344+
return coroutineEngine.withDefaultContext(T.API, this, "Fetch site") {
1345+
val updatedSite = if (site.isUsingWpComRestApi) {
1346+
siteRestClient.fetchSite(site)
1347+
} else {
1348+
siteXMLRPCClient.fetchSite(site)
1349+
}
1350+
1351+
updateSite(updatedSite)
13481352
}
1349-
return updateSite(updatedSite)
13501353
}
13511354

13521355
suspend fun fetchSites(payload: FetchSitesPayload): OnSiteChanged {
@@ -1357,7 +1360,9 @@ open class SiteStore @Inject constructor(
13571360
}
13581361

13591362
suspend fun fetchSitesXmlRpc(payload: RefreshSitesXMLRPCPayload): OnSiteChanged {
1360-
return updateSites(siteXMLRPCClient.fetchSites(payload.url, payload.username, payload.password))
1363+
return coroutineEngine.withDefaultContext(T.API, this, "Fetch sites") {
1364+
updateSites(siteXMLRPCClient.fetchSites(payload.url, payload.username, payload.password))
1365+
}
13611366
}
13621367

13631368
@Suppress("ForbiddenComment", "SwallowedException")

0 commit comments

Comments
 (0)