From a76c8d117b4f1d390856619aa0b39fbf92836e21 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Tue, 7 Jul 2026 08:27:25 +0700 Subject: [PATCH] fix syncing state --- shared/src/commonMain/kotlin/su/reya/coop/nostr/Nostr.kt | 1 + .../commonMain/kotlin/su/reya/coop/viewmodel/ChatViewModel.kt | 2 +- .../kotlin/su/reya/coop/viewmodel/NostrViewModel.kt | 4 +--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/shared/src/commonMain/kotlin/su/reya/coop/nostr/Nostr.kt b/shared/src/commonMain/kotlin/su/reya/coop/nostr/Nostr.kt index 4483ba0..be4f84a 100644 --- a/shared/src/commonMain/kotlin/su/reya/coop/nostr/Nostr.kt +++ b/shared/src/commonMain/kotlin/su/reya/coop/nostr/Nostr.kt @@ -219,6 +219,7 @@ class Nostr { KindStandard.INBOX_RELAYS -> { // Get all gift wrap events for the current user if (isSignedByUser(event = event)) { + messages.updateSyncState { it.copy(isSyncing = true) } messages.getUserMessages(msgRelayList = event) } } diff --git a/shared/src/commonMain/kotlin/su/reya/coop/viewmodel/ChatViewModel.kt b/shared/src/commonMain/kotlin/su/reya/coop/viewmodel/ChatViewModel.kt index e848f5f..baee6b6 100644 --- a/shared/src/commonMain/kotlin/su/reya/coop/viewmodel/ChatViewModel.kt +++ b/shared/src/commonMain/kotlin/su/reya/coop/viewmodel/ChatViewModel.kt @@ -65,7 +65,7 @@ class ChatViewModel(private val nostr: Nostr) : BaseViewModel() { launch { nostr.messages.messageSyncState.collect { syncState -> // When at least some messages are processed, allow UI to show the list - if (syncState.processedCount > 0) { + if (syncState.processedCount > 0 || !syncState.isSyncing) { _state.update { it.copy(isPartialProcessedGiftWrap = true) } } diff --git a/shared/src/commonMain/kotlin/su/reya/coop/viewmodel/NostrViewModel.kt b/shared/src/commonMain/kotlin/su/reya/coop/viewmodel/NostrViewModel.kt index 5fb8c89..4c02d66 100644 --- a/shared/src/commonMain/kotlin/su/reya/coop/viewmodel/NostrViewModel.kt +++ b/shared/src/commonMain/kotlin/su/reya/coop/viewmodel/NostrViewModel.kt @@ -71,9 +71,7 @@ class NostrViewModel(private val nostr: Nostr) : BaseViewModel() { private val profiles = mutableMapOf>() private val metadataRequestChannel = Channel(Channel.UNLIMITED) private val seenPublicKeys = mutableSetOf() - - val isBusy = appState.map { it.isBusy } - .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), false) + val isRelayListEmpty = appState.map { it.isRelayListEmpty } .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), false)