fix: display ens names with correct format in all screens
This commit is contained in:
parent
0e6653968f
commit
e96f3ed47f
|
@ -1,11 +1,12 @@
|
||||||
import NimQml, std/wrapnils
|
import NimQml, Tables, std/wrapnils
|
||||||
import ../../../status/[chat/chat, status]
|
import ../../../status/[chat/chat, status, ens, accounts]
|
||||||
import chat_members
|
import chat_members
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type ChatItemView* = ref object of QObject
|
type ChatItemView* = ref object of QObject
|
||||||
chatItem*: Chat
|
chatItem*: Chat
|
||||||
chatMembers*: ChatMembersView
|
chatMembers*: ChatMembersView
|
||||||
|
status*: Status
|
||||||
|
|
||||||
proc setup(self: ChatItemView) =
|
proc setup(self: ChatItemView) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
|
@ -18,6 +19,7 @@ QtObject:
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result = ChatItemView()
|
result = ChatItemView()
|
||||||
result.chatItem = nil
|
result.chatItem = nil
|
||||||
|
result.status = status
|
||||||
result.chatMembers = newChatMembersView(status)
|
result.chatMembers = newChatMembersView(status)
|
||||||
result.setup
|
result.setup
|
||||||
|
|
||||||
|
@ -30,7 +32,16 @@ QtObject:
|
||||||
QtProperty[string] id:
|
QtProperty[string] id:
|
||||||
read = id
|
read = id
|
||||||
|
|
||||||
proc name*(self: ChatItemView): string {.slot.} = result = ?.self.chatItem.name
|
proc userNameOrAlias(self: ChatItemView, pubKey: string): string {.slot.} =
|
||||||
|
if self.status.chat.contacts.hasKey(pubKey):
|
||||||
|
return ens.userNameOrAlias(self.status.chat.contacts[pubKey])
|
||||||
|
generateAlias(pubKey)
|
||||||
|
|
||||||
|
proc name*(self: ChatItemView): string {.slot.} =
|
||||||
|
if self.chatItem != nil:
|
||||||
|
result = self.userNameOrAlias(self.chatItem.id)
|
||||||
|
else:
|
||||||
|
result = self.chatItem.name
|
||||||
|
|
||||||
QtProperty[string] name:
|
QtProperty[string] name:
|
||||||
read = name
|
read = name
|
||||||
|
|
|
@ -9,7 +9,7 @@ proc sectionIdentifier(message: Message): string =
|
||||||
|
|
||||||
proc mention(self: ChatMessageList, pubKey: string): string =
|
proc mention(self: ChatMessageList, pubKey: string): string =
|
||||||
if self.status.chat.contacts.hasKey(pubKey):
|
if self.status.chat.contacts.hasKey(pubKey):
|
||||||
return ens.userNameOrAlias(self.status.chat.contacts[pubKey])
|
return ens.userNameOrAlias(self.status.chat.contacts[pubKey], true)
|
||||||
generateAlias(pubKey)
|
generateAlias(pubKey)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ proc addDomain*(username: string): string =
|
||||||
else:
|
else:
|
||||||
return username & domain
|
return username & domain
|
||||||
|
|
||||||
proc userNameOrAlias*(contact: Profile): string =
|
proc userNameOrAlias*(contact: Profile, removeSuffix: bool = false): string =
|
||||||
if(contact.ensName != "" and contact.ensVerified):
|
if(contact.ensName != "" and contact.ensVerified):
|
||||||
result = "@" & userName(contact.ensName, true)
|
result = "@" & userName(contact.ensName, removeSuffix)
|
||||||
else:
|
else:
|
||||||
result = contact.alias
|
result = contact.alias
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ Item {
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
visible: chatsModel.activeChannel.chatType !== Constants.chatTypeOneToOne
|
visible: chatsModel.activeChannel.chatType !== Constants.chatTypeOneToOne
|
||||||
text: (chatsModel.activeChannel.name.charAt(0) === "#" ? chatsModel.activeChannel.name.charAt(1) : chatsModel.activeChannel.name.charAt(0)).toUpperCase()
|
text: Utils.removeStatusEns((chatsModel.activeChannel.name.charAt(0) === "#" ? chatsModel.activeChannel.name.charAt(1) : chatsModel.activeChannel.name.charAt(0)).toUpperCase())
|
||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
font.pixelSize: 51
|
font.pixelSize: 51
|
||||||
|
@ -57,10 +57,10 @@ Item {
|
||||||
id: channelName
|
id: channelName
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
text: {
|
text: {
|
||||||
if (chatsModel.activeChannel.chatType !== Constants.chatTypePublic) {
|
switch(chatsModel.activeChannel.chatType) {
|
||||||
return chatsModel.activeChannel.name;
|
case Constants.chatTypePublic: return "#" + chatsModel.activeChannel.name;
|
||||||
} else {
|
case Constants.chatTypeOneToOne: return Utils.removeStatusEns(chatsModel.activeChannel.name)
|
||||||
return "#" + chatsModel.activeChannel.name;
|
default: return chatsModel.activeChannel.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
|
|
|
@ -28,7 +28,6 @@ Item {
|
||||||
UsernameLabel {
|
UsernameLabel {
|
||||||
id: chatName
|
id: chatName
|
||||||
visible: chatsModel.activeChannel.chatType !== Constants.chatTypeOneToOne && isMessage && authorCurrentMsg != authorPrevMsg && !isCurrentUser
|
visible: chatsModel.activeChannel.chatType !== Constants.chatTypeOneToOne && isMessage && authorCurrentMsg != authorPrevMsg && !isCurrentUser
|
||||||
text: userName
|
|
||||||
anchors.leftMargin: 20
|
anchors.leftMargin: 20
|
||||||
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
||||||
anchors.topMargin: 0
|
anchors.topMargin: 0
|
||||||
|
|
|
@ -7,7 +7,8 @@ StyledTextEdit {
|
||||||
visible: isMessage && authorCurrentMsg != authorPrevMsg
|
visible: isMessage && authorCurrentMsg != authorPrevMsg
|
||||||
height: this.visible ? 18 : 0
|
height: this.visible ? 18 : 0
|
||||||
//% "You"
|
//% "You"
|
||||||
text: !isCurrentUser ? userName : qsTrId("You")
|
text: !isCurrentUser ? Utils.removeStatusEns(userName) : qsTrId("You")
|
||||||
|
color: (userName.startsWith("@") || isCurrentUser) ? Style.current.blue : Style.current.textColor
|
||||||
font.bold: true
|
font.bold: true
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
|
|
@ -31,7 +31,13 @@ Rectangle {
|
||||||
id: channelName
|
id: channelName
|
||||||
width: 80
|
width: 80
|
||||||
height: 20
|
height: 20
|
||||||
text: chatsModel.activeChannel.chatType != Constants.chatTypePublic ? chatsModel.activeChannel.name : channelNameStr
|
text: {
|
||||||
|
switch(chatsModel.activeChannel.chatType) {
|
||||||
|
case Constants.chatTypePublic: return channelNameStr;
|
||||||
|
case Constants.chatTypeOneToOne: return Utils.removeStatusEns(chatsModel.activeChannel.name)
|
||||||
|
default: return chatsModel.activeChannel.name
|
||||||
|
}
|
||||||
|
}
|
||||||
anchors.left: channelIcon.right
|
anchors.left: channelIcon.right
|
||||||
anchors.leftMargin: Style.current.smallPadding
|
anchors.leftMargin: Style.current.smallPadding
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
|
|
@ -70,7 +70,7 @@ Rectangle {
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: contactInfo
|
id: contactInfo
|
||||||
text: wrapper.chatType !== Constants.chatTypePublic ? Emoji.parse(wrapper.name, "26x26") : "#" + wrapper.name
|
text: wrapper.chatType !== Constants.chatTypePublic ? Emoji.parse(Utils.removeStatusEns(wrapper.name), "26x26") : "#" + wrapper.name
|
||||||
anchors.right: contactTime.left
|
anchors.right: contactTime.left
|
||||||
anchors.rightMargin: Style.current.smallPadding
|
anchors.rightMargin: Style.current.smallPadding
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
|
|
|
@ -123,6 +123,8 @@ ModalPopup {
|
||||||
SVGImage {
|
SVGImage {
|
||||||
id: editGroupImg
|
id: editGroupImg
|
||||||
source: "../../../img/edit-group.svg"
|
source: "../../../img/edit-group.svg"
|
||||||
|
height: 16
|
||||||
|
width: 16
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
@ -184,7 +186,7 @@ ModalPopup {
|
||||||
showCheckbox: memberCount < maxMembers
|
showCheckbox: memberCount < maxMembers
|
||||||
pubKey: model.pubKey
|
pubKey: model.pubKey
|
||||||
isUser: model.isUser
|
isUser: model.isUser
|
||||||
name: model.name
|
name: Utils.removeStatusEns(model.name)
|
||||||
address: model.address
|
address: model.address
|
||||||
identicon: model.identicon
|
identicon: model.identicon
|
||||||
onItemChecked: function(pubKey, itemChecked){
|
onItemChecked: function(pubKey, itemChecked){
|
||||||
|
@ -272,7 +274,7 @@ ModalPopup {
|
||||||
}
|
}
|
||||||
Column {
|
Column {
|
||||||
StyledText {
|
StyledText {
|
||||||
text: model.userName
|
text: Utils.removeStatusEns(model.userName)
|
||||||
width: 300
|
width: 300
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
|
@ -54,7 +54,7 @@ PopupMenu {
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: username
|
id: username
|
||||||
text: profilePopup.userName
|
text: Utils.removeStatusEns(profilePopup.userName)
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
anchors.top: profileImage.bottom
|
anchors.top: profileImage.bottom
|
||||||
|
|
|
@ -53,7 +53,7 @@ ModalPopup {
|
||||||
|
|
||||||
StyledTextEdit {
|
StyledTextEdit {
|
||||||
id: profileName
|
id: profileName
|
||||||
text: userName
|
text: Utils.removeStatusEns(userName)
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: 18
|
anchors.topMargin: 18
|
||||||
anchors.left: profilePic.right
|
anchors.left: profilePic.right
|
||||||
|
@ -150,7 +150,7 @@ ModalPopup {
|
||||||
id: valueEnsName
|
id: valueEnsName
|
||||||
visible: isEnsVerified
|
visible: isEnsVerified
|
||||||
height: isEnsVerified ? 20 : 0
|
height: isEnsVerified ? 20 : 0
|
||||||
text: userName
|
text: userName.substr(1)
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: Style.current.smallPadding
|
anchors.leftMargin: Style.current.smallPadding
|
||||||
|
|
|
@ -20,7 +20,7 @@ ListView {
|
||||||
|
|
||||||
model: contacts
|
model: contacts
|
||||||
delegate: Contact {
|
delegate: Contact {
|
||||||
name: model.name
|
name: Utils.removeStatusEns(model.name)
|
||||||
address: model.address
|
address: model.address
|
||||||
identicon: model.identicon
|
identicon: model.identicon
|
||||||
isContact: model.isContact
|
isContact: model.isContact
|
||||||
|
|
|
@ -244,7 +244,8 @@ Item {
|
||||||
|
|
||||||
UsernameLabel {
|
UsernameLabel {
|
||||||
id: chatName
|
id: chatName
|
||||||
text: profileModel.ens.preferredUsername
|
text: "@" + (profileModel.ens.preferredUsername.replace(".stateofus.eth", ""))
|
||||||
|
color: Style.current.blue
|
||||||
anchors.leftMargin: 20
|
anchors.leftMargin: 20
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: 0
|
anchors.topMargin: 0
|
||||||
|
|
|
@ -60,6 +60,9 @@ QtObject {
|
||||||
function isOnlyEmoji(inputText) {
|
function isOnlyEmoji(inputText) {
|
||||||
var emoji_regex = /^(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff]|\s)+$/;
|
var emoji_regex = /^(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff]|\s)+$/;
|
||||||
return emoji_regex.test(inputText);
|
return emoji_regex.test(inputText);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeStatusEns(userName){
|
||||||
|
return userName.endsWith(".stateofus.eth") ? userName.substr(0, userName.length - 14) : userName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue