feat: show nickname in the modal from the contact list
This commit is contained in:
parent
bc3b7a5533
commit
6e357cb5e2
|
@ -13,6 +13,7 @@ type
|
|||
IsBlocked = UserRole + 6
|
||||
Alias = UserRole + 7
|
||||
EnsVerified = UserRole + 8
|
||||
LocalNickname = UserRole + 9
|
||||
|
||||
QtObject:
|
||||
type ContactList* = ref object of QAbstractListModel
|
||||
|
@ -52,6 +53,7 @@ QtObject:
|
|||
of "isBlocked": result = $contact.isBlocked()
|
||||
of "alias": result = contact.alias
|
||||
of "ensVerified": result = $contact.ensVerified
|
||||
of "localNickname": result = $contact.localNickname
|
||||
|
||||
method data(self: ContactList, index: QModelIndex, role: int): QVariant =
|
||||
if not index.isValid:
|
||||
|
@ -68,6 +70,7 @@ QtObject:
|
|||
of ContactRoles.IsBlocked: result = newQVariant(contact.isBlocked())
|
||||
of ContactRoles.Alias: result = newQVariant(contact.alias)
|
||||
of ContactRoles.EnsVerified: result = newQVariant(contact.ensVerified)
|
||||
of ContactRoles.LocalNickname: result = newQVariant(contact.localNickname)
|
||||
|
||||
method roleNames(self: ContactList): Table[int, string] =
|
||||
{
|
||||
|
@ -78,6 +81,7 @@ QtObject:
|
|||
ContactRoles.IsContact.int:"isContact",
|
||||
ContactRoles.IsBlocked.int:"isBlocked",
|
||||
ContactRoles.Alias.int:"alias",
|
||||
ContactRoles.LocalNickname.int:"localNickname",
|
||||
ContactRoles.EnsVerified.int:"ensVerified"
|
||||
}.toTable
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ type ChatMember* = object
|
|||
joined*: bool
|
||||
identicon*: string
|
||||
userName*: string
|
||||
localNickname*: string
|
||||
|
||||
proc toJsonNode*(self: ChatMember): JsonNode =
|
||||
result = %* {
|
||||
|
|
|
@ -65,7 +65,18 @@ Item {
|
|||
if (!isProfileClick) {
|
||||
SelectedMessage.set(messageId, fromAuthor);
|
||||
}
|
||||
profileClick(userName, fromAuthor, identicon);
|
||||
// Get contact nickname
|
||||
const contactList = profileModel.contactList
|
||||
const contactCount = contactList.rowCount()
|
||||
let nickname = ""
|
||||
for (let i = 0; i < contactCount; i++) {
|
||||
if (contactList.rowData(i, 'pubKey') === fromAuthor) {
|
||||
nickname = contactList.rowData(i, 'localNickname')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
profileClick(userName, fromAuthor, identicon, "", nickname);
|
||||
messageContextMenu.isProfile = !!isProfileClick
|
||||
messageContextMenu.isSticker = isSticker
|
||||
messageContextMenu.popup()
|
||||
|
|
|
@ -21,7 +21,7 @@ ModalPopup {
|
|||
data.clear();
|
||||
for(let i = 0; i < profileModel.contactList.rowCount(); i++){
|
||||
if(chatsModel.activeChannel.contains(profileModel.contactList.rowData(i, "pubKey"))) continue;
|
||||
if(profileModel.contactList.rowData(i, "isContact") == "false") continue;
|
||||
if(profileModel.contactList.rowData(i, "isContact") === "false") continue;
|
||||
data.append({
|
||||
name: profileModel.contactList.rowData(i, "name"),
|
||||
pubKey: profileModel.contactList.rowData(i, "pubKey"),
|
||||
|
@ -312,7 +312,17 @@ ModalPopup {
|
|||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
popup.profileClick(model.userName, model.pubKey, model.identicon)
|
||||
// Get contact nickname
|
||||
const contactList = profileModel.contactList
|
||||
const contactCount = contactList.rowCount()
|
||||
let nickname = ""
|
||||
for (let i = 0; i < contactCount; i++) {
|
||||
if (contactList.rowData(i, 'pubKey') === model.pubKey) {
|
||||
nickname = contactList.rowData(i, 'localNickname')
|
||||
break;
|
||||
}
|
||||
}
|
||||
popup.profileClick(model.userName, model.pubKey, model.identicon, '', nickname)
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ ModalPopup {
|
|||
property bool nicknameTooLong: nicknameLength > maxNicknameLength
|
||||
|
||||
id: popup
|
||||
height: 325
|
||||
|
||||
header: Item {
|
||||
height: childrenRect.height
|
||||
|
|
|
@ -22,10 +22,10 @@ ModalPopup {
|
|||
signal blockButtonClicked(name: string, address: string)
|
||||
signal removeButtonClicked(address: string)
|
||||
|
||||
function setPopupData(userNameParam, fromAuthorParam, identiconParam, textParam){
|
||||
function setPopupData(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam) {
|
||||
showQR = false
|
||||
userName = userNameParam || ""
|
||||
nickname = userName.startsWith("@") ? "" : userName
|
||||
nickname = nicknameParam || ""
|
||||
fromAuthor = fromAuthorParam || ""
|
||||
identicon = identiconParam || ""
|
||||
text = textParam || ""
|
||||
|
@ -33,8 +33,8 @@ ModalPopup {
|
|||
alias = chatsModel.alias(this.fromAuthor) || ""
|
||||
}
|
||||
|
||||
function openPopup(userNameParam, fromAuthorParam, identiconParam) {
|
||||
setPopupData(userNameParam, fromAuthorParam, identiconParam, "");
|
||||
function openPopup(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam) {
|
||||
setPopupData(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam);
|
||||
popup.open()
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ Rectangle {
|
|||
property string name: "Jotaro Kujo"
|
||||
property string address: "0x04d8c07dd137bd1b73a6f51df148b4f77ddaa11209d36e43d8344c0a7d6db1cad6085f27cfb75dd3ae21d86ceffebe4cf8a35b9ce8d26baa19dc264efe6d8f221b"
|
||||
property string identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="
|
||||
property string localNickname: "JoJo"
|
||||
property bool selectable: false
|
||||
property var profileClick: function() {}
|
||||
property bool isContact: true
|
||||
|
@ -92,7 +93,7 @@ Rectangle {
|
|||
icon.width: menuButton.iconSize
|
||||
icon.height: menuButton.iconSize
|
||||
text: qsTrId("view-profile")
|
||||
onTriggered: profileClick(name, address, identicon)
|
||||
onTriggered: profileClick(name, address, identicon, "", localNickname)
|
||||
enabled: true
|
||||
}
|
||||
Action {
|
||||
|
|
|
@ -23,6 +23,7 @@ ListView {
|
|||
delegate: Contact {
|
||||
name: Utils.removeStatusEns(model.name)
|
||||
address: model.address
|
||||
localNickname: model.localNickname
|
||||
identicon: model.identicon
|
||||
isContact: model.isContact
|
||||
isBlocked: model.isBlocked
|
||||
|
|
Loading…
Reference in New Issue