From a63da4889badc82f2a8687fcfe0c73126bc4ec45 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Wed, 1 Jul 2020 09:47:15 -0400 Subject: [PATCH] fix: hour format and show timestamp on messages --- ui/app/AppLayouts/Chat/ChatColumn/Message.qml | 18 +++++++++++------- .../AppLayouts/Chat/ContactsColumn/Channel.qml | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml index faeb6e3877..0d4ccac2f3 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml @@ -36,7 +36,7 @@ Item { case Constants.stickerType: return stickerId.height + 50 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 { id: chatTime 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.topMargin: 8 anchors.bottomMargin: Theme.padding - anchors.right: !isCurrentUser ? parent.right : undefined - anchors.rightMargin: !isCurrentUser ? Theme.padding : 0 - anchors.left: !isCurrentUser ? undefined : parent.left - anchors.leftMargin: !isCurrentUser ? 0 : Theme.padding + anchors.right: parent.right + anchors.rightMargin: isCurrentUser ? 5 : Theme.padding font.pixelSize: 10 readOnly: true selectByMouse: true // Probably only want to show this when clicking? - visible: false + visible: true } } } diff --git a/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml b/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml index ff88d65804..9aa2a90987 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml @@ -94,8 +94,11 @@ Rectangle { let lastWeek = new Date() lastWeek.setDate(now.getDate()-7) + let minutes = messageDate.getMinutes(); + let hours = messageDate.getHours(); + 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()) { return qsTr("Yesterday") } else if (lastWeek.getTime() < messageDate.getTime()) {