Skip to content

Commit

Permalink
Check every second to redraw pickers
Browse files Browse the repository at this point in the history
  • Loading branch information
tgolen committed Aug 14, 2024
1 parent 09bcb06 commit 4bf4869
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/js/lib/pages/github/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,27 +153,19 @@ export default function () {
}
allreadySetup = true;

let refreshPickerTimeoutID;
let refreshAssigneesTimeoutID;
// Draw them once when the page is loaded
setTimeout(refreshPicker, 500);
setTimeout(refreshAssignees, 500);

// Listen for when the sidebar is redrawn, then redraw our pickers
$(document).bind('DOMNodeRemoved', (e) => {
if ($(e.target).hasClass('sidebar-assignee')) {
// Make sure that only one setTimeout runs at a time
clearTimeout(refreshAssigneesTimeoutID);
refreshAssigneesTimeoutID = setTimeout(refreshAssignees, 500);
// Every second, check to see if the pickers are still there, and if not, redraw them
setInterval(() => {
if (!$('.k2picker-wrapper').length) {
refreshPicker();
}

if ($(e.target).is('#partial-discussion-sidebar')) {
// Make sure that only one setTimeout runs at a time
clearTimeout(refreshPickerTimeoutID);
refreshPickerTimeoutID = setTimeout(refreshPicker, 500);
clearTimeout(refreshAssigneesTimeoutID);
refreshAssigneesTimeoutID = setTimeout(refreshAssignees, 500);
if (!$('.js-issue-assignees .k2-element').length) {
refreshAssignees();
}
});
}, 1000);
};

return IssuePage;
Expand Down

0 comments on commit 4bf4869

Please sign in to comment.