add prune database function
This commit is contained in:
@@ -188,6 +188,14 @@ class Nostr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun prune() {
|
||||||
|
try {
|
||||||
|
client?.database()?.wipe()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw IllegalStateException("Failed to prune database: ${e.message}", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun setSigner(new: AsyncNostrSigner) {
|
suspend fun setSigner(new: AsyncNostrSigner) {
|
||||||
try {
|
try {
|
||||||
signer.switch(new)
|
signer.switch(new)
|
||||||
@@ -994,7 +1002,7 @@ class Nostr {
|
|||||||
try {
|
try {
|
||||||
val currentUser =
|
val currentUser =
|
||||||
signer.getPublicKeyAsync() ?: throw IllegalStateException("User not signed in")
|
signer.getPublicKeyAsync() ?: throw IllegalStateException("User not signed in")
|
||||||
|
|
||||||
val kind = Kind.fromStd(KindStandard.CONTACT_LIST)
|
val kind = Kind.fromStd(KindStandard.CONTACT_LIST)
|
||||||
val filter = Filter().kind(kind).author(currentUser).limit(1u)
|
val filter = Filter().kind(kind).author(currentUser).limit(1u)
|
||||||
|
|
||||||
|
|||||||
@@ -325,8 +325,11 @@ class NostrViewModel(
|
|||||||
|
|
||||||
fun logout() {
|
fun logout() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
secretStore.clear("user_signer")
|
// Reset the nostr state and wipe database
|
||||||
nostr.signer.switch(Keys.generate())
|
nostr.signer.switch(Keys.generate())
|
||||||
|
nostr.prune()
|
||||||
|
// Clear credential
|
||||||
|
secretStore.clear("user_signer")
|
||||||
_signerRequired.value = true
|
_signerRequired.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -821,7 +824,7 @@ class NostrViewModel(
|
|||||||
}
|
}
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun verifyActivity(pubkey: PublicKey): Timestamp? {
|
suspend fun verifyActivity(pubkey: PublicKey): Timestamp? {
|
||||||
return try {
|
return try {
|
||||||
nostr.verifyActivity(pubkey)
|
nostr.verifyActivity(pubkey)
|
||||||
|
|||||||
Reference in New Issue
Block a user