feat: add notification permission banner (#11)

Reviewed-on: #11
This commit was merged in pull request #11.
This commit is contained in:
2026-06-02 08:54:47 +00:00
parent ff383a7c6a
commit 71a8240b1d
4 changed files with 260 additions and 132 deletions

View File

@@ -40,6 +40,9 @@ class NostrViewModel(
private val nostr: Nostr,
private val secretStore: SecretStorage
) : ViewModel() {
private val _isNotificationBannerDismissed = MutableStateFlow(false)
val isNotificationBannerDismissed = _isNotificationBannerDismissed.asStateFlow()
private val _signerRequired = MutableStateFlow<Boolean?>(null)
val signerRequired = _signerRequired.asStateFlow()
@@ -72,6 +75,9 @@ class NostrViewModel(
private val seenPublicKeys = mutableSetOf<PublicKey>()
init {
// Check if the notification banner has been dismissed
checkNotificationBannerDismissedStatus()
// Check local stored secret (secret key or bunker)
login()
@@ -104,6 +110,13 @@ class NostrViewModel(
}
}
private fun checkNotificationBannerDismissedStatus() {
viewModelScope.launch {
_isNotificationBannerDismissed.value =
secretStore.get("notification_banner_dismissed") == "true"
}
}
private fun runObserver() {
viewModelScope.launch {
// Observe new messages
@@ -290,6 +303,13 @@ class NostrViewModel(
}
}
fun dismissNotificationBanner() {
viewModelScope.launch {
secretStore.set("notification_banner_dismissed", "true")
_isNotificationBannerDismissed.value = true
}
}
fun dismissRelayWarning() {
_isRelayListEmpty.value = false
}