From b05799a892b3cd0e81f7166c3c19f39a7e36d4e5 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 8 Apr 2026 13:59:31 -0400 Subject: [PATCH] Fixes the check of the topnav fitler for global and relays --- .../amethyst/ui/dal/FilterByListParams.kt | 40 +++++++++++-------- .../ui/screen/loggedIn/home/HomeScreen.kt | 4 +- .../dal/NotificationFeedFilter.kt | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt index 580101cbf..86ed153ae 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt @@ -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, + 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) = - followLists is GlobalTopNavFilter && - comingFrom.any { followLists.outboxRelays.value.contains(it) } + private fun applyTopFilter( + comingFrom: List, + address: Address, + ): Boolean { + if (followLists == null) return false - fun isFromRelay(comingFrom: List) = - 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, - ) = ((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, ) = address != null && - (isGlobal(comingFrom) || isFromRelay(comingFrom) || isAuthorInFollows(address)) && + (applyTopFilter(comingFrom, address)) && (isHiddenList || isNotHidden(address.pubKeyHex)) companion object { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt index 9d0bcdb4a..4d3224403 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt @@ -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() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt index 6bcb32e14..70ee67990 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt @@ -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)) &&