fix translating polls and spoilers (#4344)

The docs are wrong https://github.com/mastodon/documentation/pull/1423 🙄
This commit is contained in:
Konrad Pozniak 2024-03-29 21:13:57 +01:00 committed by GitHub
commit b022767ae6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View file

@ -67,10 +67,12 @@ sealed class StatusViewData {
actionable.attachments.translated { translation -> map { it.translated(translation) } }
val spoilerText: String =
actionable.spoilerText.translated { translation -> translation.spoilerWarning ?: this }
actionable.spoilerText.translated { translation -> translation.spoilerText ?: this }
val poll = actionable.poll?.translated { translation ->
val translatedOptionsText = translation.poll ?: return@translated this
val translatedOptionsText = translation.poll?.options?.map { option ->
option.title
} ?: return@translated this
val translatedOptions = options.zip(translatedOptionsText) { option, translatedText ->
option.copy(title = translatedText)
}