File tree Expand file tree Collapse file tree 3 files changed +12
-13
lines changed
res/values-x-invalidLanguageCode Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -472,7 +472,10 @@ class UploadWorker(
472472 if (wikiDataPlace != null ) {
473473 if (! contribution.hasInvalidLocation()) {
474474 var revisionID: Long? = null
475+ val p18WasSkipped = ! wikiDataPlace.imageValue.isNullOrBlank()
475476 try {
477+ if (! p18WasSkipped) {
478+ // Only set P18 if the place does not already have a picture
476479 revisionID =
477480 wikidataEditService.createClaim(
478481 wikiDataPlace,
@@ -489,9 +492,11 @@ class UploadWorker(
489492 .subscribeOn(Schedulers .io())
490493 .blockingAwait()
491494 Timber .d(" Updated WikiItem place ${place.name} with image ${place.pic} " )
495+ }
492496 }
493- showSuccessNotification(contribution)
494497 }
498+ // Always show success notification, whether P18 was set or skipped
499+ showSuccessNotification(contribution)
495500 } catch (exception: Exception ) {
496501 Timber .e(exception)
497502 }
@@ -500,6 +505,7 @@ class UploadWorker(
500505 wikidataEditService.handleImageClaimResult(
501506 contribution.wikidataPlace!! ,
502507 revisionID,
508+ p18WasSkipped = p18WasSkipped
503509 )
504510 }
505511 } else {
Original file line number Diff line number Diff line change @@ -196,13 +196,16 @@ class WikidataEditService @Inject constructor(
196196 return wikidataClient.setClaim(claim, COMMONS_APP_TAG ).blockingSingle()
197197 }
198198
199- fun handleImageClaimResult (wikidataItem : WikidataItem , revisionId : Long? ) {
199+ fun handleImageClaimResult (wikidataItem : WikidataItem , revisionId : Long? , p18WasSkipped : Boolean = false ) {
200200 if (revisionId != null ) {
201201 wikidataEditListener?.onSuccessfulWikidataEdit()
202202 showSuccessToast(wikidataItem.name)
203- } else {
203+ } else if ( ! p18WasSkipped) {
204204 Timber .d(" Unable to make wiki data edit for entity %s" , wikidataItem)
205205 showLongToast(context, context.getString(R .string.wikidata_edit_failure))
206+ } else {
207+ Timber .d(" Wikidata edit skipped for entity %s because P18 already exists" , wikidataItem)
208+ // No error shown to user, as this is not a failure
206209 }
207210 }
208211
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments