Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

refactor: remove unused callbacks

Elijah Potter48bdc7f2f610
diff --git a/src/harper/Highlighter.tsx b/src/harper/Highlighter.tsx
index ee03f7d63..6a5c7f656 100644
--- a/src/harper/Highlighter.tsx
+++ b/src/harper/Highlighter.tsx
@@ -91,13 +91,9 @@ function setBlockContent( clientId: string, text: string ) {
export default function Highlighter( {
container,
target,
- requestClosePopups,
- registerCloseHandler,
}: {
container: Element;
target: HTMLElement;
- requestClosePopups: () => void;
- registerCloseHandler: ( handler: () => void ) => void;
} ) {
const [ targetBoxes, setTargetBoxes ] = useState< LintBox[] >( [] );
const [ lints, setLints ] = useState< Lint[] >( [] );
@@ -142,11 +138,7 @@ export default function Highlighter( {
return (
<>
{ targetBoxes.map( ( b ) => (
- <SuggestionControl
- lintBox={ b }
- requestClosePopups={ requestClosePopups }
- registerCloseHandler={ registerCloseHandler }
- />
+ <SuggestionControl lintBox={ b } />
) ) }
</>
);
diff --git a/src/harper/SidebarControl.tsx b/src/harper/SidebarControl.tsx
index f8e464f3c..e25d378f4 100644
--- a/src/harper/SidebarControl.tsx
+++ b/src/harper/SidebarControl.tsx
@@ -37,24 +37,11 @@ export default function SidebarControl() {
[ documentContainer, frameCount ]
);
- const closeHandlers = useRef( new Set< () => void >() );
-
- let requestClosePopups = useCallback( () => {
- closeHandlers.current.forEach( ( h ) => h() );
- }, [] );
-
let highlights =
documentContainer &&
targetNodes.map( ( n ) => {
return createPortal(
- <Highlighter
- container={ documentContainer }
- target={ n }
- requestClosePopups={ requestClosePopups }
- registerCloseHandler={ ( handler ) =>
- closeHandlers.current.add( handler )
- }
- />,
+ <Highlighter container={ documentContainer } target={ n } />,
documentContainer
);
} );
diff --git a/src/harper/SuggestionControl.tsx b/src/harper/SuggestionControl.tsx
index a13cc2d31..58895b449 100644
--- a/src/harper/SuggestionControl.tsx
+++ b/src/harper/SuggestionControl.tsx
@@ -25,15 +25,7 @@ function suggestionText(
/** A control for an individual suggestion shown on the screen.
* This includes both the underline to be shown, and the control that appears when you hover over it.
* */
-export default function SuggestionControl( {
- lintBox,
- requestClosePopups,
- registerCloseHandler,
-}: {
- lintBox: LintBox;
- requestClosePopups: () => void;
- registerCloseHandler: ( handler: () => void ) => void;
-} ) {
+export default function SuggestionControl( { lintBox }: { lintBox: LintBox } ) {
let { x, y, width, height, lint, applySuggestion } = lintBox;
let underlineRef = useRef< HTMLElement | null >( null );
@@ -42,10 +34,6 @@ export default function SuggestionControl( {
let suggestions = useMemo( () => lint.suggestions(), [ lint ] );
const [ showPopover, setShowPopover ] = useState( false );
- useEffect( () => {
- registerCloseHandler( () => setShowPopover( () => false ) );
- }, [] );
-
useEffect( () => {
function mouseUp( e: MouseEvent ) {
if ( underlineRef.current == null ) {
@@ -77,7 +65,7 @@ export default function SuggestionControl( {
mouseUp
);
};
- }, [ requestClosePopups, underlineRef.current ] );
+ }, [ underlineRef.current ] );
return (
<>