import './hidden-review-comments-indicator.css'; import mem from 'mem'; import React from 'dom-chef'; import {$$} from 'select-dom'; import {CommentIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; import features from '../feature-manager.js'; import preserveScroll from '../helpers/preserve-scroll.js'; import onAbort from '../helpers/abort-controller.js'; import observe from '../helpers/selector-observer.js'; // When an indicator is clicked, this will show comments on the current file function handleIndicatorClick({delegateTarget}: DelegateEvent): void { const commentedLine = delegateTarget.closest('tr')!.previousElementSibling!; const resetScroll = preserveScroll(commentedLine); delegateTarget .closest('.file.js-file')! .querySelector('input.js-toggle-file-notes')! .click(); resetScroll(); } // `mem` avoids adding the indicator twice to the same thread const addIndicator = mem((commentThread: HTMLElement): void => { const commentCount = commentThread.querySelectorAll('.review-comment.js-comment').length; commentThread.before(