fix: trigger a single log refresh after changing 'since' (#2202)

mine
MrLuje 2023-11-12 18:07:46 +01:00 committed by GitHub
parent b3029eefbd
commit a2a7544a6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 10 deletions

View File

@ -33,15 +33,16 @@ const (
type Log struct { type Log struct {
*tview.Flex *tview.Flex
app *App app *App
logs *Logger logs *Logger
indicator *LogIndicator indicator *LogIndicator
ansiWriter io.Writer ansiWriter io.Writer
model *model.Log model *model.Log
cancelFn context.CancelFunc cancelFn context.CancelFunc
cancelUpdates bool cancelUpdates bool
mx sync.Mutex mx sync.Mutex
follow bool follow bool
requestOneRefresh bool
} }
var _ model.Component = (*Log)(nil) var _ model.Component = (*Log)(nil)
@ -338,9 +339,12 @@ func (l *Log) Flush(lines [][]byte) {
} }
}() }()
if len(lines) == 0 || !l.indicator.AutoScroll() || l.cancelUpdates { if len(lines) == 0 || (!l.requestOneRefresh && !l.indicator.AutoScroll()) || l.cancelUpdates {
return return
} }
if l.requestOneRefresh {
l.requestOneRefresh = false
}
for i := 0; i < len(lines); i++ { for i := 0; i < len(lines); i++ {
if l.cancelUpdates { if l.cancelUpdates {
break break
@ -364,6 +368,7 @@ func (l *Log) sinceCmd(n int) func(evt *tcell.EventKey) *tcell.EventKey {
} else { } else {
l.model.SetSinceSeconds(ctx, int64(n)) l.model.SetSinceSeconds(ctx, int64(n))
} }
l.requestOneRefresh = true
l.updateTitle() l.updateTitle()
return nil return nil