diff --git a/ui/app/AppLayouts/Chat/components/MessageContextMenu.qml b/ui/app/AppLayouts/Chat/components/MessageContextMenu.qml index fd8e55b370..38278065ee 100644 --- a/ui/app/AppLayouts/Chat/components/MessageContextMenu.qml +++ b/ui/app/AppLayouts/Chat/components/MessageContextMenu.qml @@ -86,7 +86,7 @@ PopupMenu { StyledText { id: username - text: Utils.removeStatusEns(userName) + text: Utils.truncateName(Utils.removeStatusEns(userName)) horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap anchors.top: profileImage.bottom diff --git a/ui/app/AppLayouts/Chat/components/ProfilePopup.qml b/ui/app/AppLayouts/Chat/components/ProfilePopup.qml index 152fdb5250..6cfaac48df 100644 --- a/ui/app/AppLayouts/Chat/components/ProfilePopup.qml +++ b/ui/app/AppLayouts/Chat/components/ProfilePopup.qml @@ -67,7 +67,7 @@ ModalPopup { StyledTextEdit { id: profileName - text: Utils.removeStatusEns(userName) + text: Utils.truncateName(Utils.removeStatusEns(userName)) anchors.top: parent.top anchors.topMargin: Style.current.padding anchors.left: profilePic.right diff --git a/ui/imports/Utils.qml b/ui/imports/Utils.qml index c48e015915..4b580acb0d 100644 --- a/ui/imports/Utils.qml +++ b/ui/imports/Utils.qml @@ -74,6 +74,14 @@ QtObject { return userName.endsWith(".stateofus.eth") ? userName.substr(0, userName.length - 14) : userName } + function truncateName(name, num = 32) { + if (name.length <= num) { + return name; + } + + return name.slice(0, num) + "..."; + } + function isValidAddress(inputValue) { return inputValue !== "0x" && /^0x[a-fA-F0-9]{40}$/.test(inputValue) }