Skip to content

Commit

Permalink
When starting new stopwatch stop previous if it is still running (#10533
Browse files Browse the repository at this point in the history
)

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
  • Loading branch information
3 people authored Jul 12, 2020
1 parent 8188176 commit bac57ab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions models/issue_stopwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ func CreateOrStopIssueStopwatch(user *User, issue *Issue) error {
return err
}
} else {
//if another stopwatch is running: stop it
exists, sw, err := HasUserStopwatch(user.ID)
if err != nil {
return err
}
if exists {
issue, err := getIssueByID(x, sw.IssueID)
if err != nil {
return err
}
if err := CreateOrStopIssueStopwatch(user, issue); err != nil {
return err
}
}

// Create stopwatch
sw = &Stopwatch{
UserID: user.ID,
Expand Down

0 comments on commit bac57ab

Please sign in to comment.