perf(chatScroll): Optimise timestamps
The date parsing is time consuming and it needs to be used with care in the delegate perf(chatScroll): Fix StatusDateGroupLabel comment - standaloneMonthName perf(chatScroll): fix comments on Optimise timestamps perf(chatScroll): Optimise timestamps - bring back comment perf(chatScroll): fix activity notification
This commit is contained in:
parent
bf1d59c0ad
commit
719e0a34f6
|
@ -18,17 +18,20 @@ StatusBaseText {
|
||||||
if (messageTimestamp === 0)
|
if (messageTimestamp === 0)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
const currentMsgDate = new Date(messageTimestamp)
|
const msInADay = 86400000
|
||||||
const prevMsgDate = new Date(previousMessageTimestamp)
|
const lastMessageInDays = Math.floor(previousMessageTimestamp / msInADay)
|
||||||
|
const currentMessageInDays = Math.floor(messageTimestamp / msInADay)
|
||||||
if (prevMsgDate > 0 && currentMsgDate.getDay() <= prevMsgDate.getDay())
|
if(previousMessageTimestamp > 0 && currentMessageInDays <= lastMessageInDays)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
const now = new Date();
|
let date = new Date()
|
||||||
|
const currentYear = date.getFullYear()
|
||||||
|
date.setTime(messageTimestamp)
|
||||||
|
|
||||||
// FIXME Qt6: replace with Intl.DateTimeFormat
|
// FIXME Qt6: replace with Intl.DateTimeFormat
|
||||||
const monthName = Qt.locale().standaloneMonthName(currentMsgDate.getMonth(), Locale.LongFormat)
|
const monthName = Qt.locale().standaloneMonthName(date.getMonth(), Locale.LongFormat)
|
||||||
if (now.getFullYear() > currentMsgDate.getFullYear())
|
if (currentYear > date.getFullYear())
|
||||||
return "%1 %2, %3".arg(monthName).arg(currentMsgDate.getDate()).arg(currentMsgDate.getFullYear())
|
return "%1 %2, %3".arg(monthName).arg(date.getDate()).arg(date.getFullYear())
|
||||||
return "%1, %2".arg(monthName).arg(currentMsgDate.getDate())
|
return "%1, %2".arg(monthName).arg(date.getDate())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,6 @@ Control {
|
||||||
property StatusMessageDetails messageDetails: StatusMessageDetails {}
|
property StatusMessageDetails messageDetails: StatusMessageDetails {}
|
||||||
property StatusMessageDetails replyDetails: StatusMessageDetails {}
|
property StatusMessageDetails replyDetails: StatusMessageDetails {}
|
||||||
|
|
||||||
property string timestampString: LocaleUtils.formatTime(timestamp, Locale.ShortFormat)
|
|
||||||
property string timestampTooltipString: LocaleUtils.formatDateTime(timestamp)
|
|
||||||
|
|
||||||
signal clicked(var sender, var mouse)
|
signal clicked(var sender, var mouse)
|
||||||
signal profilePictureClicked(var sender, var mouse)
|
signal profilePictureClicked(var sender, var mouse)
|
||||||
signal senderNameClicked(var sender, var mouse)
|
signal senderNameClicked(var sender, var mouse)
|
||||||
|
@ -250,8 +247,7 @@ Control {
|
||||||
resendError: root.messageDetails.amISender && !editMode ? root.resendError : ""
|
resendError: root.messageDetails.amISender && !editMode ? root.resendError : ""
|
||||||
onClicked: root.senderNameClicked(sender, mouse)
|
onClicked: root.senderNameClicked(sender, mouse)
|
||||||
onResendClicked: root.resendClicked()
|
onResendClicked: root.resendClicked()
|
||||||
timestamp.text: root.timestampString
|
timestamp: root.timestamp
|
||||||
timestamp.tooltip.text: root.timestampTooltipString
|
|
||||||
displayNameClickable: root.profileClickable
|
displayNameClickable: root.profileClickable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,6 +327,7 @@ Control {
|
||||||
active: root.messageDetails.contentType === StatusMessage.ContentType.Invitation && !editMode
|
active: root.messageDetails.contentType === StatusMessage.ContentType.Invitation && !editMode
|
||||||
visible: active
|
visible: active
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.rightMargin: 16
|
Layout.rightMargin: 16
|
||||||
|
|
|
@ -15,9 +15,7 @@ Item {
|
||||||
property StatusMessageSenderDetails sender: StatusMessageSenderDetails { }
|
property StatusMessageSenderDetails sender: StatusMessageSenderDetails { }
|
||||||
|
|
||||||
property alias displayNameLabel: primaryDisplayName
|
property alias displayNameLabel: primaryDisplayName
|
||||||
property alias secondaryNameLabel: secondaryDisplayName
|
property double timestamp: 0
|
||||||
property alias tertiaryDetailsLabel: tertiaryDetailText
|
|
||||||
property alias timestamp: timestampText
|
|
||||||
|
|
||||||
property string tertiaryDetail: sender.id
|
property string tertiaryDetail: sender.id
|
||||||
property string resendText: qsTr("Resend")
|
property string resendText: qsTr("Resend")
|
||||||
|
@ -110,6 +108,7 @@ Item {
|
||||||
StatusTimeStampLabel {
|
StatusTimeStampLabel {
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
id: timestampText
|
id: timestampText
|
||||||
|
timestamp: root.timestamp
|
||||||
}
|
}
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
|
@ -5,11 +5,13 @@ import StatusQ.Core 0.1
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
property alias tooltip: tooltip
|
id: root
|
||||||
|
property double timestamp: 0
|
||||||
|
|
||||||
color: Theme.palette.baseColor1
|
color: Theme.palette.baseColor1
|
||||||
font.pixelSize: 10
|
font.pixelSize: 10
|
||||||
visible: !!text
|
visible: !!text
|
||||||
|
text: LocaleUtils.formatTime(timestamp, Locale.ShortFormat)
|
||||||
StatusToolTip {
|
StatusToolTip {
|
||||||
id: tooltip
|
id: tooltip
|
||||||
visible: hhandler.hovered && !!text
|
visible: hhandler.hovered && !!text
|
||||||
|
@ -17,5 +19,10 @@ StatusBaseText {
|
||||||
}
|
}
|
||||||
HoverHandler {
|
HoverHandler {
|
||||||
id: hhandler
|
id: hhandler
|
||||||
|
onHoveredChanged: {
|
||||||
|
if(hhandler.hovered && timestamp) {
|
||||||
|
tooltip.text = LocaleUtils.formatDateTime(timestamp)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,7 @@ StatusDialog {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property StatusMessageDetails messageDetails
|
property StatusMessageDetails messageDetails
|
||||||
property string timestampString
|
property double timestamp: 0
|
||||||
property string timestampTooltipString
|
|
||||||
|
|
||||||
signal accepted
|
signal accepted
|
||||||
signal declined
|
signal declined
|
||||||
|
@ -58,8 +57,7 @@ StatusDialog {
|
||||||
amISender: root.messageDetails.amISender
|
amISender: root.messageDetails.amISender
|
||||||
messageOriginInfo: root.messageDetails.messageOriginInfo
|
messageOriginInfo: root.messageDetails.messageOriginInfo
|
||||||
tertiaryDetail: Utils.getElidedCompressedPk(sender.id)
|
tertiaryDetail: Utils.getElidedCompressedPk(sender.id)
|
||||||
timestamp.text: root.timestampString
|
timestamp: root.timestamp
|
||||||
timestamp.tooltip.text: root.timestampTooltipString
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
|
|
@ -72,8 +72,7 @@ ActivityNotificationMessage {
|
||||||
onDetailsClicked: {
|
onDetailsClicked: {
|
||||||
Global.openPopup(reviewContactRequestPopupComponent, {
|
Global.openPopup(reviewContactRequestPopupComponent, {
|
||||||
messageDetails: root.messageDetails,
|
messageDetails: root.messageDetails,
|
||||||
timestampString: root.timestampString,
|
timestamp: notification ? notification.timestamp : 0
|
||||||
timestampTooltipString: root.timestampTooltipString
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ ActivityNotificationBase {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
maximumLineCount: root.maximumLineCount
|
maximumLineCount: root.maximumLineCount
|
||||||
messageDetails: root.messageDetails
|
messageDetails: root.messageDetails
|
||||||
timestamp: notification ? notification.timestamp : ""
|
timestamp: notification ? notification.timestamp : 0
|
||||||
messageSubheaderComponent: root.messageSubheaderComponent
|
messageSubheaderComponent: root.messageSubheaderComponent
|
||||||
messageBadgeComponent: root.messageBadgeComponent
|
messageBadgeComponent: root.messageBadgeComponent
|
||||||
onOpenProfilePopup: root.openProfilePopup()
|
onOpenProfilePopup: root.openProfilePopup()
|
||||||
|
|
|
@ -25,9 +25,6 @@ RowLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property string timestampString: timestamp ? LocaleUtils.formatTime(timestamp, Locale.ShortFormat) : ""
|
|
||||||
readonly property string timestampTooltipString: timestamp ? LocaleUtils.formatDateTime(timestamp) : ""
|
|
||||||
|
|
||||||
signal openProfilePopup()
|
signal openProfilePopup()
|
||||||
|
|
||||||
spacing: 8
|
spacing: 8
|
||||||
|
@ -64,8 +61,7 @@ RowLayout {
|
||||||
amISender: root.messageDetails.amISender
|
amISender: root.messageDetails.amISender
|
||||||
messageOriginInfo: root.messageDetails.messageOriginInfo
|
messageOriginInfo: root.messageDetails.messageOriginInfo
|
||||||
tertiaryDetail: Utils.getElidedCompressedPk(sender.id)
|
tertiaryDetail: Utils.getElidedCompressedPk(sender.id)
|
||||||
timestamp.text: root.timestampString
|
timestamp: root.timestamp
|
||||||
timestamp.tooltip.text: root.timestampTooltipString
|
|
||||||
onClicked: root.openProfilePopup()
|
onClicked: root.openProfilePopup()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue