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 notificationCountRooms: Int = 0,
val notificationHighlightRooms: Boolean = false, val notificationHighlightRooms: Boolean = false,
val hasUnreadMessages: Boolean = false, val hasUnreadMessages: Boolean = false,
val syncState: SyncState = SyncState.Idle, val syncState: SyncState? = null,
val incrementalSyncRequestState: SyncRequestState.IncrementalSyncRequestState = SyncRequestState.IncrementalSyncIdle, val incrementalSyncRequestState: SyncRequestState.IncrementalSyncRequestState? = null,
val pushCounter: Int = 0, val pushCounter: Int = 0,
val pstnSupportFlag: Boolean = false, val pstnSupportFlag: Boolean = false,
val forceDialPadTab: Boolean = false val forceDialPadTab: Boolean = false

View File

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

View File

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