Re-adds name to the profile edit page.
This commit is contained in:
+3
-2
@@ -50,6 +50,7 @@ class UserMetadataState(
|
|||||||
|
|
||||||
suspend fun sendNewUserMetadata(
|
suspend fun sendNewUserMetadata(
|
||||||
name: String? = null,
|
name: String? = null,
|
||||||
|
displayName: String? = null,
|
||||||
picture: String? = null,
|
picture: String? = null,
|
||||||
banner: String? = null,
|
banner: String? = null,
|
||||||
website: String? = null,
|
website: String? = null,
|
||||||
@@ -69,7 +70,7 @@ class UserMetadataState(
|
|||||||
MetadataEvent.updateFromPast(
|
MetadataEvent.updateFromPast(
|
||||||
latest = latest,
|
latest = latest,
|
||||||
name = name,
|
name = name,
|
||||||
displayName = name,
|
displayName = displayName,
|
||||||
picture = picture,
|
picture = picture,
|
||||||
banner = banner,
|
banner = banner,
|
||||||
website = website,
|
website = website,
|
||||||
@@ -85,7 +86,7 @@ class UserMetadataState(
|
|||||||
} else {
|
} else {
|
||||||
MetadataEvent.createNew(
|
MetadataEvent.createNew(
|
||||||
name = name,
|
name = name,
|
||||||
displayName = name,
|
displayName = displayName,
|
||||||
picture = picture,
|
picture = picture,
|
||||||
banner = banner,
|
banner = banner,
|
||||||
website = website,
|
website = website,
|
||||||
|
|||||||
+24
-3
@@ -70,11 +70,12 @@ fun NewUserMetadataScreen(
|
|||||||
SavingTopBar(
|
SavingTopBar(
|
||||||
titleRes = R.string.profile,
|
titleRes = R.string.profile,
|
||||||
onCancel = {
|
onCancel = {
|
||||||
postViewModel.clear()
|
|
||||||
nav.popBack()
|
nav.popBack()
|
||||||
},
|
},
|
||||||
onPost = {
|
onPost = {
|
||||||
postViewModel.create()
|
accountViewModel.launchSigner {
|
||||||
|
postViewModel.create()
|
||||||
|
}
|
||||||
nav.popBack()
|
nav.popBack()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -95,7 +96,27 @@ fun NewUserMetadataScreen(
|
|||||||
modifier = Modifier.padding(10.dp).verticalScroll(rememberScrollState()),
|
modifier = Modifier.padding(10.dp).verticalScroll(rememberScrollState()),
|
||||||
) {
|
) {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
label = { Text(text = stringRes(R.string.profile_name)) },
|
label = { Text(text = stringRes(R.string.profile_name_with_explainer)) },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
value = postViewModel.name.value,
|
||||||
|
onValueChange = { postViewModel.name.value = it },
|
||||||
|
placeholder = {
|
||||||
|
Text(
|
||||||
|
text = stringRes(R.string.my_name),
|
||||||
|
color = MaterialTheme.colorScheme.placeholderText,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
keyboardOptions =
|
||||||
|
KeyboardOptions.Default.copy(
|
||||||
|
capitalization = KeyboardCapitalization.Sentences,
|
||||||
|
),
|
||||||
|
singleLine = true,
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(10.dp))
|
||||||
|
|
||||||
|
OutlinedTextField(
|
||||||
|
label = { Text(text = stringRes(R.string.display_name)) },
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
value = postViewModel.displayName.value,
|
value = postViewModel.displayName.value,
|
||||||
onValueChange = { postViewModel.displayName.value = it },
|
onValueChange = { postViewModel.displayName.value = it },
|
||||||
|
|||||||
+23
-25
@@ -47,7 +47,7 @@ class NewUserMetadataViewModel : ViewModel() {
|
|||||||
private lateinit var accountViewModel: AccountViewModel
|
private lateinit var accountViewModel: AccountViewModel
|
||||||
private lateinit var account: Account
|
private lateinit var account: Account
|
||||||
|
|
||||||
// val userName = mutableStateOf("")
|
val name = mutableStateOf("")
|
||||||
val displayName = mutableStateOf("")
|
val displayName = mutableStateOf("")
|
||||||
val about = mutableStateOf("")
|
val about = mutableStateOf("")
|
||||||
|
|
||||||
@@ -74,8 +74,8 @@ class NewUserMetadataViewModel : ViewModel() {
|
|||||||
|
|
||||||
fun load() {
|
fun load() {
|
||||||
account.userProfile().let {
|
account.userProfile().let {
|
||||||
// userName.value = it.bestUsername() ?: ""
|
name.value = it.info?.name ?: ""
|
||||||
displayName.value = it.info?.bestName() ?: ""
|
displayName.value = it.info?.displayName ?: ""
|
||||||
about.value = it.info?.about ?: ""
|
about.value = it.info?.about ?: ""
|
||||||
picture.value = it.info?.picture ?: ""
|
picture.value = it.info?.picture ?: ""
|
||||||
banner.value = it.info?.banner ?: ""
|
banner.value = it.info?.banner ?: ""
|
||||||
@@ -100,33 +100,31 @@ class NewUserMetadataViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun create() {
|
suspend fun create() {
|
||||||
// Tries to not delete any existing attribute that we do not work with.
|
val metadata =
|
||||||
accountViewModel.launchSigner {
|
account.userMetadata.sendNewUserMetadata(
|
||||||
val metadata =
|
name = name.value,
|
||||||
account.userMetadata.sendNewUserMetadata(
|
displayName = displayName.value,
|
||||||
name = displayName.value,
|
picture = picture.value,
|
||||||
picture = picture.value,
|
banner = banner.value,
|
||||||
banner = banner.value,
|
website = website.value,
|
||||||
website = website.value,
|
pronouns = pronouns.value,
|
||||||
pronouns = pronouns.value,
|
about = about.value,
|
||||||
about = about.value,
|
nip05 = nip05.value,
|
||||||
nip05 = nip05.value,
|
lnAddress = lnAddress.value,
|
||||||
lnAddress = lnAddress.value,
|
lnURL = lnURL.value,
|
||||||
lnURL = lnURL.value,
|
twitter = twitter.value,
|
||||||
twitter = twitter.value,
|
mastodon = mastodon.value,
|
||||||
mastodon = mastodon.value,
|
github = github.value,
|
||||||
github = github.value,
|
)
|
||||||
)
|
|
||||||
|
|
||||||
account.sendLiterallyEverywhere(metadata)
|
account.sendLiterallyEverywhere(metadata)
|
||||||
|
|
||||||
clear()
|
clear()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clear() {
|
fun clear() {
|
||||||
// userName.value = ""
|
name.value = ""
|
||||||
displayName.value = ""
|
displayName.value = ""
|
||||||
about.value = ""
|
about.value = ""
|
||||||
picture.value = ""
|
picture.value = ""
|
||||||
|
|||||||
@@ -147,6 +147,8 @@
|
|||||||
<string name="add_a_user">Add a User</string>
|
<string name="add_a_user">Add a User</string>
|
||||||
<string name="add_a_relay">Add a Relay</string>
|
<string name="add_a_relay">Add a Relay</string>
|
||||||
<string name="profile_name">Name</string>
|
<string name="profile_name">Name</string>
|
||||||
|
<string name="profile_name_with_explainer">Name (for @tagging)</string>
|
||||||
|
<string name="my_name">My @tag name</string>
|
||||||
<string name="display_name">Display Name</string>
|
<string name="display_name">Display Name</string>
|
||||||
<string name="my_display_name">My display name</string>
|
<string name="my_display_name">My display name</string>
|
||||||
<string name="my_awesome_name">Ostrich McAwesome</string>
|
<string name="my_awesome_name">Ostrich McAwesome</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user