When starting new stopwatch stop previous if it is still running (#10533)

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
tokarchuk/v1.17
bobemoe 4 years ago committed by GitHub
parent 8188176b58
commit bac57ab590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      models/issue_stopwatch.go

@ -101,6 +101,21 @@ func CreateOrStopIssueStopwatch(user *User, issue *Issue) error {
return err return err
} }
} else { } 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 // Create stopwatch
sw = &Stopwatch{ sw = &Stopwatch{
UserID: user.ID, UserID: user.ID,

Loading…
Cancel
Save