mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
refactored hooks directory
This commit is contained in:
parent
efa3ba902d
commit
f76a5a4798
106 changed files with 122 additions and 144 deletions
|
@ -1,27 +0,0 @@
|
|||
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
||||
import { selectFlow } from '~/redux/flow/selectors';
|
||||
import { useFlowLayout } from '~/utils/hooks/flow/useFlowLayout';
|
||||
import { selectLabUpdatesNodes } from '~/redux/lab/selectors';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useFlowPagination } from '~/utils/hooks/flow/useFlowPagination';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { FlowDisplay, INode } from '~/redux/types';
|
||||
import { flowSetCellView } from '~/redux/flow/actions';
|
||||
|
||||
export const useFlow = () => {
|
||||
const { nodes, heroes, recent, updated, isLoading } = useShallowSelect(selectFlow);
|
||||
const { isFluid, toggleLayout } = useFlowLayout();
|
||||
const labUpdates = useShallowSelect(selectLabUpdatesNodes);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useFlowPagination({ isLoading });
|
||||
|
||||
const updates = useMemo(() => [...updated, ...labUpdates].slice(0, 10), [updated, labUpdates]);
|
||||
|
||||
const onChangeCellView = useCallback(
|
||||
(id: INode['id'], val: FlowDisplay) => dispatch(flowSetCellView(id, val)),
|
||||
[dispatch]
|
||||
);
|
||||
|
||||
return { nodes, heroes, recent, updates, isFluid, toggleLayout, onChangeCellView };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue