This commit is contained in:
2026-05-09 09:07:27 +07:00
parent 5c31f7a0d6
commit e824aa7e16
8 changed files with 222 additions and 81 deletions
@@ -101,21 +101,17 @@ class NostrViewModel(
}
fun getUserProfile(): StateFlow<Metadata?> {
return getMetadata(nostr.userPubkey!!)
return nostr.userPubkey?.let { getMetadata(it) } ?: MutableStateFlow(null).asStateFlow()
}
fun initAndConnect(dbPath: String) {
viewModelScope.launch {
try {
// Initialize nostr client
nostr.init(dbPath)
// Connect to bootstrap relays
nostr.connect()
// Get user's secret
getUserSecret()
} catch (e: Exception) {
showError("Failed to initialize Nostr: ${e.message}")
}
suspend fun initAndConnect(dbPath: String) {
try {
// Initialize nostr client
nostr.init(dbPath)
// Get user's secret
getUserSecret()
} catch (e: Exception) {
showError("Failed to initialize Nostr: ${e.message}")
}
}