.
This commit is contained in:
@@ -6,13 +6,13 @@ import io.ktor.client.plugins.websocket.WebSockets
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.HttpResponse
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asSharedFlow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import rust.nostr.sdk.AckPolicy
|
||||
import rust.nostr.sdk.Alphabet
|
||||
import rust.nostr.sdk.AsyncNostrSigner
|
||||
@@ -170,8 +170,6 @@ class Nostr {
|
||||
suspend fun setSigner(new: AsyncNostrSigner) {
|
||||
try {
|
||||
signer.switch(new)
|
||||
// Fetch metadata for current user
|
||||
getUserMetadata()
|
||||
} catch (e: Exception) {
|
||||
throw IllegalStateException("Failed to set signer: ${e.message}", e)
|
||||
}
|
||||
@@ -244,10 +242,10 @@ class Nostr {
|
||||
onContactListUpdate: (List<PublicKey>) -> Unit,
|
||||
onNewMessage: (UnsignedEvent) -> Unit,
|
||||
onSubscriptionClose: () -> Unit,
|
||||
) = coroutineScope {
|
||||
) = supervisorScope {
|
||||
val now = Timestamp.now()
|
||||
val processedEvent = mutableSetOf<EventId>()
|
||||
val notifications = client?.notifications() ?: return@coroutineScope
|
||||
val notifications = client?.notifications() ?: return@supervisorScope
|
||||
|
||||
var eoseTrackerJob: Job? = null
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class NostrViewModel(
|
||||
|
||||
// Observe new events from the Nostr client
|
||||
runObserver()
|
||||
|
||||
|
||||
// Wait and merge metadata requests into a single batch
|
||||
runMetadataBatching()
|
||||
}
|
||||
@@ -201,9 +201,6 @@ class NostrViewModel(
|
||||
|
||||
private fun login() {
|
||||
viewModelScope.launch {
|
||||
// Wait until the client is ready
|
||||
nostr.waitUntilInitialized()
|
||||
|
||||
// Get user's signer secret
|
||||
val secret = secretStore.get("user_signer")
|
||||
|
||||
@@ -249,6 +246,9 @@ class NostrViewModel(
|
||||
_isPartialProcessedGiftWrap.value = true
|
||||
}
|
||||
|
||||
// Get all metadata for the current user
|
||||
nostr.getUserMetadata()
|
||||
|
||||
// Small delay to ensure all relays are connected
|
||||
delay(3000)
|
||||
|
||||
@@ -261,7 +261,7 @@ class NostrViewModel(
|
||||
break
|
||||
}
|
||||
|
||||
delay(1000)
|
||||
delay(500)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user