Skip to content

Commit

Permalink
feat: support time skip search
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Nov 6, 2023
1 parent 045f04a commit 55410ee
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion pkg/mux/screen/replay/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ func TestTimeJump(t *testing.T) {
r, i := createTest(e)
i(size)
r.gotoIndex(1, -1)
r.skipInactivity = false
i(ActionSearchForward, "+5m", "enter")
require.Equal(t, e[0].Stamp.Add(5*time.Minute), r.currentTime)
i(ActionSearchForward, "-5m", "enter")
Expand Down
2 changes: 1 addition & 1 deletion pkg/mux/screen/replay/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (r *Replay) handleSearchInput(msg tea.Msg) (taro.Model, tea.Cmd) {
r.searchInput.Reset()

if match := TIME_DELTA_REGEX.FindStringSubmatch(value); match != nil {
r.setTimeDelta(parseTimeDelta(match))
r.setTimeDelta(parseTimeDelta(match), false)
return r, nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/mux/screen/replay/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func parseTimeDelta(delta []string) (result time.Duration) {
return
}

func (r *Replay) setTimeDelta(delta time.Duration) {
func (r *Replay) setTimeDelta(delta time.Duration, skipInactivity bool) {
if len(r.events) == 0 {
return
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func (r *Replay) setTimeDelta(delta time.Duration) {
return
}

if !r.skipInactivity {
if !skipInactivity {
r.currentTime = newTime
return
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/mux/screen/replay/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ func (r *Replay) Update(msg tea.Msg) (taro.Model, tea.Cmd) {
return r, nil
}

r.setTimeDelta(time.Duration(int64(time.Now().Sub(msg.Since)) * int64(r.playbackRate)))
delta := int64(time.Now().Sub(msg.Since)) * int64(r.playbackRate)
r.setTimeDelta(
time.Duration(delta),
r.skipInactivity,
)

return r.scheduleUpdate()
case tea.WindowSizeMsg:
Expand Down

0 comments on commit 55410ee

Please sign in to comment.