From 408a77a7e2dcb1d8bcdd0627e8a7c04895c30d75 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 19 Jan 2023 11:17:14 -0500 Subject: [PATCH] fix(chat/messages): ensure there is only one label for given date Covers the case, where timestamps are missynchronized: ``` clock: 0 timestamp: 31.12.2022 10:00:00 clock: 1 timestamp: 01.01.2023 23:59:30 clock: 2 timestamp: 01.01.2023 23:59:45 clock: 3 timestamp: 02.01.2023 00:00:05 clock: 4 timestamp: 02.01.2023 00:00:10 clock: 5 timestamp: 01.01.2023 23:59:55 ``` Before, it would result in repeated labels: ``` clock: 0 timestamp: 31.12.2022 10:00:00 LABEL: 1.01.2023 clock: 1 timestamp: 01.01.2023 23:59:30 clock: 2 timestamp: 01.01.2023 23:59:45 LABEL: 2.01.2023 clock: 3 timestamp: 02.01.2023 00:00:05 clock: 4 timestamp: 02.01.2023 00:00:10 LABEL: 1.01.2023 clock: 5 timestamp: 01.01.2023 23:59:55 ``` fixes: #8962 --- ui/StatusQ/src/StatusQ/Components/StatusDateGroupLabel.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/StatusQ/src/StatusQ/Components/StatusDateGroupLabel.qml b/ui/StatusQ/src/StatusQ/Components/StatusDateGroupLabel.qml index 1764889db91..84781eb91fb 100644 --- a/ui/StatusQ/src/StatusQ/Components/StatusDateGroupLabel.qml +++ b/ui/StatusQ/src/StatusQ/Components/StatusDateGroupLabel.qml @@ -18,8 +18,8 @@ StatusBaseText { const currentMsgDate = new Date(messageTimestamp) const prevMsgDate = new Date(previousMessageTimestamp) - if (prevMsgDate > 0 && currentMsgDate.getDay() === prevMsgDate.getDay()) - return ""; + if (prevMsgDate > 0 && currentMsgDate.getDay() <= prevMsgDate.getDay()) + return "" const now = new Date(); // FIXME Qt6: replace with Intl.DateTimeFormat