Implement adding labels for account

This gives the user the ability to label different account (e.g. "work",
"private") and shows this label in the account switcher. Showing the
label in more places will be done in future MRs.

The label is stored in the user's account data and thus transfers
automatically to other instances of neochat
This commit is contained in:
Tobias Fella
2022-01-31 22:45:17 +01:00
parent 0b7dcd70ac
commit a6ab447955
4 changed files with 39 additions and 0 deletions

View File

@@ -321,6 +321,7 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true
Layout.fillHeight: true
text: model.connection.localUserId
subtitle: model.connection.localUser.accountLabel
}
}
}

View File

@@ -151,6 +151,11 @@ Kirigami.ScrollablePage {
text: userEditSheet.connection ? userEditSheet.connection.localUser.displayName : ""
Kirigami.FormData.label: i18n("Name:")
}
Controls.TextField {
id: accountLabel
text: userEditSheet.connection ? userEditSheet.connection.localUser.accountLabel : ""
Kirigami.FormData.label: i18n("Label:")
}
Controls.TextField {
id: currentPassword
Kirigami.FormData.label: i18n("Current Password:")
@@ -179,6 +184,8 @@ Kirigami.ScrollablePage {
showPassiveNotification("The Avatar could not be set")
if(userEditSheet.connection.localUser.displayName !== name.text)
userEditSheet.connection.localUser.rename(name.text)
if(userEditSheet.connection.localUser.accountLabel !== accountLabel.text)
userEditSheet.connection.localUser.setAccountLabel(accountLabel.text)
if(currentPassword.text !== "" && newPassword.text !== "" && confirmPassword.text !== "") {
if(newPassword.text === confirmPassword.text) {
Controller.changePassword(userEditSheet.connection, currentPassword.text, newPassword.text)