summaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtzfr.eu>2020-08-24 08:48:32 +0200
committerHubert Hirtz <hubert@hirtzfr.eu>2020-08-24 08:48:32 +0200
commit196baeb8d2ff63d34020fe3ae0d2cb61540ba280 (patch)
tree71d49cc502085b0140fe330317b32d80e62ec7f1 /app.go
parentFix topic time timezone (diff)
Only fetch history on JOIN and PgUp
Diffstat (limited to 'app.go')
-rw-r--r--app.go30
1 files 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