Support both "label" and "itemLabel" for NearbyResultItem mapping (#6386)

* Support both label and itemLabel for robust NearbyResultItem mapping.

* fix code style

* Add getOriginalLabel() for Wikidata edits to avoid fallback issues with itemLabel

* Fix Wikidata edit failure by resetting hasInvalidLocation flag on upload confirmation

---------

Co-authored-by: Sonal Yadav <sonalyadav@Sonals-MacBook-Air.local>
This commit is contained in:
Sonal Yadav 2025-08-05 09:43:40 +05:30 committed by GitHub
parent 6dcce45c59
commit ffb9af1f1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 41 deletions

View file

@ -7,7 +7,8 @@ class NearbyResultItem(
private val wikipediaArticle: ResultTuple?,
private val commonsArticle: ResultTuple?,
private val location: ResultTuple?,
private val label: ResultTuple?,
@field:SerializedName("label") private val label: ResultTuple?,
@field:SerializedName("itemLabel") private val itemLabel: ResultTuple?,
@field:SerializedName("streetAddress") private val address: ResultTuple?,
private val icon: ResultTuple?,
@field:SerializedName("class") private val className: ResultTuple?,
@ -29,7 +30,15 @@ class NearbyResultItem(
fun getLocation(): ResultTuple = location ?: ResultTuple()
fun getLabel(): ResultTuple = label ?: ResultTuple()
/**
* Returns label for display (pins, popup), using fallback to itemLabel if needed.
*/
fun getLabel(): ResultTuple = label ?: itemLabel ?: ResultTuple()
/**
* Returns only the original label field, for Wikidata edits.
*/
fun getOriginalLabel(): ResultTuple = label ?: ResultTuple()
fun getIcon(): ResultTuple = icon ?: ResultTuple()

View file

@ -821,6 +821,7 @@ class UploadMediaDetailFragment : UploadBaseFragment(), UploadMediaDetailsContra
{
showProgress(false)
uploadItem.imageQuality = IMAGE_OK
uploadItem.hasInvalidLocation = false // Reset invalid location flag when user confirms upload
},
{
presenterCallback!!.deletePictureAtIndex(index)