fix translating boosts in home timeline (#4590)

fixes https://github.com/tuskyapp/Tusky/issues/4589
This commit is contained in:
Konrad Pozniak 2024-08-06 20:10:38 +02:00 committed by GitHub
parent 17c50b0829
commit b68e9760fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 5 deletions

View File

@ -284,19 +284,18 @@ class CachedTimelineViewModel @Inject constructor(
} }
override suspend fun translate(status: StatusViewData.Concrete): NetworkResult<Unit> { override suspend fun translate(status: StatusViewData.Concrete): NetworkResult<Unit> {
translations.value = translations.value + (status.id to TranslationViewData.Loading) translations.value += (status.id to TranslationViewData.Loading)
return timelineCases.translate(status.actionableId) return timelineCases.translate(status.actionableId)
.map { translation -> .map { translation ->
translations.value = translations.value += (status.actionableId to TranslationViewData.Loaded(translation))
translations.value + (status.id to TranslationViewData.Loaded(translation))
} }
.onFailure { .onFailure {
translations.value = translations.value - status.id translations.value -= status.actionableId
} }
} }
override fun untranslate(status: StatusViewData.Concrete) { override fun untranslate(status: StatusViewData.Concrete) {
translations.value = translations.value - status.id translations.value -= status.actionableId
} }
companion object { companion object {