mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
R: Remove redundant useCallback
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
This commit is contained in:
parent
0ad1e4f872
commit
507faf4689
|
@ -1,7 +1,5 @@
|
|||
'use client';
|
||||
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { PolicyIcon } from '@/components/DomainIcons';
|
||||
import { CProps } from '@/components/props';
|
||||
import Dropdown from '@/components/ui/Dropdown';
|
||||
|
@ -23,15 +21,12 @@ interface SelectAccessPolicyProps extends CProps.Styling {
|
|||
function SelectAccessPolicy({ value, disabled, stretchLeft, onChange, ...restProps }: SelectAccessPolicyProps) {
|
||||
const menu = useDropdown();
|
||||
|
||||
const handleChange = useCallback(
|
||||
(newValue: AccessPolicy) => {
|
||||
menu.hide();
|
||||
if (newValue !== value) {
|
||||
onChange(newValue);
|
||||
}
|
||||
},
|
||||
[menu, value, onChange]
|
||||
);
|
||||
function handleChange(newValue: AccessPolicy) {
|
||||
menu.hide();
|
||||
if (newValue !== value) {
|
||||
onChange(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={menu.ref} {...restProps}>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
'use client';
|
||||
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { DependencyIcon } from '@/components/DomainIcons';
|
||||
import { CProps } from '@/components/props';
|
||||
import Dropdown from '@/components/ui/Dropdown';
|
||||
|
@ -23,13 +21,10 @@ function SelectGraphFilter({ value, dense, onChange, ...restProps }: SelectGraph
|
|||
const menu = useDropdown();
|
||||
const size = useWindowSize();
|
||||
|
||||
const handleChange = useCallback(
|
||||
(newValue: DependencyMode) => {
|
||||
menu.hide();
|
||||
onChange(newValue);
|
||||
},
|
||||
[menu, onChange]
|
||||
);
|
||||
function handleChange(newValue: DependencyMode) {
|
||||
menu.hide();
|
||||
onChange(newValue);
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={menu.ref} {...restProps}>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import clsx from 'clsx';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { IconFolderTree } from '@/components/Icons';
|
||||
import { CProps } from '@/components/props';
|
||||
|
@ -28,15 +27,12 @@ function SelectLocationContext({
|
|||
}: SelectLocationContextProps) {
|
||||
const menu = useDropdown();
|
||||
|
||||
const handleClick = useCallback(
|
||||
(event: CProps.EventMouse, newValue: string) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
menu.hide();
|
||||
onChange(newValue);
|
||||
},
|
||||
[menu, onChange]
|
||||
);
|
||||
function handleClick(event: CProps.EventMouse, newValue: string) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
menu.hide();
|
||||
onChange(newValue);
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={menu.ref} className='h-full text-right self-start mt-[-0.25rem] ml-[-1.5rem]'>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import clsx from 'clsx';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { LocationIcon } from '@/components/DomainIcons';
|
||||
import { CProps } from '@/components/props';
|
||||
|
@ -22,13 +21,10 @@ interface SelectLocationHeadProps extends CProps.Styling {
|
|||
function SelectLocationHead({ value, excluded = [], onChange, className, ...restProps }: SelectLocationHeadProps) {
|
||||
const menu = useDropdown();
|
||||
|
||||
const handleChange = useCallback(
|
||||
(newValue: LocationHead) => {
|
||||
menu.hide();
|
||||
onChange(newValue);
|
||||
},
|
||||
[menu, onChange]
|
||||
);
|
||||
function handleChange(newValue: LocationHead) {
|
||||
menu.hide();
|
||||
onChange(newValue);
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={menu.ref} className={clsx('h-full text-right', className)} {...restProps}>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
'use client';
|
||||
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { MatchModeIcon } from '@/components/DomainIcons';
|
||||
import { CProps } from '@/components/props';
|
||||
import Dropdown from '@/components/ui/Dropdown';
|
||||
|
@ -23,13 +21,10 @@ function SelectMatchMode({ value, dense, onChange, ...restProps }: SelectMatchMo
|
|||
const menu = useDropdown();
|
||||
const size = useWindowSize();
|
||||
|
||||
const handleChange = useCallback(
|
||||
(newValue: CstMatchMode) => {
|
||||
menu.hide();
|
||||
onChange(newValue);
|
||||
},
|
||||
[menu, onChange]
|
||||
);
|
||||
function handleChange(newValue: CstMatchMode) {
|
||||
menu.hide();
|
||||
onChange(newValue);
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={menu.ref} {...restProps}>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import clsx from 'clsx';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { CProps } from '@/components/props';
|
||||
import WordformButton from '@/dialogs/DlgEditReference/WordformButton';
|
||||
|
@ -15,12 +14,9 @@ interface SelectWordFormProps extends CProps.Styling {
|
|||
}
|
||||
|
||||
function SelectWordForm({ value, onChange, className, ...restProps }: SelectWordFormProps) {
|
||||
const handleSelect = useCallback(
|
||||
(grams: Grammeme[]) => {
|
||||
onChange(SelectorGrammemes.filter(({ value }) => grams.includes(value as Grammeme)));
|
||||
},
|
||||
[onChange]
|
||||
);
|
||||
function handleSelect(grams: Grammeme[]) {
|
||||
onChange(SelectorGrammemes.filter(({ value }) => grams.includes(value as Grammeme)));
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={clsx('text-xs sm:text-sm', className)} {...restProps}>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import clsx from 'clsx';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import {
|
||||
IconGraphCollapse,
|
||||
|
@ -35,20 +34,14 @@ function ToolbarGraphSelection({
|
|||
emptySelection,
|
||||
...restProps
|
||||
}: ToolbarGraphSelectionProps) {
|
||||
const handleSelectCore = useCallback(() => {
|
||||
function handleSelectCore() {
|
||||
const core = [...graph.nodes.keys()].filter(isCore);
|
||||
onChange([...core, ...graph.expandInputs(core)]);
|
||||
}, [onChange, graph, isCore]);
|
||||
}
|
||||
|
||||
const handleSelectOwned = useCallback(
|
||||
() => (isOwned ? onChange([...graph.nodes.keys()].filter(isOwned)) : undefined),
|
||||
[onChange, graph, isOwned]
|
||||
);
|
||||
|
||||
const handleInvertSelection = useCallback(
|
||||
() => onChange([...graph.nodes.keys()].filter(item => !selected.includes(item))),
|
||||
[onChange, selected, graph]
|
||||
);
|
||||
function handleSelectOwned() {
|
||||
if (isOwned) onChange([...graph.nodes.keys()].filter(isOwned));
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={clsx('cc-icons', className)} {...restProps}>
|
||||
|
@ -91,7 +84,7 @@ function ToolbarGraphSelection({
|
|||
<MiniButton
|
||||
titleHtml='Инвертировать'
|
||||
icon={<IconGraphInverse size='1.25rem' className='icon-primary' />}
|
||||
onClick={handleInvertSelection}
|
||||
onClick={() => onChange([...graph.nodes.keys()].filter(item => !selected.includes(item)))}
|
||||
/>
|
||||
<MiniButton
|
||||
titleHtml='Выделить ядро'
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import clsx from 'clsx';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { IconMenuFold, IconMenuUnfold } from '@/components/Icons';
|
||||
import Button from '@/components/ui/Button';
|
||||
|
@ -22,13 +21,10 @@ function TopicsDropdown({ activeTopic, onChangeTopic }: TopicsDropdownProps) {
|
|||
const noNavigation = useAppLayoutStore(state => state.noNavigation);
|
||||
const treeHeight = useFitHeight('4rem + 2px');
|
||||
|
||||
const handleSelectTopic = useCallback(
|
||||
(topic: HelpTopic) => {
|
||||
menu.hide();
|
||||
onChangeTopic(topic);
|
||||
},
|
||||
[onChangeTopic, menu]
|
||||
);
|
||||
function handleSelectTopic(topic: HelpTopic) {
|
||||
menu.hide();
|
||||
onChangeTopic(topic);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { useMutatingOss } from '@/backend/oss/useMutatingOss';
|
||||
import {
|
||||
|
@ -75,48 +75,48 @@ function NodeContextMenu({
|
|||
return true;
|
||||
})();
|
||||
|
||||
const handleHide = useCallback(() => {
|
||||
function handleHide() {
|
||||
setIsOpen(false);
|
||||
onHide();
|
||||
}, [onHide]);
|
||||
}
|
||||
|
||||
useClickedOutside(isOpen, ref, handleHide);
|
||||
|
||||
useEffect(() => setIsOpen(true), []);
|
||||
|
||||
const handleOpenSchema = () => {
|
||||
function handleOpenSchema() {
|
||||
controller.navigateOperationSchema(operation.id);
|
||||
};
|
||||
}
|
||||
|
||||
const handleEditSchema = () => {
|
||||
function handleEditSchema() {
|
||||
handleHide();
|
||||
onEditSchema(operation.id);
|
||||
};
|
||||
}
|
||||
|
||||
const handleEditOperation = () => {
|
||||
function handleEditOperation() {
|
||||
handleHide();
|
||||
onEditOperation(operation.id);
|
||||
};
|
||||
}
|
||||
|
||||
const handleDeleteOperation = () => {
|
||||
function handleDeleteOperation() {
|
||||
handleHide();
|
||||
onDelete(operation.id);
|
||||
};
|
||||
}
|
||||
|
||||
const handleCreateSchema = () => {
|
||||
function handleCreateSchema() {
|
||||
handleHide();
|
||||
onCreateInput(operation.id);
|
||||
};
|
||||
}
|
||||
|
||||
const handleRunSynthesis = () => {
|
||||
function handleRunSynthesis() {
|
||||
handleHide();
|
||||
onExecuteOperation(operation.id);
|
||||
};
|
||||
}
|
||||
|
||||
const handleRelocateConstituents = () => {
|
||||
function handleRelocateConstituents() {
|
||||
handleHide();
|
||||
onRelocateConstituents(operation.id);
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={ref} className='absolute select-none' style={{ top: cursorY, left: cursorX }}>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use client';
|
||||
|
||||
import { toPng } from 'html-to-image';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { toast } from 'react-toastify';
|
||||
import {
|
||||
Background,
|
||||
|
@ -65,16 +65,13 @@ function OssFlow() {
|
|||
const [toggleReset, setToggleReset] = useState(false);
|
||||
const [menuProps, setMenuProps] = useState<ContextMenuData | undefined>(undefined);
|
||||
|
||||
const onSelectionChange = useCallback(
|
||||
({ nodes }: { nodes: Node[] }) => {
|
||||
const ids = nodes.map(node => Number(node.id));
|
||||
controller.setSelected(prev => [
|
||||
...prev.filter(nodeID => ids.includes(nodeID)),
|
||||
...ids.filter(nodeID => !prev.includes(Number(nodeID)))
|
||||
]);
|
||||
},
|
||||
[controller]
|
||||
);
|
||||
function onSelectionChange({ nodes }: { nodes: Node[] }) {
|
||||
const ids = nodes.map(node => Number(node.id));
|
||||
controller.setSelected(prev => [
|
||||
...prev.filter(nodeID => ids.includes(nodeID)),
|
||||
...ids.filter(nodeID => !prev.includes(Number(nodeID)))
|
||||
]);
|
||||
}
|
||||
|
||||
useOnSelectionChange({
|
||||
onChange: onSelectionChange
|
||||
|
|
|
@ -79,17 +79,14 @@ function TGFlow() {
|
|||
const [needReset, setNeedReset] = useState(true);
|
||||
const [toggleResetView, setToggleResetView] = useState(false);
|
||||
|
||||
const onSelectionChange = useCallback(
|
||||
({ nodes }: { nodes: Node[] }) => {
|
||||
const ids = nodes.map(node => Number(node.id));
|
||||
if (ids.length === 0) {
|
||||
controller.setSelected([]);
|
||||
} else {
|
||||
controller.setSelected(prev => [...prev.filter(nodeID => !filteredGraph.hasNode(nodeID)), ...ids]);
|
||||
}
|
||||
},
|
||||
[controller, filteredGraph]
|
||||
);
|
||||
function onSelectionChange({ nodes }: { nodes: Node[] }) {
|
||||
const ids = nodes.map(node => Number(node.id));
|
||||
if (ids.length === 0) {
|
||||
controller.setSelected([]);
|
||||
} else {
|
||||
controller.setSelected(prev => [...prev.filter(nodeID => !filteredGraph.hasNode(nodeID)), ...ids]);
|
||||
}
|
||||
}
|
||||
|
||||
useOnSelectionChange({
|
||||
onChange: onSelectionChange
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
'use client';
|
||||
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { IconGraphInputs, IconGraphOutputs, IconReset } from '@/components/Icons';
|
||||
import MiniButton from '@/components/ui/MiniButton';
|
||||
import { IConstituenta } from '@/models/rsform';
|
||||
|
@ -29,10 +27,10 @@ function ToolbarFocusedCst({
|
|||
}: ToolbarFocusedCstProps) {
|
||||
const controller = useRSEdit();
|
||||
|
||||
const resetSelection = useCallback(() => {
|
||||
function resetSelection() {
|
||||
reset();
|
||||
controller.setSelected([]);
|
||||
}, [reset, controller]);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='items-center cc-icons'>
|
||||
|
|
Loading…
Reference in New Issue
Block a user