mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-26 17:52:29 +01:00
Refactoring
This commit is contained in:
parent
b785e0d505
commit
cafad6a003
@ -209,13 +209,13 @@ object LocalCache {
|
||||
} as LatestByKindAndAuthor<T>
|
||||
}
|
||||
|
||||
fun updateObservables(event: Event) {
|
||||
val observablesOfKind = observablesByKindAndETag[event.kind()] ?: return
|
||||
private fun updateObservables(event: Event) {
|
||||
val observablesOfKind = observablesByKindAndETag[event.kind] ?: return
|
||||
event.forEachTaggedEvent {
|
||||
observablesOfKind[it]?.updateIfMatches(event)
|
||||
}
|
||||
|
||||
observablesByKindAndAuthor[event.kind()]?.get(event.pubKey)?.updateIfMatches(event)
|
||||
observablesByKindAndAuthor[event.kind]?.get(event.pubKey)?.updateIfMatches(event)
|
||||
}
|
||||
|
||||
fun checkGetOrCreateUser(key: String): User? {
|
||||
|
@ -30,8 +30,8 @@ import com.vitorpamplona.quartz.encoders.HexKey
|
||||
import com.vitorpamplona.quartz.events.Event
|
||||
import com.vitorpamplona.quartz.events.EventInterface
|
||||
import com.vitorpamplona.quartz.events.RelayAuthEvent
|
||||
import com.vitorpamplona.quartz.events.bytesUsedInMemory
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
import com.vitorpamplona.quartz.utils.bytesUsedInMemory
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
|
@ -193,8 +193,7 @@ open class BaseTextNoteEvent(
|
||||
val repliesTo = replyTos()
|
||||
val tagAddresses =
|
||||
taggedAddresses().filter {
|
||||
it.kind != CommunityDefinitionEvent.KIND &&
|
||||
(kind != WikiNoteEvent.KIND || it.kind != WikiNoteEvent.KIND)
|
||||
it.kind != CommunityDefinitionEvent.KIND && (kind != WikiNoteEvent.KIND || it.kind != WikiNoteEvent.KIND)
|
||||
// removes forks from itself.
|
||||
}.map { it.toTag() }
|
||||
if (repliesTo.isEmpty() && tagAddresses.isEmpty()) return emptyList()
|
||||
|
@ -43,6 +43,7 @@ import com.vitorpamplona.quartz.encoders.Nip19Bech32
|
||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||
import com.vitorpamplona.quartz.signers.NostrSigner
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
import com.vitorpamplona.quartz.utils.bytesUsedInMemory
|
||||
import java.math.BigDecimal
|
||||
import java.security.MessageDigest
|
||||
|
||||
@ -564,10 +565,6 @@ open class BaseAddressableEvent(
|
||||
override fun addressTag() = ATag.assembleATag(kind, pubKey, dTag())
|
||||
}
|
||||
|
||||
fun String.bytesUsedInMemory(): Int {
|
||||
return (8 * ((((this.length) * 2) + 45) / 8))
|
||||
}
|
||||
|
||||
data class ZapSplitSetup(
|
||||
val lnAddressOrPubKeyHex: String,
|
||||
val relay: String?,
|
||||
|
@ -22,6 +22,10 @@ package com.vitorpamplona.quartz.utils
|
||||
|
||||
import kotlin.math.min
|
||||
|
||||
fun String.bytesUsedInMemory(): Int {
|
||||
return (8 * ((((this.length) * 2) + 45) / 8))
|
||||
}
|
||||
|
||||
fun String.containsIgnoreCase(term: String): Boolean {
|
||||
if (term.isEmpty()) return true // Empty string is contained
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user