mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Improve Stopwatch behavior (#18930)
- Don't send empty stopwatch over and over again, only send once. - Stop interval to update stopwatch's timer when there is no more stopwatch.
This commit is contained in:
@@ -9,7 +9,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/eventsource"
|
||||
)
|
||||
|
||||
// IssueStopwatch creates or stops a stopwatch for the given issue.
|
||||
@@ -59,6 +61,18 @@ func CancelStopwatch(c *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
stopwatches, err := models.GetUserStopwatches(c.Doer.ID, db.ListOptions{})
|
||||
if err != nil {
|
||||
c.ServerError("GetUserStopwatches", err)
|
||||
return
|
||||
}
|
||||
if len(stopwatches) == 0 {
|
||||
eventsource.GetManager().SendMessage(c.Doer.ID, &eventsource.Event{
|
||||
Name: "stopwatches",
|
||||
Data: "{}",
|
||||
})
|
||||
}
|
||||
|
||||
url := issue.HTMLURL()
|
||||
c.Redirect(url, http.StatusSeeOther)
|
||||
}
|
||||
|
Reference in New Issue
Block a user