mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-25 18:44:11 +01:00
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
|
||||
}
|
||||
} 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…
Reference in a new issue