mirror of
1
Fork 0

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>
This commit is contained in:
bobemoe 2020-07-12 11:01:20 +01:00 committed by GitHub
parent 8188176b58
commit bac57ab590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

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,