extract logical expression for which notes to exclude from search results
This commit is contained in:
@@ -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(
|
fun findNotesStartingWith(
|
||||||
text: String,
|
text: String,
|
||||||
forAccount: Account,
|
forAccount: Account,
|
||||||
@@ -1855,30 +1870,13 @@ object LocalCache {
|
|||||||
|
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
val note = getNoteIfExists(key)
|
val note = getNoteIfExists(key)
|
||||||
if ((note != null) &&
|
if ((note != null) && !excludeNoteEventFromSearchResults(note)) {
|
||||||
!(
|
|
||||||
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
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return listOfNotNull(note)
|
return listOfNotNull(note)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return notes.filter { _, note ->
|
return notes.filter { _, note ->
|
||||||
if (note.event is GenericRepostEvent ||
|
if (excludeNoteEventFromSearchResults(note)) {
|
||||||
note.event is RepostEvent ||
|
|
||||||
note.event is CommunityPostApprovalEvent ||
|
|
||||||
note.event is ReactionEvent ||
|
|
||||||
note.event is LnZapEvent ||
|
|
||||||
note.event is LnZapRequestEvent ||
|
|
||||||
note.event is FileHeaderEvent
|
|
||||||
) {
|
|
||||||
return@filter false
|
return@filter false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1903,14 +1901,7 @@ object LocalCache {
|
|||||||
return@filter false
|
return@filter false
|
||||||
} +
|
} +
|
||||||
addressables.filter { _, addressable ->
|
addressables.filter { _, addressable ->
|
||||||
if (addressable.event is GenericRepostEvent ||
|
if (excludeNoteEventFromSearchResults(addressable)) {
|
||||||
addressable.event is RepostEvent ||
|
|
||||||
addressable.event is CommunityPostApprovalEvent ||
|
|
||||||
addressable.event is ReactionEvent ||
|
|
||||||
addressable.event is LnZapEvent ||
|
|
||||||
addressable.event is LnZapRequestEvent ||
|
|
||||||
addressable.event is FileHeaderEvent
|
|
||||||
) {
|
|
||||||
return@filter false
|
return@filter false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user