mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
refactored node comments to component
This commit is contained in:
parent
b44266437d
commit
ab15a10d01
13 changed files with 208 additions and 111 deletions
17
src/utils/hooks/node/useNodeComments.ts
Normal file
17
src/utils/hooks/node/useNodeComments.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { useCallback } from 'react';
|
||||
import { nodeLoadMoreComments, nodeLockComment } from '~/redux/node/actions';
|
||||
import { IComment } from '~/redux/types';
|
||||
import { useDispatch } from 'react-redux';
|
||||
|
||||
export const useNodeComments = (id: string) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const onLoadMoreComments = useCallback(() => dispatch(nodeLoadMoreComments()), [dispatch]);
|
||||
|
||||
const onDelete = useCallback(
|
||||
(id: IComment['id'], locked: boolean) => dispatch(nodeLockComment(id, locked)),
|
||||
[dispatch]
|
||||
);
|
||||
|
||||
return { onLoadMoreComments, onDelete };
|
||||
};
|
13
src/utils/hooks/useImageModal.ts
Normal file
13
src/utils/hooks/useImageModal.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { useCallback } from 'react';
|
||||
import { IFile } from '~/redux/types';
|
||||
import { modalShowPhotoswipe } from '~/redux/modal/actions';
|
||||
import { useDispatch } from 'react-redux';
|
||||
|
||||
export const useImageModal = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
return useCallback(
|
||||
(images: IFile[], index: number) => dispatch(modalShowPhotoswipe(images, index)),
|
||||
[dispatch]
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue