From 8b6be70c4165b97ec2024fa3791e8ba4b76d38f8 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Tue, 2 Jun 2026 15:25:29 +0700 Subject: [PATCH] add dismiss notification banner --- .../kotlin/su/reya/coop/screens/HomeScreen.kt | 5 +++-- .../kotlin/su/reya/coop/NostrViewModel.kt | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/HomeScreen.kt b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/HomeScreen.kt index 6016d51..7dfd11a 100644 --- a/composeApp/src/androidMain/kotlin/su/reya/coop/screens/HomeScreen.kt +++ b/composeApp/src/androidMain/kotlin/su/reya/coop/screens/HomeScreen.kt @@ -111,6 +111,7 @@ fun HomeScreen() { val userProfile by currentUserProfile.collectAsState(initial = null) val chatRooms by viewModel.chatRooms.collectAsState(initial = emptyList()) val isPartialProcessedGiftWrap by viewModel.isPartialProcessedGiftWrap.collectAsState(initial = false) + val isBannerDismissed by viewModel.isNotificationBannerDismissed.collectAsState() val scope = rememberCoroutineScope() val sheetState = rememberModalBottomSheetState() @@ -221,7 +222,7 @@ fun HomeScreen() { modifier = Modifier.padding(top = innerPadding.calculateTopPadding()), verticalArrangement = Arrangement.spacedBy(16.dp), ) { - if (!isNotificationEnabled) { + if (!isNotificationEnabled && !isBannerDismissed) { Surface( modifier = Modifier .fillMaxWidth() @@ -253,7 +254,7 @@ fun HomeScreen() { horizontalArrangement = Arrangement.spacedBy(8.dp), ) { TextButton( - onClick = { }, + onClick = { viewModel.dismissNotificationBanner() }, modifier = Modifier.weight(1f), ) { Text(text = "Maybe later") diff --git a/shared/src/commonMain/kotlin/su/reya/coop/NostrViewModel.kt b/shared/src/commonMain/kotlin/su/reya/coop/NostrViewModel.kt index 91d669b..751ab71 100644 --- a/shared/src/commonMain/kotlin/su/reya/coop/NostrViewModel.kt +++ b/shared/src/commonMain/kotlin/su/reya/coop/NostrViewModel.kt @@ -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(null) val signerRequired = _signerRequired.asStateFlow() @@ -72,6 +75,9 @@ class NostrViewModel( private val seenPublicKeys = mutableSetOf() 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 }