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