fix
This commit is contained in:
@@ -78,7 +78,7 @@ fun ImportScreen() {
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
val isLoggedIn by viewModel.isLoggedIn.collectAsStateWithLifecycle(false)
|
||||
val isBusy by viewModel.isBusy.collectAsStateWithLifecycle(false)
|
||||
var secret by remember { mutableStateOf("") }
|
||||
var pubkey by remember { mutableStateOf<PublicKey?>(null) }
|
||||
|
||||
@@ -205,7 +205,7 @@ fun ImportScreen() {
|
||||
BasicTextField(
|
||||
value = secret,
|
||||
onValueChange = { secret = it },
|
||||
enabled = !isLoggedIn,
|
||||
enabled = !isBusy,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
maxLines = 4,
|
||||
keyboardOptions = KeyboardOptions(
|
||||
@@ -258,9 +258,9 @@ fun ImportScreen() {
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(ButtonDefaults.MediumContainerHeight),
|
||||
enabled = secret.isNotBlank() && !isLoggedIn,
|
||||
enabled = secret.isNotBlank() && !isBusy,
|
||||
) {
|
||||
if (isLoggedIn) {
|
||||
if (isBusy) {
|
||||
LoadingIndicator()
|
||||
} else {
|
||||
Text(
|
||||
|
||||
@@ -15,12 +15,12 @@ fun NewIdentityScreen() {
|
||||
val viewModel = LocalNostrViewModel.current
|
||||
val navigator = LocalNavigator.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val isLoggedIn by viewModel.isLoggedIn.collectAsStateWithLifecycle(false)
|
||||
val isBusy by viewModel.isBusy.collectAsStateWithLifecycle(false)
|
||||
|
||||
ProfileEditor(
|
||||
title = "Create a new identity",
|
||||
buttonLabel = "Continue",
|
||||
isBusy = isLoggedIn,
|
||||
isBusy = isBusy,
|
||||
onBack = { navigator.goBack() },
|
||||
onConfirm = { name, bio, bytes, type ->
|
||||
scope.launch {
|
||||
|
||||
@@ -160,9 +160,10 @@ fun OnboardingScreen() {
|
||||
if (viewModel.isExternalSignerAvailable()) {
|
||||
try {
|
||||
viewModel.connectExternalSigner()
|
||||
navigator.navigate(Screen.Home)
|
||||
} catch (e: Exception) {
|
||||
e.message?.let { snackbarHostState.showSnackbar(it) }
|
||||
} finally {
|
||||
navigator.navigate(Screen.Home)
|
||||
}
|
||||
} else {
|
||||
val result = snackbarHostState.showSnackbar(
|
||||
|
||||
@@ -18,7 +18,7 @@ fun UpdateProfileScreen() {
|
||||
|
||||
val currentUser = viewModel.currentUser() ?: return
|
||||
val metadata by viewModel.getMetadata(currentUser).collectAsState(initial = null)
|
||||
val isBusy by viewModel.isLoggedIn.collectAsStateWithLifecycle(false)
|
||||
val isBusy by viewModel.isBusy.collectAsStateWithLifecycle(false)
|
||||
|
||||
val profile = metadata?.asRecord()
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ class NostrViewModel(
|
||||
private val _signerRequired = MutableStateFlow<Boolean?>(null)
|
||||
val signerRequired = _signerRequired.asStateFlow()
|
||||
|
||||
private val _isLoggedIn = MutableStateFlow(false)
|
||||
val isLoggedIn = _isLoggedIn.asStateFlow()
|
||||
private val _isBusy = MutableStateFlow(false)
|
||||
val isBusy = _isBusy.asStateFlow()
|
||||
|
||||
private val _isPartialProcessedGiftWrap = MutableStateFlow(false)
|
||||
val isPartialProcessedGiftWrap = _isPartialProcessedGiftWrap.asStateFlow()
|
||||
@@ -407,7 +407,7 @@ class NostrViewModel(
|
||||
picture: ByteArray? = null,
|
||||
contentType: String? = null
|
||||
) {
|
||||
_isLoggedIn.value = true
|
||||
_isBusy.value = true
|
||||
try {
|
||||
val avatarUrl = picture?.let { blossomUpload(it, contentType ?: "image/jpeg") }
|
||||
val newMetadata = nostr.updateProfile(name, bio, avatarUrl)
|
||||
@@ -416,7 +416,7 @@ class NostrViewModel(
|
||||
} catch (e: Exception) {
|
||||
showError("Error: ${e.message}")
|
||||
} finally {
|
||||
_isLoggedIn.value = false
|
||||
_isBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ class NostrViewModel(
|
||||
picture: ByteArray?,
|
||||
contentType: String? = null
|
||||
) {
|
||||
_isLoggedIn.value = true
|
||||
_isBusy.value = true
|
||||
|
||||
val keys = Keys.generate()
|
||||
val secret = keys.secretKey().toBech32()
|
||||
@@ -439,7 +439,7 @@ class NostrViewModel(
|
||||
showError("Error: ${e.message}")
|
||||
} finally {
|
||||
secretStore.set("user_signer", secret)
|
||||
_isLoggedIn.value = false
|
||||
_isBusy.value = false
|
||||
_signerRequired.value = false
|
||||
}
|
||||
}
|
||||
@@ -486,7 +486,7 @@ class NostrViewModel(
|
||||
}
|
||||
|
||||
suspend fun importIdentity(secret: String) {
|
||||
_isLoggedIn.value = true
|
||||
_isBusy.value = true
|
||||
try {
|
||||
val signer = createSigner(secret)
|
||||
nostr.setSigner(signer)
|
||||
@@ -495,13 +495,13 @@ class NostrViewModel(
|
||||
} finally {
|
||||
secretStore.set("user_signer", secret)
|
||||
_signerRequired.value = false
|
||||
_isLoggedIn.value = false
|
||||
_isBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun connectExternalSigner() {
|
||||
val handler = externalSignerHandler ?: throw IllegalStateException("Signer not available")
|
||||
_isLoggedIn.value = true
|
||||
_isBusy.value = true
|
||||
try {
|
||||
val permissions = SignerPermissions.toJson(
|
||||
listOf(
|
||||
@@ -524,7 +524,7 @@ class NostrViewModel(
|
||||
showError("Error: ${e.message}")
|
||||
} finally {
|
||||
_signerRequired.value = false
|
||||
_isLoggedIn.value = false
|
||||
_isBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user