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