Skip to content

Commit 150d289

Browse files
authored
Merge pull request #17022 from wordpress-mobile/issue/17020-fix-crash-on-null-designs-list
Fix crash in Site Creation flow caused by null designs list
2 parents 7460bc5 + b27ba01 commit 150d289

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
20.6
44
-----
55
* [*] Login: Fix an issue preventing some users to log-in in with email addresses containing a single quote [https://github.com/wordpress-mobile/WordPress-Android/pull/15526]
6+
* [*] Fix a possible crash with themes preloading at the start of Site Creation [https://github.com/wordpress-mobile/WordPress-Android/pull/17022]
67

78
20.5
89
-----

WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import org.wordpress.android.ui.sitecreation.misc.SiteCreationTracker
2828
import org.wordpress.android.ui.sitecreation.previews.SitePreviewViewModel.CreateSiteState
2929
import org.wordpress.android.ui.sitecreation.usecases.FetchHomePageLayoutsUseCase
3030
import org.wordpress.android.ui.utils.UiString.UiStringRes
31+
import org.wordpress.android.util.AppLog
32+
import org.wordpress.android.util.AppLog.T
3133
import org.wordpress.android.util.NetworkUtilsWrapper
3234
import org.wordpress.android.util.image.ImageManager
3335
import org.wordpress.android.util.wizard.WizardManager
@@ -124,6 +126,17 @@ class SiteCreationMainVM @Inject constructor(
124126
preloadingJob = viewModelScope.launch(Dispatchers.IO) {
125127
if (networkUtils.isNetworkAvailable()) {
126128
val response = fetchHomePageLayoutsUseCase.fetchStarterDesigns()
129+
130+
// Else clause added to better understand the reason that causes this crash:
131+
// https://github.com/wordpress-mobile/WordPress-Android/issues/17020
132+
if (response.isError) {
133+
AppLog.e(T.THEMES, "Error preloading starter designs: ${response.error}")
134+
return@launch
135+
} else if (response.designs == null) {
136+
AppLog.e(T.THEMES, "Null starter designs response: $response")
137+
return@launch
138+
}
139+
127140
for (design in response.designs) {
128141
imageManager.preload(context, MShot(design.previewMobile))
129142
}

0 commit comments

Comments
 (0)