Dynamic filters for Longs, Shorts, Polls and Pictures
This commit is contained in:
@@ -226,6 +226,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.flow.debounce
|
import kotlinx.coroutines.flow.debounce
|
||||||
@@ -382,10 +383,9 @@ class Account(
|
|||||||
geohashCache = geohashListDecryptionCache,
|
geohashCache = geohashListDecryptionCache,
|
||||||
)
|
)
|
||||||
|
|
||||||
// App-ready Feeds
|
fun topNavFilterFlow(listName: MutableStateFlow<TopFilter>) =
|
||||||
val liveHomeFollowLists: StateFlow<IFeedTopNavFilter> =
|
|
||||||
FeedTopNavFilterState(
|
FeedTopNavFilterState(
|
||||||
feedFilterListName = settings.defaultHomeFollowList,
|
feedFilterListName = listName,
|
||||||
kind3Follows = kind3FollowList.flow,
|
kind3Follows = kind3FollowList.flow,
|
||||||
allFollows = allFollows.flow,
|
allFollows = allFollows.flow,
|
||||||
locationFlow = geolocationFlow,
|
locationFlow = geolocationFlow,
|
||||||
@@ -397,56 +397,31 @@ class Account(
|
|||||||
scope = scope,
|
scope = scope,
|
||||||
).flow
|
).flow
|
||||||
|
|
||||||
|
// App-ready Feeds
|
||||||
|
val liveHomeFollowLists: StateFlow<IFeedTopNavFilter> = topNavFilterFlow(settings.defaultHomeFollowList)
|
||||||
val liveHomeFollowListsPerRelay = OutboxLoaderState(liveHomeFollowLists, cache, scope).flow
|
val liveHomeFollowListsPerRelay = OutboxLoaderState(liveHomeFollowLists, cache, scope).flow
|
||||||
|
|
||||||
val liveStoriesFollowLists: StateFlow<IFeedTopNavFilter> =
|
val liveStoriesFollowLists: StateFlow<IFeedTopNavFilter> = topNavFilterFlow(settings.defaultStoriesFollowList)
|
||||||
FeedTopNavFilterState(
|
|
||||||
feedFilterListName = settings.defaultStoriesFollowList,
|
|
||||||
kind3Follows = kind3FollowList.flow,
|
|
||||||
allFollows = allFollows.flow,
|
|
||||||
locationFlow = geolocationFlow,
|
|
||||||
followsRelays = defaultGlobalRelays.flow,
|
|
||||||
blockedRelays = blockedRelayList.flow,
|
|
||||||
proxyRelays = proxyRelayList.flow,
|
|
||||||
caches = feedDecryptionCaches,
|
|
||||||
signer = signer,
|
|
||||||
scope = scope,
|
|
||||||
).flow
|
|
||||||
|
|
||||||
val liveStoriesFollowListsPerRelay = OutboxLoaderState(liveStoriesFollowLists, cache, scope).flow
|
val liveStoriesFollowListsPerRelay = OutboxLoaderState(liveStoriesFollowLists, cache, scope).flow
|
||||||
|
|
||||||
val liveDiscoveryFollowLists: StateFlow<IFeedTopNavFilter> =
|
val liveDiscoveryFollowLists: StateFlow<IFeedTopNavFilter> = topNavFilterFlow(settings.defaultDiscoveryFollowList)
|
||||||
FeedTopNavFilterState(
|
|
||||||
feedFilterListName = settings.defaultDiscoveryFollowList,
|
|
||||||
kind3Follows = kind3FollowList.flow,
|
|
||||||
allFollows = allFollows.flow,
|
|
||||||
locationFlow = geolocationFlow,
|
|
||||||
followsRelays = defaultGlobalRelays.flow,
|
|
||||||
blockedRelays = blockedRelayList.flow,
|
|
||||||
proxyRelays = proxyRelayList.flow,
|
|
||||||
caches = feedDecryptionCaches,
|
|
||||||
signer = signer,
|
|
||||||
scope = scope,
|
|
||||||
).flow
|
|
||||||
|
|
||||||
val liveDiscoveryFollowListsPerRelay = OutboxLoaderState(liveDiscoveryFollowLists, cache, scope).flow
|
val liveDiscoveryFollowListsPerRelay = OutboxLoaderState(liveDiscoveryFollowLists, cache, scope).flow
|
||||||
|
|
||||||
val liveNotificationFollowLists: StateFlow<IFeedTopNavFilter> =
|
val liveNotificationFollowLists: StateFlow<IFeedTopNavFilter> = topNavFilterFlow(settings.defaultNotificationFollowList)
|
||||||
FeedTopNavFilterState(
|
|
||||||
feedFilterListName = settings.defaultNotificationFollowList,
|
|
||||||
kind3Follows = kind3FollowList.flow,
|
|
||||||
allFollows = allFollows.flow,
|
|
||||||
locationFlow = geolocationFlow,
|
|
||||||
followsRelays = defaultGlobalRelays.flow,
|
|
||||||
blockedRelays = blockedRelayList.flow,
|
|
||||||
proxyRelays = proxyRelayList.flow,
|
|
||||||
caches = feedDecryptionCaches,
|
|
||||||
signer = signer,
|
|
||||||
scope = scope,
|
|
||||||
).flow
|
|
||||||
|
|
||||||
val liveNotificationFollowListsPerRelay = OutboxLoaderState(liveNotificationFollowLists, cache, scope).flow
|
val liveNotificationFollowListsPerRelay = OutboxLoaderState(liveNotificationFollowLists, cache, scope).flow
|
||||||
|
|
||||||
|
val livePollsFollowLists: StateFlow<IFeedTopNavFilter> = topNavFilterFlow(settings.defaultPollsFollowList)
|
||||||
|
val livePollsFollowListsPerRelay = OutboxLoaderState(livePollsFollowLists, cache, scope).flow
|
||||||
|
|
||||||
|
val livePicturesFollowLists: StateFlow<IFeedTopNavFilter> = topNavFilterFlow(settings.defaultPicturesFollowList)
|
||||||
|
val livePicturesFollowListsPerRelay = OutboxLoaderState(livePicturesFollowLists, cache, scope).flow
|
||||||
|
|
||||||
|
val liveShortsFollowLists: StateFlow<IFeedTopNavFilter> = topNavFilterFlow(settings.defaultShortsFollowList)
|
||||||
|
val liveShortsFollowListsPerRelay = OutboxLoaderState(liveShortsFollowLists, cache, scope).flow
|
||||||
|
|
||||||
|
val liveLongsFollowLists: StateFlow<IFeedTopNavFilter> = topNavFilterFlow(settings.defaultLongsFollowList)
|
||||||
|
val liveLongsFollowListsPerRelay = OutboxLoaderState(liveLongsFollowLists, cache, scope).flow
|
||||||
|
|
||||||
override fun isWriteable(): Boolean = settings.isWriteable()
|
override fun isWriteable(): Boolean = settings.isWriteable()
|
||||||
|
|
||||||
suspend fun updateWarnReports(warnReports: Boolean): Boolean {
|
suspend fun updateWarnReports(warnReports: Boolean): Boolean {
|
||||||
|
|||||||
@@ -325,6 +325,50 @@ class AccountSettings(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun changeDefaultPollsFollowList(name: FeedDefinition) {
|
||||||
|
changeDefaultPollsFollowList(name.code)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeDefaultPollsFollowList(name: TopFilter) {
|
||||||
|
if (defaultPollsFollowList.value != name) {
|
||||||
|
defaultPollsFollowList.tryEmit(name)
|
||||||
|
saveAccountSettings()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeDefaultPicturesFollowList(name: FeedDefinition) {
|
||||||
|
changeDefaultPicturesFollowList(name.code)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeDefaultPicturesFollowList(name: TopFilter) {
|
||||||
|
if (defaultPicturesFollowList.value != name) {
|
||||||
|
defaultPicturesFollowList.tryEmit(name)
|
||||||
|
saveAccountSettings()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeDefaultShortsFollowList(name: FeedDefinition) {
|
||||||
|
changeDefaultShortsFollowList(name.code)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeDefaultShortsFollowList(name: TopFilter) {
|
||||||
|
if (defaultShortsFollowList.value != name) {
|
||||||
|
defaultShortsFollowList.tryEmit(name)
|
||||||
|
saveAccountSettings()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeDefaultLongsFollowList(name: FeedDefinition) {
|
||||||
|
changeDefaultLongsFollowList(name.code)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeDefaultLongsFollowList(name: TopFilter) {
|
||||||
|
if (defaultLongsFollowList.value != name) {
|
||||||
|
defaultLongsFollowList.tryEmit(name)
|
||||||
|
saveAccountSettings()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
// language services
|
// language services
|
||||||
// ---
|
// ---
|
||||||
|
|||||||
+1
-1
@@ -107,7 +107,7 @@ fun WatchAccountForLongsScreen(
|
|||||||
videoFeedState: FeedContentState,
|
videoFeedState: FeedContentState,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
) {
|
) {
|
||||||
val listState by accountViewModel.account.liveDiscoveryFollowLists.collectAsStateWithLifecycle()
|
val listState by accountViewModel.account.liveLongsFollowLists.collectAsStateWithLifecycle()
|
||||||
val hiddenUsers =
|
val hiddenUsers =
|
||||||
accountViewModel.account.hiddenUsers.flow
|
accountViewModel.account.hiddenUsers.flow
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ fun LongsTopBar(
|
|||||||
followListsModel = accountViewModel.feedStates.feedListOptions,
|
followListsModel = accountViewModel.feedStates.feedListOptions,
|
||||||
listName = list,
|
listName = list,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onChange = accountViewModel.account.settings::changeDefaultDiscoveryFollowList,
|
onChange = accountViewModel.account.settings::changeDefaultLongsFollowList,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ class LongsFeedFilter(
|
|||||||
|
|
||||||
fun buildFilterParams(account: Account): FilterByListParams =
|
fun buildFilterParams(account: Account): FilterByListParams =
|
||||||
FilterByListParams.create(
|
FilterByListParams.create(
|
||||||
account.liveDiscoveryFollowLists.value,
|
account.liveLongsFollowLists.value,
|
||||||
account.hiddenUsers.flow.value,
|
account.hiddenUsers.flow.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ class LongsSubAssembler(
|
|||||||
|
|
||||||
fun LongsQueryState.listName() = listNameFlow().value
|
fun LongsQueryState.listName() = listNameFlow().value
|
||||||
|
|
||||||
fun LongsQueryState.followsPerRelayFlow() = account.liveDiscoveryFollowListsPerRelay
|
fun LongsQueryState.followsPerRelayFlow() = account.liveLongsFollowListsPerRelay
|
||||||
|
|
||||||
fun LongsQueryState.followsPerRelay() = followsPerRelayFlow().value
|
fun LongsQueryState.followsPerRelay() = followsPerRelayFlow().value
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -107,7 +107,7 @@ fun WatchAccountForPicturesScreen(
|
|||||||
picturesFeedContentState: FeedContentState,
|
picturesFeedContentState: FeedContentState,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
) {
|
) {
|
||||||
val listState by accountViewModel.account.liveDiscoveryFollowLists.collectAsStateWithLifecycle()
|
val listState by accountViewModel.account.livePicturesFollowLists.collectAsStateWithLifecycle()
|
||||||
val hiddenUsers =
|
val hiddenUsers =
|
||||||
accountViewModel.account.hiddenUsers.flow
|
accountViewModel.account.hiddenUsers.flow
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ fun PicturesTopBar(
|
|||||||
followListsModel = accountViewModel.feedStates.feedListOptions,
|
followListsModel = accountViewModel.feedStates.feedListOptions,
|
||||||
listName = list,
|
listName = list,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onChange = accountViewModel.account.settings::changeDefaultDiscoveryFollowList,
|
onChange = accountViewModel.account.settings::changeDefaultPicturesFollowList,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ class PictureFeedFilter(
|
|||||||
|
|
||||||
fun buildFilterParams(account: Account): FilterByListParams =
|
fun buildFilterParams(account: Account): FilterByListParams =
|
||||||
FilterByListParams.create(
|
FilterByListParams.create(
|
||||||
account.liveDiscoveryFollowLists.value,
|
account.livePicturesFollowLists.value,
|
||||||
account.hiddenUsers.flow.value,
|
account.hiddenUsers.flow.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ class PicturesSubAssembler(
|
|||||||
|
|
||||||
fun PicturesQueryState.listName() = listNameFlow().value
|
fun PicturesQueryState.listName() = listNameFlow().value
|
||||||
|
|
||||||
fun PicturesQueryState.followsPerRelayFlow() = account.liveDiscoveryFollowListsPerRelay
|
fun PicturesQueryState.followsPerRelayFlow() = account.livePicturesFollowListsPerRelay
|
||||||
|
|
||||||
fun PicturesQueryState.followsPerRelay() = followsPerRelayFlow().value
|
fun PicturesQueryState.followsPerRelay() = followsPerRelayFlow().value
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ fun WatchAccountForPollsScreen(
|
|||||||
pollsFeedContentState: FeedContentState,
|
pollsFeedContentState: FeedContentState,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
) {
|
) {
|
||||||
val listState by accountViewModel.account.liveDiscoveryFollowLists.collectAsStateWithLifecycle()
|
val listState by accountViewModel.account.livePollsFollowLists.collectAsStateWithLifecycle()
|
||||||
val hiddenUsers =
|
val hiddenUsers =
|
||||||
accountViewModel.account.hiddenUsers.flow
|
accountViewModel.account.hiddenUsers.flow
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ fun PollsTopBar(
|
|||||||
followListsModel = accountViewModel.feedStates.feedListOptions,
|
followListsModel = accountViewModel.feedStates.feedListOptions,
|
||||||
listName = list,
|
listName = list,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onChange = accountViewModel.account.settings::changeDefaultDiscoveryFollowList,
|
onChange = accountViewModel.account.settings::changeDefaultPollsFollowList,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ class PollsFeedFilter(
|
|||||||
|
|
||||||
fun buildFilterParams(account: Account): FilterByListParams =
|
fun buildFilterParams(account: Account): FilterByListParams =
|
||||||
FilterByListParams.create(
|
FilterByListParams.create(
|
||||||
account.liveDiscoveryFollowLists.value,
|
account.livePollsFollowLists.value,
|
||||||
account.hiddenUsers.flow.value,
|
account.hiddenUsers.flow.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ class PollsSubAssembler(
|
|||||||
|
|
||||||
fun PollsQueryState.listName() = listNameFlow().value
|
fun PollsQueryState.listName() = listNameFlow().value
|
||||||
|
|
||||||
fun PollsQueryState.followsPerRelayFlow() = account.liveDiscoveryFollowListsPerRelay
|
fun PollsQueryState.followsPerRelayFlow() = account.livePollsFollowListsPerRelay
|
||||||
|
|
||||||
fun PollsQueryState.followsPerRelay() = followsPerRelayFlow().value
|
fun PollsQueryState.followsPerRelay() = followsPerRelayFlow().value
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -107,7 +107,7 @@ fun WatchAccountForShortsScreen(
|
|||||||
videoFeedState: FeedContentState,
|
videoFeedState: FeedContentState,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
) {
|
) {
|
||||||
val listState by accountViewModel.account.liveDiscoveryFollowLists.collectAsStateWithLifecycle()
|
val listState by accountViewModel.account.liveShortsFollowLists.collectAsStateWithLifecycle()
|
||||||
val hiddenUsers =
|
val hiddenUsers =
|
||||||
accountViewModel.account.hiddenUsers.flow
|
accountViewModel.account.hiddenUsers.flow
|
||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ fun ShortsTopBar(
|
|||||||
followListsModel = accountViewModel.feedStates.feedListOptions,
|
followListsModel = accountViewModel.feedStates.feedListOptions,
|
||||||
listName = list,
|
listName = list,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onChange = accountViewModel.account.settings::changeDefaultDiscoveryFollowList,
|
onChange = accountViewModel.account.settings::changeDefaultShortsFollowList,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ class ShortsFeedFilter(
|
|||||||
|
|
||||||
fun buildFilterParams(account: Account): FilterByListParams =
|
fun buildFilterParams(account: Account): FilterByListParams =
|
||||||
FilterByListParams.create(
|
FilterByListParams.create(
|
||||||
account.liveDiscoveryFollowLists.value,
|
account.liveShortsFollowLists.value,
|
||||||
account.hiddenUsers.flow.value,
|
account.hiddenUsers.flow.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ class ShortsSubAssembler(
|
|||||||
|
|
||||||
fun ShortsQueryState.listName() = listNameFlow().value
|
fun ShortsQueryState.listName() = listNameFlow().value
|
||||||
|
|
||||||
fun ShortsQueryState.followsPerRelayFlow() = account.liveDiscoveryFollowListsPerRelay
|
fun ShortsQueryState.followsPerRelayFlow() = account.liveShortsFollowListsPerRelay
|
||||||
|
|
||||||
fun ShortsQueryState.followsPerRelay() = followsPerRelayFlow().value
|
fun ShortsQueryState.followsPerRelay() = followsPerRelayFlow().value
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user