Moves the filter for no subscriptions to the DAL
This commit is contained in:
@@ -52,8 +52,7 @@ open class DiscoverNIP89FeedFilter(
|
|||||||
|
|
||||||
val notes =
|
val notes =
|
||||||
LocalCache.addressables.filterIntoSet { _, it ->
|
LocalCache.addressables.filterIntoSet { _, it ->
|
||||||
val noteEvent = it.event
|
acceptDVM(it)
|
||||||
noteEvent is AppDefinitionEvent && filterParams.match(noteEvent) && noteEvent.includeKind("5300") && noteEvent.createdAt > TimeUtils.now() - lastAnnounced // && params.match(noteEvent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sort(notes)
|
return sort(notes)
|
||||||
@@ -72,12 +71,26 @@ open class DiscoverNIP89FeedFilter(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun innerApplyFilter(collection: Collection<Note>): Set<Note> {
|
fun acceptDVM(note: Note): Boolean {
|
||||||
val filterParams = buildFilterParams(account)
|
val noteEvent = note.event
|
||||||
|
return if (noteEvent is AppDefinitionEvent) {
|
||||||
|
acceptDVM(noteEvent)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun acceptDVM(noteEvent: AppDefinitionEvent): Boolean {
|
||||||
|
val filterParams = buildFilterParams(account)
|
||||||
|
return noteEvent.appMetaData()?.subscription != true &&
|
||||||
|
filterParams.match(noteEvent) &&
|
||||||
|
noteEvent.includeKind("5300") &&
|
||||||
|
noteEvent.createdAt > TimeUtils.now() - lastAnnounced // && params.match(noteEvent)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun innerApplyFilter(collection: Collection<Note>): Set<Note> {
|
||||||
return collection.filterTo(HashSet()) {
|
return collection.filterTo(HashSet()) {
|
||||||
val noteEvent = it.event
|
acceptDVM(it)
|
||||||
noteEvent is AppDefinitionEvent && filterParams.match(noteEvent) && noteEvent.includeKind("5300") && noteEvent.createdAt > TimeUtils.now() - lastAnnounced // && params.match(noteEvent)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -359,15 +359,6 @@ private fun DiscoverFeedLoaded(
|
|||||||
itemsIndexed(state.feed.value, key = { _, item -> item.idHex }) { _, item ->
|
itemsIndexed(state.feed.value, key = { _, item -> item.idHex }) { _, item ->
|
||||||
val defaultModifier = remember { Modifier.fillMaxWidth().animateItemPlacement() }
|
val defaultModifier = remember { Modifier.fillMaxWidth().animateItemPlacement() }
|
||||||
|
|
||||||
// TODO For now we avoid subscription based DVMs, as we need logic for these first if a user is not subscribed already.
|
|
||||||
var avoid = false
|
|
||||||
if (item.event is AppDefinitionEvent) {
|
|
||||||
if ((item.event as AppDefinitionEvent).appMetaData()?.subscription == true) {
|
|
||||||
avoid = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO End
|
|
||||||
if (!avoid) {
|
|
||||||
Row(defaultModifier) {
|
Row(defaultModifier) {
|
||||||
ChannelCardCompose(
|
ChannelCardCompose(
|
||||||
baseNote = item,
|
baseNote = item,
|
||||||
@@ -385,7 +376,6 @@ private fun DiscoverFeedLoaded(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
Reference in New Issue
Block a user