* Trigger API call to addDepictionsAndCaptions after succesfull upload from stash
This commit is contained in:
Ashish 2021-04-18 12:49:26 +05:30 committed by GitHub
parent bebc4afae2
commit 8c7954a158
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View file

@ -280,6 +280,8 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
"Stash Upload success..proceeding to make wikidata edit"
)
wikidataEditService.addDepictionsAndCaptions(uploadResult, contribution)
.blockingSubscribe();
if(contribution.wikidataPlace==null){
Timber.d(
"WikiDataEdit not required, upload success"
@ -339,7 +341,6 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
* Make the WikiData Edit, if applicable
*/
private suspend fun makeWikiDataEdit(uploadResult: UploadResult, contribution: Contribution) {
wikidataEditService.addDepictionsAndCaptions(uploadResult, contribution)
val wikiDataPlace = contribution.wikidataPlace
if (wikiDataPlace != null && wikiDataPlace.imageValue == null) {
if (!contribution.hasInvalidLocation()) {

View file

@ -179,13 +179,12 @@ public class WikidataEditService {
}
}
public Disposable addDepictionsAndCaptions(UploadResult uploadResult, Contribution contribution) {
public Observable addDepictionsAndCaptions(final UploadResult uploadResult, final Contribution contribution) {
return wikiBaseClient.getFileEntityId(uploadResult)
.doOnError(throwable -> {
Timber.e(throwable, "Error occurred while getting EntityID to set DEPICTS property");
ViewUtil.showLongToast(context, context.getString(R.string.wikidata_edit_failure));
})
.subscribeOn(Schedulers.io())
.switchMap(fileEntityId -> {
if (fileEntityId != null) {
Timber.d("EntityId for image was received successfully: %s", fileEntityId);
@ -198,9 +197,6 @@ public class WikidataEditService {
return Observable.empty();
}
}
).subscribe(
success -> Timber.d("edit response: %s", success),
throwable -> Timber.e(throwable, "posting edits failed")
);
}