diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatTime.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatTime.qml index 36682972b1..c65ecc1d9a 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatTime.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatTime.qml @@ -4,11 +4,11 @@ import "../../../../../shared/status" import "../../../../../imports" StyledText { - property bool formatDateTime: false + property bool formatAge: false id: chatTime visible: isMessage color: Style.current.secondaryText - text: formatDateTime ? Utils.formatDateTime(timestamp, globalSettings.locale) : Utils.formatTime(timestamp, globalSettings.locale) + text: formatAge ? Utils.formatAgeFromTime(timestamp) : Utils.formatTime(timestamp) font.pixelSize: Style.current.asideTextFontSize StatusToolTip { diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/StatusUpdate.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/StatusUpdate.qml index 71c55a189f..d23019b9f7 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/StatusUpdate.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/StatusUpdate.qml @@ -49,7 +49,7 @@ MouseArea { ChatTime { id: chatTime - formatDateTime: true + formatAge: true visible: chatName.visible anchors.verticalCenter: chatName.verticalCenter anchors.left: chatName.right diff --git a/ui/app/AppLayouts/Timeline/TimelineLayout.qml b/ui/app/AppLayouts/Timeline/TimelineLayout.qml index cb83c3c88b..b158eb391a 100644 --- a/ui/app/AppLayouts/Timeline/TimelineLayout.qml +++ b/ui/app/AppLayouts/Timeline/TimelineLayout.qml @@ -96,7 +96,7 @@ ScrollView { anchors.top: statusUpdateInput.bottom anchors.topMargin: 40 anchors.horizontalCenter: parent.horizontalCenter - visible: chatsModel.messageView.messageList.rowCount() === 0 + visible: chatLogView.count === 0 } ListView { diff --git a/ui/imports/Utils.qml b/ui/imports/Utils.qml index cd7429bc4f..e47b77c098 100644 --- a/ui/imports/Utils.qml +++ b/ui/imports/Utils.qml @@ -244,6 +244,25 @@ QtObject { return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) } + function formatAgeFromTime(timestamp) { + const now = new Date() + const messageDate = new Date(Math.floor(timestamp)) + const diffMs = now - messageDate + const diffMin = Math.floor(diffMs / 60000) + if (diffMin < 1) { + return qsTr("NOW") + } + const diffHour = Math.floor(diffMin / 60) + if (diffHour < 1) { + return qsTr("%1M").arg(diffMin) + } + const diffDay = Math.floor(diffHour / 24) + if (diffDay < 1) { + return qsTr("%1H").arg(diffHour) + } + return qsTr("%1D").arg(diffDay) + } + function formatShortDateStr(longStr) { const dmKeys = { // Days