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:
parent
8188176b58
commit
bac57ab590
1 changed files with 15 additions and 0 deletions
|
@ -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…
Reference in a new issue