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 isEventInList(noteEvent: Event): Boolean {
if (followLists == null) return false
return followLists.match(noteEvent)
}
fun isAuthorInFollows(author: HexKey): Boolean {
if (followLists == null) return false
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
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>) =
followLists is GlobalTopNavFilter &&
comingFrom.any { followLists.outboxRelays.value.contains(it) }
private fun applyTopFilter(
comingFrom: List<NormalizedRelayUrl>,
address: Address,
): Boolean {
if (followLists == null) return false
fun isFromRelay(comingFrom: List<NormalizedRelayUrl>) =
followLists is RelayTopNavFilter &&
comingFrom.contains(followLists.relayUrl)
return when (followLists) {
is GlobalTopNavFilter -> true
is RelayTopNavFilter -> comingFrom.contains(followLists.relayUrl)
else -> followLists.matchAuthor(address.pubKeyHex)
}
}
fun match(
noteEvent: Event,
comingFrom: List<NormalizedRelayUrl>,
) = ((isGlobal(comingFrom)) || isFromRelay(comingFrom) || isEventInList(noteEvent)) &&
) = (applyTopFilter(comingFrom, noteEvent)) &&
(isHiddenList || isNotHidden(noteEvent.pubKey)) &&
isNotInTheFuture(noteEvent) &&
!hasExcessiveHashtags(noteEvent)
@@ -85,7 +93,7 @@ class FilterByListParams(
address: Address?,
comingFrom: List<NormalizedRelayUrl>,
) = address != null &&
(isGlobal(comingFrom) || isFromRelay(comingFrom) || isAuthorInFollows(address)) &&
(applyTopFilter(comingFrom, address)) &&
(isHiddenList || isNotHidden(address.pubKeyHex))
companion object {
@@ -118,7 +118,7 @@ fun HomeScreen(
accountViewModel: AccountViewModel,
nav: INav,
) {
WatchAccountForHomeScreen(newThreadsFeedState, repliesFeedState, accountViewModel)
WatchAccountForHomeScreen(liveFeedState, newThreadsFeedState, repliesFeedState, accountViewModel)
WatchLifecycleAndUpdateModel(liveFeedState)
WatchLifecycleAndUpdateModel(newThreadsFeedState)
@@ -441,6 +441,7 @@ fun CrossfadeCheckIfVideoIsOnline(
@Composable
fun WatchAccountForHomeScreen(
liveFeedState: ChannelFeedContentState,
newThreadsFeedState: FeedContentState,
repliesFeedState: FeedContentState,
accountViewModel: AccountViewModel,
@@ -450,6 +451,7 @@ fun WatchAccountForHomeScreen(
LaunchedEffect(accountViewModel, homeFollowList) {
newThreadsFeedState.checkKeysInvalidateDataAndSendToTop()
repliesFeedState.checkKeysInvalidateDataAndSendToTop()
liveFeedState.checkKeysInvalidateDataAndSendToTop()
}
}
@@ -194,7 +194,7 @@ class NotificationFeedFilter(
return noteEvent?.kind in NOTIFICATION_KINDS &&
(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 &&
(filterParams.isHiddenList || notifAuthor == null || !account.isHidden(notifAuthor)) &&
(noteEvent !is PrivateDmEvent || !account.isDecryptedContentHidden(noteEvent)) &&