Skip to content

Commit d1f8ad1

Browse files
committed
fix ui & test
1 parent 7062121 commit d1f8ad1

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

routers/web/repo/issue_view.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ func ViewIssue(ctx *context.Context) {
426426
return user_service.CanBlockUser(ctx, ctx.Doer, blocker, blockee)
427427
}
428428

429-
if !issue.PullRequest.IsChecking() && !setting.IsProd {
429+
if issue.PullRequest != nil && !issue.PullRequest.IsChecking() && !setting.IsProd {
430430
ctx.Data["PullMergeBoxReloadingInterval"] = 1 // in dev env, force using the reloading logic to make sure it won't break
431431
}
432432

@@ -870,7 +870,7 @@ func preparePullViewReviewAndMerge(ctx *context.Context, issue *issues_model.Iss
870870
}
871871
}
872872

873-
ctx.Data["PullMergeBoxReloadingInterval"] = util.Iif(issue.PullRequest.IsChecking(), 2000, 0)
873+
ctx.Data["PullMergeBoxReloadingInterval"] = util.Iif(pull != nil && pull.IsChecking(), 2000, 0)
874874
ctx.Data["CanWriteToHeadRepo"] = canWriteToHeadRepo
875875
ctx.Data["ShowMergeInstructions"] = canWriteToHeadRepo
876876
ctx.Data["AllowMerge"] = allowMerge

web_src/js/features/repo-issue-pull.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,26 @@ export function initRepoPullMergeBox(el: HTMLElement) {
108108
if (timerId) return;
109109
setTimeout(reloadMergeBox, reloadingInterval);
110110
};
111+
const onVisibilityChange = () => {
112+
if (document.hidden) {
113+
stopReloading();
114+
} else {
115+
startReloading();
116+
}
117+
};
111118
reloadMergeBox = async () => {
112119
const resp = await GET(`${pullLink}/merge_box`);
113120
stopReloading();
114121
if (!resp.ok) {
115122
startReloading();
116123
return;
117124
}
118-
const respHtml = await resp.text();
119-
const newElem = createElementFromHTML(respHtml);
125+
document.removeEventListener('visibilitychange', onVisibilityChange);
126+
const newElem = createElementFromHTML(await resp.text());
120127
executeScripts(newElem);
121128
el.replaceWith(newElem);
122129
};
123-
const onVisibilityChange = () => {
124-
if (document.hidden) {
125-
stopReloading();
126-
} else {
127-
startReloading();
128-
}
129-
};
130+
130131
document.addEventListener('visibilitychange', onVisibilityChange);
131132
startReloading();
132133
}

0 commit comments

Comments
 (0)