diff options
author | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-24 08:48:32 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-24 08:48:32 +0200 |
commit | 196baeb8d2ff63d34020fe3ae0d2cb61540ba280 (patch) | |
tree | 71d49cc502085b0140fe330317b32d80e62ec7f1 /app.go | |
parent | Fix topic time timezone (diff) |
Only fetch history on JOIN and PgUp
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 30 |
1 files changed, 11 insertions, 19 deletions
@@ -194,26 +194,32 @@ func (app *App) handleUIEvent(ev tcell.Event) { app.win.Resize() case tcell.KeyCtrlU, tcell.KeyPgUp: app.win.ScrollUp() - app.requestHistory() + if app.s == nil { + return + } + buffer := app.win.CurrentBuffer() + if app.win.IsAtTop() && buffer != ui.Home { + at := time.Now() + if t := app.win.CurrentBufferOldestTime(); t != nil { + at = *t + } + app.s.RequestHistory(buffer, at) + } case tcell.KeyCtrlD, tcell.KeyPgDn: app.win.ScrollDown() case tcell.KeyCtrlN: app.win.NextBuffer() - app.requestHistory() case tcell.KeyCtrlP: app.win.PreviousBuffer() - app.requestHistory() case tcell.KeyRight: if ev.Modifiers() == tcell.ModAlt { app.win.NextBuffer() - app.requestHistory() } else { app.win.InputRight() } case tcell.KeyLeft: if ev.Modifiers() == tcell.ModAlt { app.win.PreviousBuffer() - app.requestHistory() } else { app.win.InputLeft() } @@ -290,20 +296,6 @@ func (app *App) notifyHighlight(buffer, nick, content string) { } } -func (app *App) requestHistory() { - if app.s == nil { - return - } - buffer := app.win.CurrentBuffer() - if app.win.IsAtTop() && buffer != ui.Home { - at := time.Now() - if t := app.win.CurrentBufferOldestTime(); t != nil { - at = *t - } - app.s.RequestHistory(buffer, at) - } -} - func (app *App) typing() { if app.s == nil { return |