Permalink
Browse files

fix(webview): outdated comment

  • Loading branch information...
h13i32maru committed Sep 2, 2018
1 parent 27431c1 commit a86f0f99433433176808a3dd7f694d3b5475fd03
@@ -1,6 +1,7 @@
(function(){
const containers = document.querySelectorAll('.outdated-comment, .outdated-diff-comment-container');
for (const container of Array.from(containers)) {
container.classList.add('open');
container.setAttribute('open', true);
container.classList.add('open'); // for old style(GHE ~2018.08)
}
})();
@@ -1,4 +1,4 @@
(function(){
(async function(){
const prevReadAt = _prevReadAt_;
function highlightComment(comment, prevReadAt) {
@@ -12,6 +12,33 @@
}
}
function sleep(msec) {
return new Promise((resolve) => {
setTimeout(resolve, msec);
});
}
// outdatedが非同期になってしまったので、一度openして中を読み込ませてから、処理を行う
// todo: GHEの場合、リクエストが増えるのが心配
{
const containers = document.querySelectorAll('.outdated-comment, .discussion-item');
if (containers.length) {
// outdatedしている箇所を一度openして、中身を読み込ませる
for (const container of Array.from(containers)) {
container.setAttribute('open', true);
container.removeAttribute('open');
}
// 最後のoutdatedの中が読み込まれるまで待機
const lastContainer = containers[containers.length - 1];
for (let i = 0; i < 10; i++) {
await sleep(100);
if (lastContainer.querySelector('.review-comment')) break;
}
}
}
{
const comments = document.querySelectorAll('.review-comment');
for (const comment of Array.from(comments)) {
@@ -37,7 +64,10 @@
const containers = document.querySelectorAll('.outdated-comment, .discussion-item');
for (const container of Array.from(containers)) {
const comment = container.querySelector('.highlight-comment');
if (comment) container.classList.add('open');
if (comment) {
container.setAttribute('open', true);
container.classList.add('open'); // for old style(GHE ~2018.08)
}
}
}
})();

0 comments on commit a86f0f9

Please sign in to comment.