fix: hour format and show timestamp on messages
This commit is contained in:
parent
f191f7fe8b
commit
a63da4889b
|
@ -36,7 +36,7 @@ Item {
|
||||||
case Constants.stickerType:
|
case Constants.stickerType:
|
||||||
return stickerId.height + 50
|
return stickerId.height + 50
|
||||||
default:
|
default:
|
||||||
return (isCurrentUser || (!isCurrentUser && authorCurrentMsg == authorPrevMsg) ? chatBox.height : 24 + chatBox.height)
|
return (isCurrentUser || (!isCurrentUser && authorCurrentMsg == authorPrevMsg) ? chatBox.height : 24 + chatBox.height) + 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,18 +311,22 @@ Item {
|
||||||
StyledTextEdit {
|
StyledTextEdit {
|
||||||
id: chatTime
|
id: chatTime
|
||||||
color: Theme.darkGrey
|
color: Theme.darkGrey
|
||||||
text: timestamp
|
text: {
|
||||||
|
let messageDate = new Date(Math.floor(timestamp))
|
||||||
|
let minutes = messageDate.getMinutes();
|
||||||
|
let hours = messageDate.getHours();
|
||||||
|
return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes)
|
||||||
|
}
|
||||||
anchors.top: contentType === Constants.stickerType ? stickerId.bottom : chatText.bottom
|
anchors.top: contentType === Constants.stickerType ? stickerId.bottom : chatText.bottom
|
||||||
|
anchors.topMargin: 8
|
||||||
anchors.bottomMargin: Theme.padding
|
anchors.bottomMargin: Theme.padding
|
||||||
anchors.right: !isCurrentUser ? parent.right : undefined
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: !isCurrentUser ? Theme.padding : 0
|
anchors.rightMargin: isCurrentUser ? 5 : Theme.padding
|
||||||
anchors.left: !isCurrentUser ? undefined : parent.left
|
|
||||||
anchors.leftMargin: !isCurrentUser ? 0 : Theme.padding
|
|
||||||
font.pixelSize: 10
|
font.pixelSize: 10
|
||||||
readOnly: true
|
readOnly: true
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
// Probably only want to show this when clicking?
|
// Probably only want to show this when clicking?
|
||||||
visible: false
|
visible: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,8 +94,11 @@ Rectangle {
|
||||||
let lastWeek = new Date()
|
let lastWeek = new Date()
|
||||||
lastWeek.setDate(now.getDate()-7)
|
lastWeek.setDate(now.getDate()-7)
|
||||||
|
|
||||||
|
let minutes = messageDate.getMinutes();
|
||||||
|
let hours = messageDate.getHours();
|
||||||
|
|
||||||
if (now.toDateString() == messageDate.toDateString()) {
|
if (now.toDateString() == messageDate.toDateString()) {
|
||||||
return messageDate.getHours() + ":" + (messageDate.getMinutes() < 10 ? "0" + messageDate.getMinutes() : messageDate.getMinutes())
|
return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes)
|
||||||
} else if (yesterday.toDateString() == messageDate.toDateString()) {
|
} else if (yesterday.toDateString() == messageDate.toDateString()) {
|
||||||
return qsTr("Yesterday")
|
return qsTr("Yesterday")
|
||||||
} else if (lastWeek.getTime() < messageDate.getTime()) {
|
} else if (lastWeek.getTime() < messageDate.getTime()) {
|
||||||
|
|
Loading…
Reference in New Issue