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(
472
472
if (wikiDataPlace != null ) {
473
473
if (! contribution.hasInvalidLocation()) {
474
474
var revisionID: Long? = null
475
+ val p18WasSkipped = ! wikiDataPlace.imageValue.isNullOrBlank()
475
476
try {
477
+ if (! p18WasSkipped) {
478
+ // Only set P18 if the place does not already have a picture
476
479
revisionID =
477
480
wikidataEditService.createClaim(
478
481
wikiDataPlace,
@@ -489,9 +492,11 @@ class UploadWorker(
489
492
.subscribeOn(Schedulers .io())
490
493
.blockingAwait()
491
494
Timber .d(" Updated WikiItem place ${place.name} with image ${place.pic} " )
495
+ }
492
496
}
493
- showSuccessNotification(contribution)
494
497
}
498
+ // Always show success notification, whether P18 was set or skipped
499
+ showSuccessNotification(contribution)
495
500
} catch (exception: Exception ) {
496
501
Timber .e(exception)
497
502
}
@@ -500,6 +505,7 @@ class UploadWorker(
500
505
wikidataEditService.handleImageClaimResult(
501
506
contribution.wikidataPlace!! ,
502
507
revisionID,
508
+ p18WasSkipped = p18WasSkipped
503
509
)
504
510
}
505
511
} else {
Original file line number Diff line number Diff line change @@ -196,13 +196,16 @@ class WikidataEditService @Inject constructor(
196
196
return wikidataClient.setClaim(claim, COMMONS_APP_TAG ).blockingSingle()
197
197
}
198
198
199
- fun handleImageClaimResult (wikidataItem : WikidataItem , revisionId : Long? ) {
199
+ fun handleImageClaimResult (wikidataItem : WikidataItem , revisionId : Long? , p18WasSkipped : Boolean = false ) {
200
200
if (revisionId != null ) {
201
201
wikidataEditListener?.onSuccessfulWikidataEdit()
202
202
showSuccessToast(wikidataItem.name)
203
- } else {
203
+ } else if ( ! p18WasSkipped) {
204
204
Timber .d(" Unable to make wiki data edit for entity %s" , wikidataItem)
205
205
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
206
209
}
207
210
}
208
211
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments