From 7d0a234fd8bb3332162be2bfaed920efc513c4cd Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 6 Apr 2026 02:33:49 +0000 Subject: [PATCH 1/2] fix: remove expired polls from notification cards via periodic re-evaluation The open polls notification flow only re-evaluated when new notes arrived or dismissed IDs changed. Polls that passed their close date remained visible until something else triggered the flow. Adding a 1-minute ticker to the combine ensures expired polls are filtered out promptly. https://claude.ai/code/session_01VY9FRuzHzwTVrePaJiHuHx --- .../loggedIn/notifications/OpenPollsState.kt | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/OpenPollsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/OpenPollsState.kt index ee33578d4d..1629cc3e1a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/OpenPollsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/OpenPollsState.kt @@ -29,12 +29,14 @@ import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn +import kotlin.time.Duration.Companion.minutes @Stable class OpenPollsState( @@ -47,14 +49,23 @@ class OpenPollsState( authors = listOf(account.pubKey), ) + // Periodic ticker to re-evaluate polls after their close date passes + private val ticker = + flow { + while (true) { + emit(Unit) + delay(1.minutes) + } + } + val flow: StateFlow> = combine( account.cache - .observeNotes(filter) - .map { notes -> filterOpenPolls(notes) }, + .observeNotes(filter), account.settings.dismissedPollNoteIds, - ) { polls, dismissed -> - polls.filter { it.idHex !in dismissed } + ticker, + ) { notes, dismissed, _ -> + filterOpenPolls(notes).filter { it.idHex !in dismissed } }.flowOn(Dispatchers.IO) .stateIn( scope, From 7e32c314f442e2cc79bd155647944b5ad6ace123 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 6 Apr 2026 12:11:55 +0000 Subject: [PATCH 2/2] fix: change poll re-evaluation ticker from 1 minute to 1 hour https://claude.ai/code/session_01VY9FRuzHzwTVrePaJiHuHx --- .../ui/screen/loggedIn/notifications/OpenPollsState.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/OpenPollsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/OpenPollsState.kt index 1629cc3e1a..db7081eb8e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/OpenPollsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/OpenPollsState.kt @@ -36,7 +36,7 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.stateIn -import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.hours @Stable class OpenPollsState( @@ -54,7 +54,7 @@ class OpenPollsState( flow { while (true) { emit(Unit) - delay(1.minutes) + delay(1.hours) } }