Skip to content

Commit 8c7954a

Browse files
* Trigger API call to addDepictionsAndCaptions after succesfull upload from stash
1 parent bebc4af commit 8c7954a

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

app/src/main/java/fr/free/nrw/commons/upload/worker/UploadWorker.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
280280
"Stash Upload success..proceeding to make wikidata edit"
281281
)
282282

283+
wikidataEditService.addDepictionsAndCaptions(uploadResult, contribution)
284+
.blockingSubscribe();
283285
if(contribution.wikidataPlace==null){
284286
Timber.d(
285287
"WikiDataEdit not required, upload success"
@@ -339,7 +341,6 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
339341
* Make the WikiData Edit, if applicable
340342
*/
341343
private suspend fun makeWikiDataEdit(uploadResult: UploadResult, contribution: Contribution) {
342-
wikidataEditService.addDepictionsAndCaptions(uploadResult, contribution)
343344
val wikiDataPlace = contribution.wikidataPlace
344345
if (wikiDataPlace != null && wikiDataPlace.imageValue == null) {
345346
if (!contribution.hasInvalidLocation()) {

app/src/main/java/fr/free/nrw/commons/wikidata/WikidataEditService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,12 @@ public void handleImageClaimResult(final WikidataItem wikidataItem, final Long r
179179
}
180180
}
181181

182-
public Disposable addDepictionsAndCaptions(UploadResult uploadResult, Contribution contribution) {
182+
public Observable addDepictionsAndCaptions(final UploadResult uploadResult, final Contribution contribution) {
183183
return wikiBaseClient.getFileEntityId(uploadResult)
184184
.doOnError(throwable -> {
185185
Timber.e(throwable, "Error occurred while getting EntityID to set DEPICTS property");
186186
ViewUtil.showLongToast(context, context.getString(R.string.wikidata_edit_failure));
187187
})
188-
.subscribeOn(Schedulers.io())
189188
.switchMap(fileEntityId -> {
190189
if (fileEntityId != null) {
191190
Timber.d("EntityId for image was received successfully: %s", fileEntityId);
@@ -198,9 +197,6 @@ public Disposable addDepictionsAndCaptions(UploadResult uploadResult, Contributi
198197
return Observable.empty();
199198
}
200199
}
201-
).subscribe(
202-
success -> Timber.d("edit response: %s", success),
203-
throwable -> Timber.e(throwable, "posting edits failed")
204200
);
205201
}
206202

0 commit comments

Comments
 (0)