Skip to content
Permalink
Browse files
fix(highlight-and-scroll): fix edited comment time
  • Loading branch information
h13i32maru committed Jul 11, 2020
1 parent 43862df commit f36a4baf0c0786c222718d419aff9f5afa4121ec
Showing 1 changed file with 12 additions and 11 deletions.
@@ -46,7 +46,8 @@
}

async function replaceEditedTime() {
const editHistories = Array.from(document.querySelectorAll('.js-comment-edit-history > details'));
const editHistories = Array.from(document.querySelectorAll('.js-discussion details'))
.filter(el => el.querySelector('.js-comment-edit-history-menu'));
for (const editHistory of editHistories) {
editHistory.setAttribute('open', 'true');
// @ts-ignore
@@ -64,22 +65,22 @@
if (loadedCount === editHistories.length) break;
}

// replace
for (const comment of getComments()) {
const editedTimeEl = comment.querySelector('.js-comment-edit-history > details details-menu relative-time');
if (editedTimeEl) {
const editedTime = new Date(editedTimeEl.getAttribute('datetime'));
const timeEl = comment.querySelector('relative-time');
timeEl && timeEl.setAttribute('datetime', dateUTCFormat(editedTime));
}
}

// close
for (const editHistory of editHistories) {
editHistory.removeAttribute('open');
// @ts-ignore
editHistory.querySelector('details-menu').style.opacity = 1;
}

// replace
for (const comment of getComments()) {
const editedTimeEl = comment.querySelector('.js-comment-edit-history-menu relative-time');
if (!editedTimeEl) continue;

const editedTime = new Date(editedTimeEl.getAttribute('datetime'));
const timeEls = comment.querySelectorAll('relative-time');
for (const timeEl of timeEls) timeEl.setAttribute('datetime', dateUTCFormat(editedTime));
}
}

async function openResolvedThread() {

0 comments on commit f36a4ba

Please sign in to comment.