Skip to content

Commit

Permalink
fix(player): Fix duplicate logs when movie is finished
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 24, 2024
1 parent fdd0d57 commit f5e9c8d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func (p *Player) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case p.speed >= 0:
frameDiff = 1
if p.frame+frameDiff >= len(p.movie.Frames) {
p.log.Info().Msg("Finished movie")
return p, Quit
}
case p.frame <= 0:
Expand All @@ -96,7 +95,6 @@ func (p *Player) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
duration := p.movie.Frames[p.frame].CalcDuration(speed)
for duration < time.Second/15 {
if p.frame+frameDiff >= len(p.movie.Frames) {
p.log.Info().Msg("Finished movie")
return p, Quit
} else if p.frame+frameDiff <= 0 {
p.speed = 1
Expand Down Expand Up @@ -169,7 +167,11 @@ func (p *Player) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
case quitMsg:
p.log.Info().Msg("Disconnected early")
if p.frame >= len(p.movie.Frames)-1 {
p.log.Info().Msg("Finished movie")
} else {
p.log.Info().Msg("Disconnected early")
}
p.clearTimeouts()
p.zone.Close()
return p, tea.Quit //nolint:forbidigo
Expand Down

0 comments on commit f5e9c8d

Please sign in to comment.