mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Skip image upload to Wikidata (nearby -> green pins) (#6349)
Some checks failed
Android CI / Run tests and generate APK (push) Has been cancelled
Some checks failed
Android CI / Run tests and generate APK (push) Has been cancelled
* Skip image upload to Wikidata if item already has image * Re-run CI * no more Failed to update Wikidata for green pins
This commit is contained in:
parent
ca5c7ec966
commit
09da7b8d68
3 changed files with 12 additions and 13 deletions
|
|
@ -472,7 +472,10 @@ class UploadWorker(
|
||||||
if (wikiDataPlace != null) {
|
if (wikiDataPlace != null) {
|
||||||
if (!contribution.hasInvalidLocation()) {
|
if (!contribution.hasInvalidLocation()) {
|
||||||
var revisionID: Long? = null
|
var revisionID: Long? = null
|
||||||
|
val p18WasSkipped = !wikiDataPlace.imageValue.isNullOrBlank()
|
||||||
try {
|
try {
|
||||||
|
if (!p18WasSkipped) {
|
||||||
|
// Only set P18 if the place does not already have a picture
|
||||||
revisionID =
|
revisionID =
|
||||||
wikidataEditService.createClaim(
|
wikidataEditService.createClaim(
|
||||||
wikiDataPlace,
|
wikiDataPlace,
|
||||||
|
|
@ -490,8 +493,10 @@ class UploadWorker(
|
||||||
.blockingAwait()
|
.blockingAwait()
|
||||||
Timber.d("Updated WikiItem place ${place.name} with image ${place.pic}")
|
Timber.d("Updated WikiItem place ${place.name} with image ${place.pic}")
|
||||||
}
|
}
|
||||||
showSuccessNotification(contribution)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Always show success notification, whether P18 was set or skipped
|
||||||
|
showSuccessNotification(contribution)
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Timber.e(exception)
|
Timber.e(exception)
|
||||||
}
|
}
|
||||||
|
|
@ -500,6 +505,7 @@ class UploadWorker(
|
||||||
wikidataEditService.handleImageClaimResult(
|
wikidataEditService.handleImageClaimResult(
|
||||||
contribution.wikidataPlace!!,
|
contribution.wikidataPlace!!,
|
||||||
revisionID,
|
revisionID,
|
||||||
|
p18WasSkipped = p18WasSkipped
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -196,13 +196,16 @@ class WikidataEditService @Inject constructor(
|
||||||
return wikidataClient.setClaim(claim, COMMONS_APP_TAG).blockingSingle()
|
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) {
|
if (revisionId != null) {
|
||||||
wikidataEditListener?.onSuccessfulWikidataEdit()
|
wikidataEditListener?.onSuccessfulWikidataEdit()
|
||||||
showSuccessToast(wikidataItem.name)
|
showSuccessToast(wikidataItem.name)
|
||||||
} else {
|
} else if (!p18WasSkipped) {
|
||||||
Timber.d("Unable to make wiki data edit for entity %s", wikidataItem)
|
Timber.d("Unable to make wiki data edit for entity %s", wikidataItem)
|
||||||
showLongToast(context, context.getString(R.string.wikidata_edit_failure))
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Authors:
|
|
||||||
* Vlad5250
|
|
||||||
-->
|
|
||||||
<resources>
|
|
||||||
<string name="crash_dialog_title">کامَنٕز گوو رُکِتھ</string>
|
|
||||||
<string name="crash_dialog_text">Oops. کیہہ تام گوو غلط!</string>
|
|
||||||
<string name="crash_dialog_comment_prompt">ؤنِیوٚ اَسہِ توٚہہِ کیاہ ٲسِیوٚ کران، تہٕ کٕریٚو تہِ اَسہِ سٕتی شیر بذریعہِ برقی خط. یُس مَدَتھ کَرِ اَسہِ اَتھ شہَرنَس منٛز!</string>
|
|
||||||
<string name="crash_dialog_ok_toast">شُکریہ!</string>
|
|
||||||
</resources>
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue