Skip to content

Commit 7dc48f0

Browse files
committed
fix ui
1 parent 7062121 commit 7dc48f0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

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)