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

Commit a10939f

Browse files
authored
Merge pull request #1466 from wordpress-mobile/issue/gb-rollout-phase2
Add a setOnlyIfEmpty option to the DesignateMobileEditorForAllSites payload
2 parents 4e77f9d + a893bde commit a10939f

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/site/SiteRestClient.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,17 @@ public void onErrorResponse(@NonNull WPComGsonNetworkError error) {
332332
add(request);
333333
}
334334

335-
public void designateMobileEditorForAllSites(final String mobileEditorName) {
335+
public void designateMobileEditorForAllSites(final String mobileEditorName, final boolean setOnlyIfEmpty) {
336336
Map<String, Object> params = new HashMap<>();
337337
String url = WPCOMV2.me.gutenberg.getUrl();
338338
params.put("editor", mobileEditorName);
339339
params.put("platform", "mobile");
340-
params.put("set_only_if_empty", "true");
340+
if (setOnlyIfEmpty) {
341+
params.put("set_only_if_empty", "true");
342+
}
343+
// Else, omit the "set_only_if_empty" parameters.
344+
// There is an issue in the API implementation. It only checks
345+
// for "set_only_if_empty" presence but don't check for its value.
341346

342347
add(WPComGsonRequest
343348
.buildPostRequest(url, params, Map.class,

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,16 @@ public FetchedPostFormatsPayload(@NonNull SiteModel site, @NonNull List<PostForm
115115

116116
public static class DesignateMobileEditorForAllSitesPayload extends Payload<SiteEditorsError> {
117117
public String editor;
118+
public boolean setOnlyIfEmpty;
118119

119120
public DesignateMobileEditorForAllSitesPayload(@NonNull String editorName) {
120121
this.editor = editorName;
122+
this.setOnlyIfEmpty = true;
123+
}
124+
125+
public DesignateMobileEditorForAllSitesPayload(@NonNull String editorName, boolean setOnlyIfEmpty) {
126+
this.editor = editorName;
127+
this.setOnlyIfEmpty = setOnlyIfEmpty;
121128
}
122129
}
123130

@@ -1754,7 +1761,7 @@ private void designateMobileEditorForAllSites(DesignateMobileEditorForAllSitesPa
17541761
}
17551762

17561763
if (wpcomPostRequestRequired) {
1757-
mSiteRestClient.designateMobileEditorForAllSites(payload.editor);
1764+
mSiteRestClient.designateMobileEditorForAllSites(payload.editor, payload.setOnlyIfEmpty);
17581765
event.isNetworkResponse = false;
17591766
} else {
17601767
event.isNetworkResponse = true;

0 commit comments

Comments
 (0)