feat: implement basic notification #6

Merged
reya merged 6 commits from feat/notifications into master 2026-05-29 06:56:48 +00:00
Showing only changes of commit e2f4b454b9 - Show all commits

View File

@@ -109,9 +109,7 @@ class NostrViewModel(
}, },
onSubscriptionClose = { onSubscriptionClose = {
getChatRooms() getChatRooms()
if (!_isPartialProcessedGiftWrap.value) { _isPartialProcessedGiftWrap.value = true
_isPartialProcessedGiftWrap.value = true
}
}, },
onNewMessage = { event -> onNewMessage = { event ->
viewModelScope.launch { viewModelScope.launch {
@@ -178,7 +176,9 @@ class NostrViewModel(
val results = nostr.getAllCacheMetadata() val results = nostr.getAllCacheMetadata()
results.forEach { (pubkey, metadata) -> results.forEach { (pubkey, metadata) ->
// Update the metadata state
updateMetadata(pubkey, metadata) updateMetadata(pubkey, metadata)
// Update seenPublicKeys to avoid duplicate requests
seenPublicKeys.add(pubkey) seenPublicKeys.add(pubkey)
} }
} }
@@ -193,15 +193,14 @@ class NostrViewModel(
val secret = secretStore.get("user_signer") val secret = secretStore.get("user_signer")
// If no secret is found, show onboarding screen // If no secret is found, show onboarding screen
when (secret) { if (secret == null) {
null -> { _emptySecret.value = true
_emptySecret.value = true return@launch
return@launch
}
else -> _emptySecret.value = false
} }
// Update the empty secret state
_emptySecret.value = false
// Handle different signer types // Handle different signer types
if (secret.startsWith("nsec1")) { if (secret.startsWith("nsec1")) {
val keys = Keys.parse(secret) val keys = Keys.parse(secret)
@@ -229,11 +228,22 @@ class NostrViewModel(
val pubkey = nostr.signer.currentUser val pubkey = nostr.signer.currentUser
if (pubkey != null) { if (pubkey != null) {
// Get chat rooms
val rooms = nostr.getChatRooms() ?: emptySet()
if (rooms.isNotEmpty()) {
_chatRooms.value = rooms
_isPartialProcessedGiftWrap.value = true
}
// Small delay to ensure all relays are connected
delay(3000) delay(3000)
// Check if the relay list is empty
val relays = nostr.getMsgRelays(pubkey) val relays = nostr.getMsgRelays(pubkey)
if (relays.isEmpty()) { if (relays.isEmpty()) {
_isRelayListEmpty.value = true _isRelayListEmpty.value = true
} }
break break
} }