Finishing up the Poll Screen
This commit is contained in:
+15
-10
@@ -20,9 +20,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls
|
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.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.vitorpamplona.amethyst.commons.ui.feeds.FeedContentState
|
import com.vitorpamplona.amethyst.commons.ui.feeds.FeedContentState
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.RefresheableBox
|
import com.vitorpamplona.amethyst.ui.feeds.RefresheableBox
|
||||||
@@ -74,16 +77,18 @@ fun PollsScreen(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
) {
|
) { paddingValues ->
|
||||||
RefresheableBox(pollsFeedContentState, true) {
|
Column(Modifier.padding(paddingValues)) {
|
||||||
SaveableFeedContentState(pollsFeedContentState, scrollStateKey = ScrollStateKeys.POLLS_SCREEN) { listState ->
|
RefresheableBox(pollsFeedContentState, true) {
|
||||||
RenderFeedContentState(
|
SaveableFeedContentState(pollsFeedContentState, scrollStateKey = ScrollStateKeys.POLLS_SCREEN) { listState ->
|
||||||
feedContentState = pollsFeedContentState,
|
RenderFeedContentState(
|
||||||
accountViewModel = accountViewModel,
|
feedContentState = pollsFeedContentState,
|
||||||
listState = listState,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
listState = listState,
|
||||||
routeForLastRead = "PollsFeed",
|
nav = nav,
|
||||||
)
|
routeForLastRead = "PollsFeed",
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -28,6 +28,7 @@ import com.vitorpamplona.amethyst.model.filterIntoSet
|
|||||||
import com.vitorpamplona.amethyst.ui.dal.AdditiveFeedFilter
|
import com.vitorpamplona.amethyst.ui.dal.AdditiveFeedFilter
|
||||||
import com.vitorpamplona.amethyst.ui.dal.DefaultFeedOrder
|
import com.vitorpamplona.amethyst.ui.dal.DefaultFeedOrder
|
||||||
import com.vitorpamplona.amethyst.ui.dal.FilterByListParams
|
import com.vitorpamplona.amethyst.ui.dal.FilterByListParams
|
||||||
|
import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent
|
||||||
import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent
|
import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent
|
||||||
|
|
||||||
class PollsFeedFilter(
|
class PollsFeedFilter(
|
||||||
@@ -52,7 +53,7 @@ class PollsFeedFilter(
|
|||||||
val notes =
|
val notes =
|
||||||
LocalCache.notes.filterIntoSet { _, it ->
|
LocalCache.notes.filterIntoSet { _, it ->
|
||||||
val noteEvent = it.event
|
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)
|
return sort(notes)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.polls.datasource
|
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.commons.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountFeedContentStates
|
||||||
@@ -32,6 +33,7 @@ class PollsQueryState(
|
|||||||
val scope: CoroutineScope,
|
val scope: CoroutineScope,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Stable
|
||||||
class PollsFilterAssembler(
|
class PollsFilterAssembler(
|
||||||
client: INostrClient,
|
client: INostrClient,
|
||||||
) : ComposeSubscriptionManager<PollsQueryState>() {
|
) : ComposeSubscriptionManager<PollsQueryState>() {
|
||||||
|
|||||||
+2
-1
@@ -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.author.AuthorsTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet
|
import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
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.core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
|
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||||
@@ -41,7 +42,7 @@ fun filterPollsByAuthors(
|
|||||||
filter =
|
filter =
|
||||||
Filter(
|
Filter(
|
||||||
authors = authorList,
|
authors = authorList,
|
||||||
kinds = listOf(PollEvent.KIND),
|
kinds = listOf(PollEvent.KIND, ZapPollEvent.KIND),
|
||||||
limit = 200,
|
limit = 200,
|
||||||
since = since,
|
since = since,
|
||||||
),
|
),
|
||||||
|
|||||||
+2
-1
@@ -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.model.topNavFeeds.hashtag.HashtagTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
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.client.pool.RelayBasedFilter
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||||
@@ -37,7 +38,7 @@ fun filterPollsByHashtag(
|
|||||||
relay = relay,
|
relay = relay,
|
||||||
filter =
|
filter =
|
||||||
Filter(
|
Filter(
|
||||||
kinds = listOf(PollEvent.KIND),
|
kinds = listOf(PollEvent.KIND, ZapPollEvent.KIND),
|
||||||
tags = mapOf("t" to hashtags.toList()),
|
tags = mapOf("t" to hashtags.toList()),
|
||||||
limit = 200,
|
limit = 200,
|
||||||
since = since,
|
since = since,
|
||||||
|
|||||||
+2
-1
@@ -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.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet
|
||||||
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
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.client.pool.RelayBasedFilter
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||||
import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent
|
import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent
|
||||||
@@ -40,7 +41,7 @@ fun filterPollsGlobal(
|
|||||||
relay = it.key,
|
relay = it.key,
|
||||||
filter =
|
filter =
|
||||||
Filter(
|
Filter(
|
||||||
kinds = listOf(PollEvent.KIND),
|
kinds = listOf(PollEvent.KIND, ZapPollEvent.KIND),
|
||||||
limit = 200,
|
limit = 200,
|
||||||
since = since,
|
since = since,
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user