Skip to content

Commit

Permalink
fix(chat/messages): ensure there is only one label for given date
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jrainville committed Jan 19, 2023
1 parent 934c797 commit 408a77a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ui/StatusQ/src/StatusQ/Components/StatusDateGroupLabel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 408a77a

Please sign in to comment.