Browse Source

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>
for-closed-social
bobemoe 4 years ago
committed by GitHub
parent
commit
bac57ab590
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      models/issue_stopwatch.go

+ 15
- 0
models/issue_stopwatch.go View File

@ -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,

Loading…
Cancel
Save