fix: prevent unknown-user banner flicker
fix: wait for private chat relationship resolution before showing the add-contact banner
This commit is contained in:
@@ -603,6 +603,7 @@ private fun ChatScreen(
|
||||
val isPrivateChat = state.chatType.equals("private", ignoreCase = true)
|
||||
val showUnknownPrivateChatBanner = isPrivateChat &&
|
||||
state.counterpartUserId != null &&
|
||||
state.isCounterpartRelationshipResolved &&
|
||||
!state.isCounterpartContact &&
|
||||
!state.isCounterpartBlocked
|
||||
val canShowMembersTab = state.chatType.equals("group", ignoreCase = true) ||
|
||||
|
||||
@@ -778,6 +778,11 @@ class ChatViewModel @Inject constructor(
|
||||
it.copy(
|
||||
chatType = chat.type,
|
||||
counterpartUserId = chat.counterpartUserId,
|
||||
isCounterpartRelationshipResolved = if (chat.type.equals("private", ignoreCase = true) && chat.counterpartUserId != null) {
|
||||
it.isCounterpartRelationshipResolved
|
||||
} else {
|
||||
false
|
||||
},
|
||||
chatRole = role,
|
||||
chatMuted = chat.muted,
|
||||
chatTitle = chatTitle,
|
||||
@@ -819,6 +824,7 @@ class ChatViewModel @Inject constructor(
|
||||
is AppResult.Success -> {
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
isCounterpartRelationshipResolved = true,
|
||||
isCounterpartContact = true,
|
||||
isCounterpartBlocked = false,
|
||||
errorMessage = null,
|
||||
@@ -842,6 +848,7 @@ class ChatViewModel @Inject constructor(
|
||||
is AppResult.Success -> {
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
isCounterpartRelationshipResolved = true,
|
||||
isCounterpartContact = false,
|
||||
isCounterpartBlocked = true,
|
||||
errorMessage = null,
|
||||
@@ -964,6 +971,7 @@ class ChatViewModel @Inject constructor(
|
||||
privateChatRelationKey = null
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
isCounterpartRelationshipResolved = false,
|
||||
isCounterpartContact = false,
|
||||
isCounterpartBlocked = false,
|
||||
)
|
||||
@@ -972,6 +980,7 @@ class ChatViewModel @Inject constructor(
|
||||
}
|
||||
if (!force && privateChatRelationKey == counterpartUserId) return
|
||||
privateChatRelationKey = counterpartUserId
|
||||
_uiState.update { it.copy(isCounterpartRelationshipResolved = false) }
|
||||
viewModelScope.launch {
|
||||
val contactsResult = accountRepository.listContacts()
|
||||
val blockedResult = accountRepository.listBlockedUsers()
|
||||
@@ -979,6 +988,7 @@ class ChatViewModel @Inject constructor(
|
||||
val isBlocked = (blockedResult as? AppResult.Success)?.data?.any { it.id == counterpartUserId } == true
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
isCounterpartRelationshipResolved = true,
|
||||
isCounterpartContact = isContact,
|
||||
isCounterpartBlocked = isBlocked,
|
||||
)
|
||||
|
||||
@@ -22,6 +22,7 @@ data class MessageUiState(
|
||||
val chatRole: String? = null,
|
||||
val chatMuted: Boolean = false,
|
||||
val chatUnreadCount: Int = 0,
|
||||
val isCounterpartRelationshipResolved: Boolean = false,
|
||||
val isCounterpartContact: Boolean = false,
|
||||
val isCounterpartBlocked: Boolean = false,
|
||||
val chatMembers: List<ChatMemberItem> = emptyList(),
|
||||
|
||||
Reference in New Issue
Block a user