commit 3904c91
Hubert Hirtz
·
2021-11-29 08:35:45 +0000 UTC
parent 24a84fa
Use second precision for bound computation Should solve duplicates on servers that don't store message stamps with the full millisecond precision offered by the time tag (e.g. soju)
1 files changed,
+10,
-8
M
app.go
M
app.go
+10,
-8
1@@ -34,16 +34,17 @@ type bound struct {
2
3 // Compare returns 0 if line is within bounds, -1 if before, 1 if after.
4 func (b *bound) Compare(line *ui.Line) int {
5- if line.At.Before(b.first) {
6+ at := line.At.Truncate(time.Second)
7+ if at.Before(b.first) {
8 return -1
9 }
10- if line.At.After(b.last) {
11+ if at.After(b.last) {
12 return 1
13 }
14- if line.At.Equal(b.first) && line.Body.String() != b.firstMessage {
15+ if at.Equal(b.first) && line.Body.String() != b.firstMessage {
16 return -1
17 }
18- if line.At.Equal(b.last) && line.Body.String() != b.lastMessage {
19+ if at.Equal(b.last) && line.Body.String() != b.lastMessage {
20 return -1
21 }
22 return 0
23@@ -54,11 +55,12 @@ func (b *bound) Update(line *ui.Line) {
24 if line.At.IsZero() {
25 return
26 }
27- if b.first.IsZero() || line.At.Before(b.first) {
28- b.first = line.At
29+ at := line.At.Truncate(time.Second)
30+ if b.first.IsZero() || at.Before(b.first) {
31+ b.first = at
32 b.firstMessage = line.Body.String()
33- } else if b.last.IsZero() || line.At.After(b.last) {
34- b.last = line.At
35+ } else if b.last.IsZero() || at.After(b.last) {
36+ b.last = at
37 b.lastMessage = line.Body.String()
38 }
39 }