chore: improve loading state handling #38

Merged
reya merged 3 commits from fix-loading-state into master 2026-07-07 04:09:29 +00:00
3 changed files with 3 additions and 4 deletions
Showing only changes of commit a76c8d117b - Show all commits

View File

@@ -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)
}
}

View File

@@ -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) }
}

View File

@@ -72,8 +72,6 @@ class NostrViewModel(private val nostr: Nostr) : BaseViewModel() {
private val metadataRequestChannel = Channel<PublicKey>(Channel.UNLIMITED)
private val seenPublicKeys = mutableSetOf<PublicKey>()
val isBusy = appState.map { it.isBusy }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), false)
val isRelayListEmpty = appState.map { it.isRelayListEmpty }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), false)