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 {
*tview.Flex
app *App
logs *Logger
indicator *LogIndicator
ansiWriter io.Writer
model *model.Log
cancelFn context.CancelFunc
cancelUpdates bool
mx sync.Mutex
follow bool
app *App
logs *Logger
indicator *LogIndicator
ansiWriter io.Writer
model *model.Log
cancelFn context.CancelFunc
cancelUpdates bool
mx sync.Mutex
follow bool
requestOneRefresh bool
}
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
}
if l.requestOneRefresh {
l.requestOneRefresh = false
}
for i := 0; i < len(lines); i++ {
if l.cancelUpdates {
break
@ -364,6 +368,7 @@ func (l *Log) sinceCmd(n int) func(evt *tcell.EventKey) *tcell.EventKey {
} else {
l.model.SetSinceSeconds(ctx, int64(n))
}
l.requestOneRefresh = true
l.updateTitle()
return nil