1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

moved comments load to hook

This commit is contained in:
Fedor Katurov 2021-09-20 11:56:20 +07:00
parent 5e1e575ee3
commit 639c952c2c
11 changed files with 184 additions and 59 deletions

View file

@ -8,16 +8,27 @@ import { Footer } from '~/components/main/Footer';
import { Card } from '~/components/containers/Card';
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
import { selectAuthUser } from '~/redux/auth/selectors';
import { IComment, INode } from '~/redux/types';
import { IComment, IFile, INode } from '~/redux/types';
interface IProps {
isLoadingComments: boolean;
commentCount: number;
node: INode;
comments: IComment[];
onDelete: (id: IComment['id'], locked: boolean) => void;
onLoadMoreComments: () => void;
onShowPhotoswipe: (images: IFile[], index: number) => void;
}
const BorisComments: FC<IProps> = ({ isLoadingComments, node, commentCount, comments }) => {
const BorisComments: FC<IProps> = ({
node,
commentCount,
comments,
isLoadingComments,
onLoadMoreComments,
onDelete,
onShowPhotoswipe,
}) => {
const user = useShallowSelect(selectAuthUser);
return (
@ -28,7 +39,15 @@ const BorisComments: FC<IProps> = ({ isLoadingComments, node, commentCount, comm
{isLoadingComments ? (
<NodeNoComments is_loading count={7} />
) : (
<NodeComments comments={comments} count={commentCount} user={user} order="ASC" />
<NodeComments
comments={comments}
count={commentCount}
user={user}
order="ASC"
onLoadMoreComments={onLoadMoreComments}
onDelete={onDelete}
onShowPhotoswipe={onShowPhotoswipe}
/>
)}
</Group>