mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Some correction in the code
This commit is contained in:
parent
058c0482da
commit
e60037300a
3 changed files with 87 additions and 95 deletions
|
|
@ -481,7 +481,7 @@ class UploadWorker(
|
|||
contribution.media.captions,
|
||||
)
|
||||
|
||||
if (revisionID != null) {
|
||||
if (null != revisionID) {
|
||||
withContext(Dispatchers.IO) {
|
||||
// Fetch and update place details
|
||||
val place = placesRepository.fetchPlace(wikiDataPlace.id)
|
||||
|
|
|
|||
|
|
@ -81,17 +81,16 @@ class WikiBaseClient
|
|||
fun addLabelsToWikidata(
|
||||
fileEntityId: Long,
|
||||
languageCode: String?,
|
||||
captionValue: String?
|
||||
): Observable<MwPostResponse> {
|
||||
return csrfToken().switchMap { editToken ->
|
||||
captionValue: String?,
|
||||
): Observable<MwPostResponse> =
|
||||
csrfToken().switchMap { editToken ->
|
||||
wikiBaseInterface.addLabelstoWikidata(
|
||||
PAGE_ID_PREFIX + fileEntityId,
|
||||
editToken,
|
||||
languageCode,
|
||||
captionValue
|
||||
captionValue,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun csrfToken(): Observable<String> =
|
||||
Observable.fromCallable {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Named
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
||||
/**
|
||||
* This class is meant to handle the Wikidata edits made through the app It will talk with MediaWiki
|
||||
* Apis to make the necessary calls, log the edits and fire listeners on successful edits
|
||||
|
|
@ -54,7 +55,6 @@ class WikidataEditService @Inject constructor(
|
|||
fileEntityId: String,
|
||||
depictedItems: List<String>
|
||||
): Observable<Boolean> {
|
||||
|
||||
val data = EditClaim.from(
|
||||
if (isBetaFlavour) listOf("Q10") else depictedItems, DEPICTS.propertyName
|
||||
)
|
||||
|
|
@ -79,7 +79,6 @@ class WikidataEditService @Inject constructor(
|
|||
fileEntityId: String?,
|
||||
depictedItems: List<String>
|
||||
): Observable<Boolean> {
|
||||
|
||||
val entityId: String = PAGE_ID_PREFIX + fileEntityId
|
||||
val claimIds = getDepictionsClaimIds(entityId)
|
||||
|
||||
|
|
@ -164,8 +163,7 @@ class WikidataEditService @Inject constructor(
|
|||
)
|
||||
return null
|
||||
}
|
||||
val result = addImageAndMediaLegends(wikidataPlace!!, fileName, captions)
|
||||
return result
|
||||
return addImageAndMediaLegends(wikidataPlace!!, fileName, captions)
|
||||
}
|
||||
|
||||
fun addImageAndMediaLegends(
|
||||
|
|
@ -197,8 +195,7 @@ class WikidataEditService @Inject constructor(
|
|||
), Arrays.asList(MEDIA_LEGENDS.propertyName)
|
||||
)
|
||||
|
||||
val result = wikidataClient.setClaim(claim, COMMONS_APP_TAG).blockingSingle()
|
||||
return result
|
||||
return wikidataClient.setClaim(claim, COMMONS_APP_TAG).blockingSingle()
|
||||
}
|
||||
|
||||
fun handleImageClaimResult(wikidataItem: WikidataItem, revisionId: Long?) {
|
||||
|
|
@ -242,22 +239,18 @@ class WikidataEditService @Inject constructor(
|
|||
|
||||
@SuppressLint("NewApi")
|
||||
private fun captionEdits(contribution: Contribution, fileEntityId: Long): Observable<Boolean> {
|
||||
val result = Observable.fromIterable(contribution.media.captions.entries)
|
||||
return Observable.fromIterable(contribution.media.captions.entries)
|
||||
.concatMap { addCaption(fileEntityId, it.key, it.value) }
|
||||
return result
|
||||
}
|
||||
|
||||
private fun depictionEdits(
|
||||
contribution: Contribution,
|
||||
fileEntityId: Long
|
||||
): Observable<Boolean> {
|
||||
val result = addDepictsProperty(fileEntityId.toString(), buildList {
|
||||
): Observable<Boolean> = addDepictsProperty(fileEntityId.toString(), buildList {
|
||||
for ((_, _, _, _, _, _, id) in contribution.depictedItems) {
|
||||
add(id)
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val COMMONS_APP_TAG: String = "wikimedia-commons-app"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue