Merge pull request #1265 from davotoula/1258-exlude-FileHeaderEvent-from-search-results

Exclude file header events from search results
This commit is contained in:
Vitor Pamplona 2025-01-30 14:46:55 -05:00 committed by GitHub
commit 78e5f5e277
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1845,6 +1845,21 @@ object LocalCache {
)
}
/**
* Will return true if supplied note is one of events to be excluded from
* search results.
*/
private fun excludeNoteEventFromSearchResults(note: Note): Boolean =
(
note.event is GenericRepostEvent ||
note.event is RepostEvent ||
note.event is CommunityPostApprovalEvent ||
note.event is ReactionEvent ||
note.event is LnZapEvent ||
note.event is LnZapRequestEvent ||
note.event is FileHeaderEvent
)
fun findNotesStartingWith(
text: String,
forAccount: Account,
@ -1855,19 +1870,13 @@ object LocalCache {
if (key != null) {
val note = getNoteIfExists(key)
if (note != null) {
if ((note != null) && !excludeNoteEventFromSearchResults(note)) {
return listOfNotNull(note)
}
}
return notes.filter { _, note ->
if (note.event is GenericRepostEvent ||
note.event is RepostEvent ||
note.event is CommunityPostApprovalEvent ||
note.event is ReactionEvent ||
note.event is LnZapEvent ||
note.event is LnZapRequestEvent
) {
if (excludeNoteEventFromSearchResults(note)) {
return@filter false
}
@ -1892,13 +1901,7 @@ object LocalCache {
return@filter false
} +
addressables.filter { _, addressable ->
if (addressable.event is GenericRepostEvent ||
addressable.event is RepostEvent ||
addressable.event is CommunityPostApprovalEvent ||
addressable.event is ReactionEvent ||
addressable.event is LnZapEvent ||
addressable.event is LnZapRequestEvent
) {
if (excludeNoteEventFromSearchResults(addressable)) {
return@filter false
}