Add a tap-to-change date format for messages, fixes #47
This commit is contained in:
parent
179ef885b5
commit
1b345a6654
2 changed files with 19 additions and 6 deletions
|
@ -160,6 +160,10 @@ function getDateTimeElapsed(timestamp) {
|
||||||
return Format.formatDate(new Date(timestamp * 1000), Formatter.DurationElapsed);
|
return Format.formatDate(new Date(timestamp * 1000), Formatter.DurationElapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDateTimeTranslated(timestamp) {
|
||||||
|
return new Date(timestamp * 1000).toLocaleString();
|
||||||
|
}
|
||||||
|
|
||||||
function MessageInsertion(offset, insertionString, removeLength) {
|
function MessageInsertion(offset, insertionString, removeLength) {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.insertionString = insertionString;
|
this.insertionString = insertionString;
|
||||||
|
|
|
@ -91,7 +91,7 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMessageStatusText(message, listItemIndex, lastReadSentIndex) {
|
function getMessageStatusText(message, listItemIndex, lastReadSentIndex, useElapsed) {
|
||||||
var messageStatusSuffix = "";
|
var messageStatusSuffix = "";
|
||||||
if(!message) {
|
if(!message) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -120,7 +120,7 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Functions.getDateTimeElapsed(message.date) + messageStatusSuffix;
|
return ( useElapsed ? Functions.getDateTimeElapsed(message.date) : Functions.getDateTimeTranslated(message.date) ) + messageStatusSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAttachmentPreviewRow() {
|
function clearAttachmentPreviewRow() {
|
||||||
|
@ -611,12 +611,12 @@ Page {
|
||||||
|
|
||||||
onLastReadSentMessageUpdated: {
|
onLastReadSentMessageUpdated: {
|
||||||
console.log("[ChatModel] Messages in this chat were read, new last read: " + lastReadSentIndex + ", updating description for index " + index + ", status: " + (index <= lastReadSentIndex));
|
console.log("[ChatModel] Messages in this chat were read, new last read: " + lastReadSentIndex + ", updating description for index " + index + ", status: " + (index <= lastReadSentIndex));
|
||||||
messageDateText.text = getMessageStatusText(display, index, lastReadSentIndex);
|
messageDateText.text = getMessageStatusText(display, index, lastReadSentIndex, messageDateText.useElapsed);
|
||||||
}
|
}
|
||||||
onMessageUpdated: {
|
onMessageUpdated: {
|
||||||
if (index === modelIndex) {
|
if (index === modelIndex) {
|
||||||
console.log("[ChatModel] This message was updated, index " + index + ", updating content...");
|
console.log("[ChatModel] This message was updated, index " + index + ", updating content...");
|
||||||
messageDateText.text = getMessageStatusText(display, index, chatView.lastReadSentIndex);
|
messageDateText.text = getMessageStatusText(display, index, chatView.lastReadSentIndex, messageDateText.useElapsed);
|
||||||
messageText.text = Emoji.emojify(Functions.getMessageText(display, false, messageListItem.isOwnMessage), messageText.font.pixelSize);
|
messageText.text = Emoji.emojify(Functions.getMessageText(display, false, messageListItem.isOwnMessage), messageText.font.pixelSize);
|
||||||
if(locationPreviewLoader.active && locationPreviewLoader.status === Loader.Ready) {
|
if(locationPreviewLoader.active && locationPreviewLoader.status === Loader.Ready) {
|
||||||
locationPreviewLoader.item.locationData = display.content.location;
|
locationPreviewLoader.item.locationData = display.content.location;
|
||||||
|
@ -878,7 +878,7 @@ Page {
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
messageDateText.text = getMessageStatusText(display, index, chatView.lastReadSentIndex);
|
messageDateText.text = getMessageStatusText(display, index, chatView.lastReadSentIndex, messageDateText.useElapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,11 +886,20 @@ Page {
|
||||||
Text {
|
Text {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
|
property bool useElapsed: true
|
||||||
|
|
||||||
id: messageDateText
|
id: messageDateText
|
||||||
font.pixelSize: Theme.fontSizeTiny
|
font.pixelSize: Theme.fontSizeTiny
|
||||||
color: messageListItem.isOwnMessage ? Theme.secondaryHighlightColor : Theme.secondaryColor
|
color: messageListItem.isOwnMessage ? Theme.secondaryHighlightColor : Theme.secondaryColor
|
||||||
horizontalAlignment: messageListItem.isOwnMessage ? Text.AlignRight : Text.AlignLeft
|
horizontalAlignment: messageListItem.isOwnMessage ? Text.AlignRight : Text.AlignLeft
|
||||||
text: getMessageStatusText(display, index, chatView.lastReadSentIndex)
|
text: getMessageStatusText(display, index, chatView.lastReadSentIndex, messageDateText.useElapsed)
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
messageDateText.useElapsed = !messageDateText.useElapsed;
|
||||||
|
messageDateText.text = getMessageStatusText(display, index, chatView.lastReadSentIndex, messageDateText.useElapsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue