Fixes the check of the topnav fitler for global and relays

This commit is contained in:
Vitor Pamplona
2026-04-08 13:59:31 -04:00
parent eb5421ccb1
commit b05799a892
3 changed files with 28 additions and 18 deletions
@@ -47,36 +47,44 @@ class FilterByListParams(
fun hasExcessiveHashtags(noteEvent: Event) = hiddenLists.maxHashtagLimit > 0 && noteEvent.countHashtags() > hiddenLists.maxHashtagLimit fun hasExcessiveHashtags(noteEvent: Event) = hiddenLists.maxHashtagLimit > 0 && noteEvent.countHashtags() > hiddenLists.maxHashtagLimit
fun isEventInList(noteEvent: Event): Boolean {
if (followLists == null) return false
return followLists.match(noteEvent)
}
fun isAuthorInFollows(author: HexKey): Boolean { fun isAuthorInFollows(author: HexKey): Boolean {
if (followLists == null) return false if (followLists == null) return false
return followLists.matchAuthor(author) return followLists.matchAuthor(author)
} }
fun isAuthorInFollows(address: Address): Boolean { fun isGlobal() = followLists is GlobalTopNavFilter
private fun applyTopFilter(
comingFrom: List<NormalizedRelayUrl>,
noteEvent: Event,
): Boolean {
if (followLists == null) return false if (followLists == null) return false
return followLists.matchAuthor(address.pubKeyHex) return when (followLists) {
is GlobalTopNavFilter -> true
is RelayTopNavFilter -> comingFrom.contains(followLists.relayUrl)
else -> followLists.match(noteEvent)
}
} }
fun isGlobal(comingFrom: List<NormalizedRelayUrl>) = private fun applyTopFilter(
followLists is GlobalTopNavFilter && comingFrom: List<NormalizedRelayUrl>,
comingFrom.any { followLists.outboxRelays.value.contains(it) } address: Address,
): Boolean {
if (followLists == null) return false
fun isFromRelay(comingFrom: List<NormalizedRelayUrl>) = return when (followLists) {
followLists is RelayTopNavFilter && is GlobalTopNavFilter -> true
comingFrom.contains(followLists.relayUrl) is RelayTopNavFilter -> comingFrom.contains(followLists.relayUrl)
else -> followLists.matchAuthor(address.pubKeyHex)
}
}
fun match( fun match(
noteEvent: Event, noteEvent: Event,
comingFrom: List<NormalizedRelayUrl>, comingFrom: List<NormalizedRelayUrl>,
) = ((isGlobal(comingFrom)) || isFromRelay(comingFrom) || isEventInList(noteEvent)) && ) = (applyTopFilter(comingFrom, noteEvent)) &&
(isHiddenList || isNotHidden(noteEvent.pubKey)) && (isHiddenList || isNotHidden(noteEvent.pubKey)) &&
isNotInTheFuture(noteEvent) && isNotInTheFuture(noteEvent) &&
!hasExcessiveHashtags(noteEvent) !hasExcessiveHashtags(noteEvent)
@@ -85,7 +93,7 @@ class FilterByListParams(
address: Address?, address: Address?,
comingFrom: List<NormalizedRelayUrl>, comingFrom: List<NormalizedRelayUrl>,
) = address != null && ) = address != null &&
(isGlobal(comingFrom) || isFromRelay(comingFrom) || isAuthorInFollows(address)) && (applyTopFilter(comingFrom, address)) &&
(isHiddenList || isNotHidden(address.pubKeyHex)) (isHiddenList || isNotHidden(address.pubKeyHex))
companion object { companion object {
@@ -118,7 +118,7 @@ fun HomeScreen(
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav, nav: INav,
) { ) {
WatchAccountForHomeScreen(newThreadsFeedState, repliesFeedState, accountViewModel) WatchAccountForHomeScreen(liveFeedState, newThreadsFeedState, repliesFeedState, accountViewModel)
WatchLifecycleAndUpdateModel(liveFeedState) WatchLifecycleAndUpdateModel(liveFeedState)
WatchLifecycleAndUpdateModel(newThreadsFeedState) WatchLifecycleAndUpdateModel(newThreadsFeedState)
@@ -441,6 +441,7 @@ fun CrossfadeCheckIfVideoIsOnline(
@Composable @Composable
fun WatchAccountForHomeScreen( fun WatchAccountForHomeScreen(
liveFeedState: ChannelFeedContentState,
newThreadsFeedState: FeedContentState, newThreadsFeedState: FeedContentState,
repliesFeedState: FeedContentState, repliesFeedState: FeedContentState,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
@@ -450,6 +451,7 @@ fun WatchAccountForHomeScreen(
LaunchedEffect(accountViewModel, homeFollowList) { LaunchedEffect(accountViewModel, homeFollowList) {
newThreadsFeedState.checkKeysInvalidateDataAndSendToTop() newThreadsFeedState.checkKeysInvalidateDataAndSendToTop()
repliesFeedState.checkKeysInvalidateDataAndSendToTop() repliesFeedState.checkKeysInvalidateDataAndSendToTop()
liveFeedState.checkKeysInvalidateDataAndSendToTop()
} }
} }
@@ -194,7 +194,7 @@ class NotificationFeedFilter(
return noteEvent?.kind in NOTIFICATION_KINDS && return noteEvent?.kind in NOTIFICATION_KINDS &&
(noteEvent is LnZapEvent || notifAuthor != loggedInUserHex) && (noteEvent is LnZapEvent || notifAuthor != loggedInUserHex) &&
(isChessEvent || filterParams.isGlobal(it.relays) || notifAuthor == null || filterParams.isAuthorInFollows(notifAuthor)) && (isChessEvent || filterParams.isGlobal() || notifAuthor == null || filterParams.isAuthorInFollows(notifAuthor)) &&
noteEvent?.isTaggedUser(loggedInUserHex) ?: false && noteEvent?.isTaggedUser(loggedInUserHex) ?: false &&
(filterParams.isHiddenList || notifAuthor == null || !account.isHidden(notifAuthor)) && (filterParams.isHiddenList || notifAuthor == null || !account.isHidden(notifAuthor)) &&
(noteEvent !is PrivateDmEvent || !account.isDecryptedContentHidden(noteEvent)) && (noteEvent !is PrivateDmEvent || !account.isDecryptedContentHidden(noteEvent)) &&