Moves NIP-55 calls to be suspending functions.

Moves NIP-55 calls to include an ID per call, not per event.
Adds error handling facilities to the Signer functions.
Moves the indexing of the decrypted objects to outside the LocalCache
Migrates Signers to become suspending functions.
Migrates Decryption caching systems to outside the Events themselves.
Migrates all NIP-51 lists to the new structure.
Migrates Drafts and NIP-04 and NIP-17 DMs to the new structure
Migrates Bookmarks to the new structure.
Changes the Room route to avoid using hashcode.
This commit is contained in:
Vitor Pamplona
2025-07-18 17:17:27 -04:00
parent 7bdb3a1a18
commit 58e353fb40
374 changed files with 9807 additions and 8720 deletions

View File

@@ -96,7 +96,7 @@ class BlurhashTest {
@Test
fun testLorikeet() {
val blurhash = load("/lorikeet.jpg").toBlurhash()
assertEquals("rFDcT@_LNs#p%Mt*nNM}E2VrIVX6VuV@WUo{xtjv9]RRw[OXS}rrWFX9w{OZxaxWNHX4n\$M}NGaK%0RkM}w{xto|jFs,Sh-Tj]bcwJnjXSxZs.NI", blurhash)
assertEquals("rFDcT@_LNs#:-pyBnhRRE2Z~MyX5VuV@WUo{xta\$9]RQw[OXS}rrWFXSw|OsxaxWNHSwn~M}NGaK%0RkM}w{xto|jGs+Sh-Tj]W?wJnjXSxGs.NI", blurhash)
}
private fun load(filename: String): Bitmap =

View File

@@ -32,8 +32,9 @@ fun <K, V> produceCachedStateAsync(
): State<V?> =
@Suppress("ProduceStateDoesNotAssignValue")
produceState(initialValue = cache.cached(key), key1 = key) {
cache.update(key) {
value = it
val newValue = cache.update(key)
if (newValue != value) {
value = newValue
}
}
@@ -45,18 +46,16 @@ fun <K, V> produceCachedStateAsync(
): State<V?> =
@Suppress("ProduceStateDoesNotAssignValue")
produceState(initialValue = cache.cached(updateValue), key1 = key) {
cache.update(updateValue) {
value = it
val newValue = cache.update(updateValue)
if (newValue != value) {
value = newValue
}
}
interface AsyncCachedState<K, V> {
fun cached(k: K): V?
suspend fun update(
k: K,
onReady: (V?) -> Unit,
)
suspend fun update(k: K): V?
}
abstract class GenericBaseCacheAsync<K, V>(
@@ -66,23 +65,17 @@ abstract class GenericBaseCacheAsync<K, V>(
override fun cached(k: K): V? = cache[k]
override suspend fun update(
k: K,
onReady: (V?) -> Unit,
) {
cache[k]?.let { onReady(it) }
override suspend fun update(k: K): V? {
cache[k]?.let { return it }
compute(k) {
if (it != null) {
cache.put(k, it)
}
val newValue = compute(k)
onReady(it)
if (newValue != null) {
cache.put(k, newValue)
}
return newValue
}
abstract suspend fun compute(
key: K,
onReady: (V?) -> Unit,
)
abstract suspend fun compute(key: K): V?
}