Adds a cache layer for citations in Notes
This commit is contained in:
@@ -19,6 +19,7 @@ open class BaseTextNoteEvent(
|
|||||||
open fun replyTos() = tags.filter { it.firstOrNull() == "e" }.mapNotNull { it.getOrNull(1) }
|
open fun replyTos() = tags.filter { it.firstOrNull() == "e" }.mapNotNull { it.getOrNull(1) }
|
||||||
|
|
||||||
private var citedUsersCache: Set<HexKey>? = null
|
private var citedUsersCache: Set<HexKey>? = null
|
||||||
|
private var citedNotesCache: Set<HexKey>? = null
|
||||||
|
|
||||||
fun citedUsers(): Set<HexKey> {
|
fun citedUsers(): Set<HexKey> {
|
||||||
citedUsersCache?.let { return it }
|
citedUsersCache?.let { return it }
|
||||||
@@ -61,8 +62,10 @@ open class BaseTextNoteEvent(
|
|||||||
return returningList
|
return returningList
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findCitations(): Set<String> {
|
fun findCitations(): Set<HexKey> {
|
||||||
var citations = mutableSetOf<String>()
|
citedNotesCache?.let { return it }
|
||||||
|
|
||||||
|
val citations = mutableSetOf<HexKey>()
|
||||||
// Removes citations from replies:
|
// Removes citations from replies:
|
||||||
val matcher = tagSearch.matcher(content)
|
val matcher = tagSearch.matcher(content)
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
@@ -102,6 +105,7 @@ open class BaseTextNoteEvent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
citedNotesCache = citations
|
||||||
return citations
|
return citations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user