Finishing up the Poll Screen

This commit is contained in:
Vitor Pamplona
2026-03-28 17:12:51 -04:00
parent 20eb95ae57
commit 485ed871d1
6 changed files with 25 additions and 14 deletions
@@ -20,9 +20,12 @@
*/
package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.commons.ui.feeds.FeedContentState
import com.vitorpamplona.amethyst.ui.feeds.RefresheableBox
@@ -74,16 +77,18 @@ fun PollsScreen(
}
},
accountViewModel = accountViewModel,
) {
RefresheableBox(pollsFeedContentState, true) {
SaveableFeedContentState(pollsFeedContentState, scrollStateKey = ScrollStateKeys.POLLS_SCREEN) { listState ->
RenderFeedContentState(
feedContentState = pollsFeedContentState,
accountViewModel = accountViewModel,
listState = listState,
nav = nav,
routeForLastRead = "PollsFeed",
)
) { paddingValues ->
Column(Modifier.padding(paddingValues)) {
RefresheableBox(pollsFeedContentState, true) {
SaveableFeedContentState(pollsFeedContentState, scrollStateKey = ScrollStateKeys.POLLS_SCREEN) { listState ->
RenderFeedContentState(
feedContentState = pollsFeedContentState,
accountViewModel = accountViewModel,
listState = listState,
nav = nav,
routeForLastRead = "PollsFeed",
)
}
}
}
}
@@ -28,6 +28,7 @@ import com.vitorpamplona.amethyst.model.filterIntoSet
import com.vitorpamplona.amethyst.ui.dal.AdditiveFeedFilter
import com.vitorpamplona.amethyst.ui.dal.DefaultFeedOrder
import com.vitorpamplona.amethyst.ui.dal.FilterByListParams
import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent
import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent
class PollsFeedFilter(
@@ -52,7 +53,7 @@ class PollsFeedFilter(
val notes =
LocalCache.notes.filterIntoSet { _, it ->
val noteEvent = it.event
noteEvent is PollEvent && params.match(noteEvent, it.relays)
(noteEvent is PollEvent || noteEvent is ZapPollEvent) && params.match(noteEvent, it.relays)
}
return sort(notes)
}
@@ -20,6 +20,7 @@
*/
package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource
import androidx.compose.runtime.Stable
import com.vitorpamplona.amethyst.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager
import com.vitorpamplona.amethyst.model.Account
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates
@@ -32,6 +33,7 @@ class PollsQueryState(
val scope: CoroutineScope,
)
@Stable
class PollsFilterAssembler(
client: INostrClient,
) : ComposeSubscriptionManager<PollsQueryState>() {
@@ -23,6 +23,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemb
import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet
import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
@@ -41,7 +42,7 @@ fun filterPollsByAuthors(
filter =
Filter(
authors = authorList,
kinds = listOf(PollEvent.KIND),
kinds = listOf(PollEvent.KIND, ZapPollEvent.KIND),
limit = 200,
since = since,
),
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemb
import com.vitorpamplona.amethyst.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@@ -37,7 +38,7 @@ fun filterPollsByHashtag(
relay = relay,
filter =
Filter(
kinds = listOf(PollEvent.KIND),
kinds = listOf(PollEvent.KIND, ZapPollEvent.KIND),
tags = mapOf("t" to hashtags.toList()),
limit = 200,
since = since,
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource.subassemb
import com.vitorpamplona.amethyst.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent
@@ -40,7 +41,7 @@ fun filterPollsGlobal(
relay = it.key,
filter =
Filter(
kinds = listOf(PollEvent.KIND),
kinds = listOf(PollEvent.KIND, ZapPollEvent.KIND),
limit = 200,
since = since,
),