From f5e9c8d82b6044e5b7efaf84dda12e882ad511c0 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Fri, 24 May 2024 00:48:17 -0500 Subject: [PATCH] fix(player): Fix duplicate logs when movie is finished --- internal/player/player.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/player/player.go b/internal/player/player.go index 6d1381d3..0a538bbf 100644 --- a/internal/player/player.go +++ b/internal/player/player.go @@ -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: @@ -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 @@ -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