summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/issue_stopwatch.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/models/issue_stopwatch.go b/models/issue_stopwatch.go
index ca92141157..79ce48c4cd 100644
--- a/models/issue_stopwatch.go
+++ b/models/issue_stopwatch.go
@@ -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,