Be more robust when parsing some enums

This commit is contained in:
Benoit Marty 2021-03-26 12:15:06 +01:00
parent 0f22dc610d
commit a7539d0f95
2 changed files with 15 additions and 2 deletions

View File

@ -11,6 +11,7 @@ Improvements 🙌:
- Improve message with Emoji only detection (#3017)
- Picture preview when replying. Also add the image preview in the message detail bottomsheet (#2916)
- Api interceptor to allow app developers peek responses (#2986)
- Be more robust when parsing some enums
Bugfix 🐛:
- Fix bad theme change for the MainActivity

View File

@ -18,8 +18,20 @@ package org.matrix.android.sdk.api.session.room.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import timber.log.Timber
@JsonClass(generateAdapter = true)
data class RoomHistoryVisibilityContent(
@Json(name = "history_visibility") val historyVisibility: RoomHistoryVisibility? = null
)
@Json(name = "history_visibility") private val _historyVisibility: String? = null
) {
val historyVisibility: RoomHistoryVisibility? = when (_historyVisibility) {
"world_readable" -> RoomHistoryVisibility.WORLD_READABLE
"shared" -> RoomHistoryVisibility.SHARED
"invited" -> RoomHistoryVisibility.INVITED
"joined" -> RoomHistoryVisibility.JOINED
else -> {
Timber.w("Invalid value for RoomHistoryVisibility: `$_historyVisibility`")
null
}
}
}