Do not show unknown data.

This commit is contained in:
Benoit Marty 2023-01-27 16:40:20 +01:00
parent 8f927a46ca
commit 366ce8665d
3 changed files with 10 additions and 8 deletions

View file

@ -38,8 +38,8 @@ data class HomeDetailViewState(
val notificationCountRooms: Int = 0,
val notificationHighlightRooms: Boolean = false,
val hasUnreadMessages: Boolean = false,
val syncState: SyncState = SyncState.Idle,
val incrementalSyncRequestState: SyncRequestState.IncrementalSyncRequestState = SyncRequestState.IncrementalSyncIdle,
val syncState: SyncState? = null,
val incrementalSyncRequestState: SyncRequestState.IncrementalSyncRequestState? = null,
val pushCounter: Int = 0,
val pstnSupportFlag: Boolean = false,
val forceDialPadTab: Boolean = false

View file

@ -60,8 +60,8 @@ data class RoomDetailViewState(
val formattedTypingUsers: String? = null,
val tombstoneEvent: Event? = null,
val joinUpgradedRoomAsync: Async<String> = Uninitialized,
val syncState: SyncState = SyncState.Idle,
val incrementalSyncRequestState: SyncRequestState.IncrementalSyncRequestState = SyncRequestState.IncrementalSyncIdle,
val syncState: SyncState? = null,
val incrementalSyncRequestState: SyncRequestState.IncrementalSyncRequestState? = null,
val pushCounter: Int = 0,
val highlightedEventId: String? = null,
val unreadState: UnreadState = UnreadState.Unknown,

View file

@ -40,8 +40,8 @@ class SyncStateView @JvmOverloads constructor(context: Context, attrs: Attribute
@SuppressLint("SetTextI18n")
fun render(
newState: SyncState,
incrementalSyncRequestState: SyncRequestState.IncrementalSyncRequestState,
newState: SyncState?,
incrementalSyncRequestState: SyncRequestState.IncrementalSyncRequestState?,
pushCounter: Int,
showDebugInfo: Boolean
) {
@ -64,8 +64,9 @@ class SyncStateView @JvmOverloads constructor(context: Context, attrs: Attribute
}
}
private fun SyncState.toHumanReadable(): String {
private fun SyncState?.toHumanReadable(): String {
return when (this) {
null -> "Unknown"
SyncState.Idle -> "Idle"
SyncState.InvalidToken -> "InvalidToken"
SyncState.Killed -> "Killed"
@ -76,8 +77,9 @@ class SyncStateView @JvmOverloads constructor(context: Context, attrs: Attribute
}
}
private fun SyncRequestState.IncrementalSyncRequestState.toHumanReadable(): String {
private fun SyncRequestState.IncrementalSyncRequestState?.toHumanReadable(): String {
return when (this) {
null -> "Unknown"
SyncRequestState.IncrementalSyncIdle -> "Idle"
is SyncRequestState.IncrementalSyncParsing -> "Parsing ${this.rooms} room(s) ${this.toDevice} toDevice(s)"
SyncRequestState.IncrementalSyncError -> "Error"