mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
no more Failed to update Wikidata for green pins
This commit is contained in:
parent
0fb9704bbc
commit
2629340470
2 changed files with 10 additions and 7 deletions
|
|
@ -472,9 +472,10 @@ class UploadWorker(
|
|||
if (wikiDataPlace != null) {
|
||||
if (!contribution.hasInvalidLocation()) {
|
||||
var revisionID: Long? = null
|
||||
val p18WasSkipped = !wikiDataPlace.imageValue.isNullOrBlank()
|
||||
try {
|
||||
if (!p18WasSkipped) {
|
||||
// Only set P18 if the place does not already have a picture
|
||||
if (wikiDataPlace.imageValue.isNullOrBlank()) {
|
||||
revisionID =
|
||||
wikidataEditService.createClaim(
|
||||
wikiDataPlace,
|
||||
|
|
@ -492,12 +493,10 @@ class UploadWorker(
|
|||
.blockingAwait()
|
||||
Timber.d("Updated WikiItem place ${place.name} with image ${place.pic}")
|
||||
}
|
||||
showSuccessNotification(contribution)
|
||||
}
|
||||
} else {
|
||||
// Place already has a picture, so skip setting P18 but still show success notification
|
||||
showSuccessNotification(contribution)
|
||||
}
|
||||
// Always show success notification, whether P18 was set or skipped
|
||||
showSuccessNotification(contribution)
|
||||
} catch (exception: Exception) {
|
||||
Timber.e(exception)
|
||||
}
|
||||
|
|
@ -506,6 +505,7 @@ class UploadWorker(
|
|||
wikidataEditService.handleImageClaimResult(
|
||||
contribution.wikidataPlace!!,
|
||||
revisionID,
|
||||
p18WasSkipped = p18WasSkipped
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -196,13 +196,16 @@ class WikidataEditService @Inject constructor(
|
|||
return wikidataClient.setClaim(claim, COMMONS_APP_TAG).blockingSingle()
|
||||
}
|
||||
|
||||
fun handleImageClaimResult(wikidataItem: WikidataItem, revisionId: Long?) {
|
||||
fun handleImageClaimResult(wikidataItem: WikidataItem, revisionId: Long?, p18WasSkipped: Boolean = false) {
|
||||
if (revisionId != null) {
|
||||
wikidataEditListener?.onSuccessfulWikidataEdit()
|
||||
showSuccessToast(wikidataItem.name)
|
||||
} else {
|
||||
} else if (!p18WasSkipped) {
|
||||
Timber.d("Unable to make wiki data edit for entity %s", wikidataItem)
|
||||
showLongToast(context, context.getString(R.string.wikidata_edit_failure))
|
||||
} else {
|
||||
Timber.d("Wikidata edit skipped for entity %s because P18 already exists", wikidataItem)
|
||||
// No error shown to user, as this is not a failure
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue