stop timer on closing issues/PRs too
This commit is contained in:
parent
58edfc93a3
commit
88beb1cef8
|
@ -1035,6 +1035,12 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
|
|||
if err := issue.ChangeStatus(ctx.User, ctx.Repo.Repository, form.Status == "close"); err != nil {
|
||||
log.Error(4, "ChangeStatus: %v", err)
|
||||
} else {
|
||||
|
||||
if err := stopTimerIfAvailable(ctx.User, issue); err != nil {
|
||||
ctx.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
|
||||
log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
|
||||
|
||||
notification.Service.NotifyIssue(issue, ctx.User.ID)
|
||||
|
|
|
@ -534,11 +534,9 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
|
|||
return
|
||||
}
|
||||
|
||||
if models.StopwatchExists(ctx.User.ID, issue.ID) {
|
||||
if err := models.CreateOrStopIssueStopwatch(ctx.User, issue); err != nil {
|
||||
ctx.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
if err := stopTimerIfAvailable(ctx.User, issue); err != nil {
|
||||
ctx.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
|
||||
notification.Service.NotifyIssue(pr.Issue, ctx.User.ID)
|
||||
|
@ -547,6 +545,17 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
|
||||
}
|
||||
|
||||
func stopTimerIfAvailable(user *models.User, issue *models.Issue) error {
|
||||
|
||||
if models.StopwatchExists(user.ID, issue.ID) {
|
||||
if err := models.CreateOrStopIssueStopwatch(user, issue); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ParseCompareInfo parse compare info between two commit for preparing pull request
|
||||
func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *git.Repository, *git.PullRequestInfo, string, string) {
|
||||
baseRepo := ctx.Repo.Repository
|
||||
|
|
Loading…
Reference in New Issue
Block a user