Skip to content

Commit 948a888

Browse files
authored
Merge pull request #9101 from wordpress-mobile/issue/9081-site-creation-service-invalid-state
Fix bug in NewSiteCreationService - service started multiple times
2 parents 07c3fae + 44b711d commit 948a888

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,22 @@ class NewSiteCreationService : AutoForeground<NewSiteCreationServiceState>(NewSi
111111
retryFromState: NewSiteCreationServiceState?,
112112
data: NewSiteCreationServiceData
113113
) {
114-
clearSiteCreationServiceState()
114+
val currentState = AutoForeground.getState(NewSiteCreationServiceState::class.java)
115+
if (currentState == null || currentState.step == FAILURE) {
116+
clearSiteCreationServiceState()
115117

116-
val intent = Intent(context, NewSiteCreationService::class.java)
118+
val intent = Intent(context, NewSiteCreationService::class.java)
117119

118-
intent.putExtra(ARG_DATA, data)
120+
intent.putExtra(ARG_DATA, data)
119121

120-
if (retryFromState != null) {
121-
intent.putExtra(ARG_RESUME_PHASE, retryFromState.stepName)
122-
}
122+
if (retryFromState != null) {
123+
intent.putExtra(ARG_RESUME_PHASE, retryFromState.stepName)
124+
}
123125

124-
context.startService(intent)
126+
context.startService(intent)
127+
} else {
128+
AppLog.w(T.SITE_CREATION, "Service not started - it seems it's already running.")
129+
}
125130
}
126131

127132
fun clearSiteCreationServiceState() {

0 commit comments

Comments
 (0)