mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-23 12:08:53 +00:00
fix(@desktop/timeline): render message age instead of message time
This commit is contained in:
parent
9d4fa890b4
commit
1cc8d768b8
@ -4,11 +4,11 @@ import "../../../../../shared/status"
|
|||||||
import "../../../../../imports"
|
import "../../../../../imports"
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
property bool formatDateTime: false
|
property bool formatAge: false
|
||||||
id: chatTime
|
id: chatTime
|
||||||
visible: isMessage
|
visible: isMessage
|
||||||
color: Style.current.secondaryText
|
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
|
font.pixelSize: Style.current.asideTextFontSize
|
||||||
|
|
||||||
StatusToolTip {
|
StatusToolTip {
|
||||||
|
@ -49,7 +49,7 @@ MouseArea {
|
|||||||
|
|
||||||
ChatTime {
|
ChatTime {
|
||||||
id: chatTime
|
id: chatTime
|
||||||
formatDateTime: true
|
formatAge: true
|
||||||
visible: chatName.visible
|
visible: chatName.visible
|
||||||
anchors.verticalCenter: chatName.verticalCenter
|
anchors.verticalCenter: chatName.verticalCenter
|
||||||
anchors.left: chatName.right
|
anchors.left: chatName.right
|
||||||
|
@ -96,7 +96,7 @@ ScrollView {
|
|||||||
anchors.top: statusUpdateInput.bottom
|
anchors.top: statusUpdateInput.bottom
|
||||||
anchors.topMargin: 40
|
anchors.topMargin: 40
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
visible: chatsModel.messageView.messageList.rowCount() === 0
|
visible: chatLogView.count === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
|
@ -244,6 +244,25 @@ QtObject {
|
|||||||
return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes)
|
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) {
|
function formatShortDateStr(longStr) {
|
||||||
const dmKeys = {
|
const dmKeys = {
|
||||||
// Days
|
// Days
|
||||||
|
Loading…
x
Reference in New Issue
Block a user