Fixes the check of the topnav fitler for global and relays
This commit is contained in:
@@ -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 {
|
||||
|
||||
+3
-1
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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)) &&
|
||||
|
||||
Reference in New Issue
Block a user