Forces the presence of the name field in kind 1 as per https://github.com/nostr-protocol/nips/pull/794
This commit is contained in:
@@ -17,7 +17,6 @@ import androidx.compose.material.Surface
|
|||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@@ -38,7 +37,6 @@ import kotlinx.coroutines.withContext
|
|||||||
fun NewUserMetadataView(onClose: () -> Unit, account: Account) {
|
fun NewUserMetadataView(onClose: () -> Unit, account: Account) {
|
||||||
val postViewModel: NewUserMetadataViewModel = viewModel()
|
val postViewModel: NewUserMetadataViewModel = viewModel()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
postViewModel.load(account)
|
postViewModel.load(account)
|
||||||
@@ -88,43 +86,22 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) {
|
|||||||
.padding(10.dp)
|
.padding(10.dp)
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
Row(
|
OutlinedTextField(
|
||||||
modifier = Modifier.fillMaxWidth(1f),
|
label = { Text(text = stringResource(R.string.display_name)) },
|
||||||
verticalAlignment = Alignment.CenterVertically
|
modifier = Modifier.fillMaxWidth(),
|
||||||
) {
|
value = postViewModel.displayName.value,
|
||||||
OutlinedTextField(
|
onValueChange = { postViewModel.displayName.value = it },
|
||||||
label = { Text(text = stringResource(R.string.display_name)) },
|
placeholder = {
|
||||||
modifier = Modifier.weight(1f),
|
Text(
|
||||||
value = postViewModel.displayName.value,
|
text = stringResource(R.string.my_display_name),
|
||||||
onValueChange = { postViewModel.displayName.value = it },
|
color = MaterialTheme.colors.placeholderText
|
||||||
placeholder = {
|
)
|
||||||
Text(
|
},
|
||||||
text = stringResource(R.string.my_display_name),
|
keyboardOptions = KeyboardOptions.Default.copy(
|
||||||
color = MaterialTheme.colors.placeholderText
|
capitalization = KeyboardCapitalization.Sentences
|
||||||
)
|
),
|
||||||
},
|
singleLine = true
|
||||||
keyboardOptions = KeyboardOptions.Default.copy(
|
)
|
||||||
capitalization = KeyboardCapitalization.Sentences
|
|
||||||
),
|
|
||||||
singleLine = true
|
|
||||||
)
|
|
||||||
|
|
||||||
Text("@", Modifier.padding(5.dp))
|
|
||||||
|
|
||||||
OutlinedTextField(
|
|
||||||
label = { Text(text = stringResource(R.string.username)) },
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
value = postViewModel.userName.value,
|
|
||||||
onValueChange = { postViewModel.userName.value = it },
|
|
||||||
placeholder = {
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.my_username),
|
|
||||||
color = MaterialTheme.colors.placeholderText
|
|
||||||
)
|
|
||||||
},
|
|
||||||
singleLine = true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(10.dp))
|
Spacer(modifier = Modifier.height(10.dp))
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.io.StringWriter
|
|||||||
class NewUserMetadataViewModel : ViewModel() {
|
class NewUserMetadataViewModel : ViewModel() {
|
||||||
private lateinit var account: Account
|
private lateinit var account: Account
|
||||||
|
|
||||||
val userName = mutableStateOf("")
|
// val userName = mutableStateOf("")
|
||||||
val displayName = mutableStateOf("")
|
val displayName = mutableStateOf("")
|
||||||
val about = mutableStateOf("")
|
val about = mutableStateOf("")
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ class NewUserMetadataViewModel : ViewModel() {
|
|||||||
this.account = account
|
this.account = account
|
||||||
|
|
||||||
account.userProfile().let {
|
account.userProfile().let {
|
||||||
userName.value = it.bestUsername() ?: ""
|
// userName.value = it.bestUsername() ?: ""
|
||||||
displayName.value = it.bestDisplayName() ?: ""
|
displayName.value = it.bestDisplayName() ?: ""
|
||||||
about.value = it.info?.about ?: ""
|
about.value = it.info?.about ?: ""
|
||||||
picture.value = it.info?.picture ?: ""
|
picture.value = it.info?.picture ?: ""
|
||||||
@@ -82,8 +82,8 @@ class NewUserMetadataViewModel : ViewModel() {
|
|||||||
} else {
|
} else {
|
||||||
ObjectMapper().createObjectNode()
|
ObjectMapper().createObjectNode()
|
||||||
}
|
}
|
||||||
currentJson.put("name", userName.value.trim())
|
// currentJson.put("username", userName.value.trim())
|
||||||
currentJson.put("username", userName.value.trim())
|
currentJson.put("name", displayName.value.trim())
|
||||||
currentJson.put("display_name", displayName.value.trim())
|
currentJson.put("display_name", displayName.value.trim())
|
||||||
currentJson.put("displayName", displayName.value.trim())
|
currentJson.put("displayName", displayName.value.trim())
|
||||||
currentJson.put("picture", picture.value.trim())
|
currentJson.put("picture", picture.value.trim())
|
||||||
@@ -128,7 +128,7 @@ class NewUserMetadataViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun clear() {
|
fun clear() {
|
||||||
userName.value = ""
|
// userName.value = ""
|
||||||
displayName.value = ""
|
displayName.value = ""
|
||||||
about.value = ""
|
about.value = ""
|
||||||
picture.value = ""
|
picture.value = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user