commit 7e1cdf8
Hubert Hirtz
·
2020-08-22 12:49:19 +0000 UTC
parent 271ec48
Fix same messages being fetched with CHATHISTORY The issue was that Message.Time() converted the timestamp to Local time, and this local timestamp was being used with UTC timestamps. Thus senpai now converts the time only during display. Moreover, to avoid missing messages in history (and at the cost of duplicates), the condition in bufferList.AddLines() as been modified.
3 files changed,
+5,
-7
+1,
-1
1@@ -361,7 +361,7 @@ func (s *Session) requestHistory(act actionRequestHistory) (err error) {
2 }
3
4 t := act.Before
5- err = s.send("CHATHISTORY BEFORE %s timestamp=%04d-%02d-%02dT%02d:%02d:%02d.%03dZ 100\r\n", act.Target, t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond()/1e6)
6+ err = s.send("CHATHISTORY BEFORE %s timestamp=%04d-%02d-%02dT%02d:%02d:%02d.%03dZ 100\r\n", act.Target, t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second()+1, t.Nanosecond()/1e6)
7
8 return
9 }
+0,
-2
1@@ -306,8 +306,6 @@ func (msg *Message) Time() (t time.Time, ok bool) {
2 }
3
4 t = time.Date(year, time.Month(month), day, hour, minute, second, millis*1e6, time.UTC)
5- t = t.Local()
6-
7 return
8 }
9
+4,
-4
1@@ -230,7 +230,7 @@ func (b *buffer) DrawLines(screen tcell.Screen, width, height, nickColWidth int)
2 }
3
4 if i == 0 || b.lines[i-1].at.Truncate(time.Minute) != line.at.Truncate(time.Minute) {
5- printTime(screen, 0, y0, st.Bold(true), line.at)
6+ printTime(screen, 0, y0, st.Bold(true), line.at.Local())
7 }
8
9 head := truncate(line.head, nickColWidth, "\u2026")
10@@ -383,9 +383,9 @@ func (bs *bufferList) AddLines(title string, lines []Line) {
11 limit := len(lines)
12
13 if 0 < len(b.lines) {
14- firstLineTime := b.lines[0].at.Round(time.Millisecond)
15- for i := len(lines) - 1; 0 <= i; i-- {
16- if firstLineTime == lines[i].at.Round(time.Millisecond) {
17+ firstLineTime := b.lines[0].at.Unix()
18+ for i, l := range lines {
19+ if firstLineTime < l.at.Unix() {
20 limit = i
21 break
22 }