Skip to content

Commit

Permalink
synchronously waits for timer to finish
Browse files Browse the repository at this point in the history
Signed-off-by: Omri Bornstein <[email protected]>
  • Loading branch information
AppleGamer22 committed Oct 21, 2024
1 parent 8569606 commit f942225
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"

"github.com/AppleGamer22/cocainate/commands"
Expand All @@ -12,5 +11,4 @@ func main() {
// _, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
fmt.Print("\r")
}
3 changes: 2 additions & 1 deletion progress_bar/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (m model) Update(message tea.Msg) (tea.Model, tea.Cmd) {
case time.Time:
m.percentage += m.amount
if m.percentage >= 1.0 {
m.percentage = 1.0
return m, quitMessage
}
return m, renderMessage()
Expand All @@ -70,7 +71,7 @@ func (m model) Update(message tea.Msg) (tea.Model, tea.Cmd) {
}

func (m model) View() string {
if m.percentage >= 1 {
if m.percentage >= 1.0 {
return ""
}
return fmt.Sprintf(
Expand Down
3 changes: 3 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (s *Session) Wait(quiet bool) error {
timer := time.NewTimer(s.Duration)
select {
case <-timer.C:
if !quiet {
program.Wait()
}
case <-s.Signals:
timer.Stop()
if !quiet {
Expand Down

0 comments on commit f942225

Please sign in to comment.