From 196baeb8d2ff63d34020fe3ae0d2cb61540ba280 Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Mon, 24 Aug 2020 08:48:32 +0200 Subject: Only fetch history on JOIN and PgUp --- app.go | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/app.go b/app.go index 78d3aea..a1bae85 100644 --- a/app.go +++ b/app.go @@ -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 -- cgit v1.2.3