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

removed almost all node sagas

This commit is contained in:
Fedor Katurov 2022-01-02 20:44:41 +07:00
parent f76a5a4798
commit 168ba8cc04
30 changed files with 268 additions and 448 deletions

View file

@ -1,37 +1,32 @@
import React, { useEffect, VFC } from 'react';
import { useDispatch } from 'react-redux';
import { useShallowSelect } from '~/hooks/data/useShallowSelect';
import { selectNode } from '~/redux/node/selectors';
import React, { VFC } from 'react';
import { BorisLayout } from '~/layouts/BorisLayout';
import { nodeLoadNode } from '~/redux/node/actions';
import { CommentContextProvider } from '~/utils/context/CommentContextProvider';
import { useImageModal } from '~/hooks/navigation/useImageModal';
import { useNodeComments } from '~/hooks/node/useNodeComments';
import { useNodeComments } from '~/hooks/comments/useNodeComments';
import { useBoris } from '~/hooks/boris/useBoris';
import { NodeContextProvider } from '~/utils/context/NodeContextProvider';
import { useGetNode } from '~/hooks/node/useGetNode';
import { useLoadNode } from '~/hooks/node/useLoadNode';
const BorisPage: VFC = () => {
const dispatch = useDispatch();
const { node, isLoading, update } = useGetNode(696);
const {
comments,
comment_count: count,
is_loading_comments: isLoadingComments,
} = useShallowSelect(selectNode);
const { node, isLoading, update } = useLoadNode(696);
const onShowImageModal = useImageModal();
const { onLoadMoreComments, onDelete: onDeleteComment } = useNodeComments(696);
const {
onLoadMoreComments,
onDelete: onDeleteComment,
onEdit: onSaveComment,
comments,
hasMore,
isLoading: isLoadingComments,
} = useNodeComments(696);
const { title, setIsBetaTester, isTester, stats } = useBoris(comments);
useEffect(() => {
dispatch(nodeLoadNode(696, 'DESC'));
}, [dispatch]);
return (
<NodeContextProvider node={node} isLoading={isLoading} update={update}>
<CommentContextProvider
onSaveComment={onSaveComment}
comments={comments}
count={count}
hasMore={hasMore}
isLoading={isLoadingComments}
onShowImageModal={onShowImageModal}
onLoadMoreComments={onLoadMoreComments}

View file

@ -2,9 +2,8 @@ import React, { FC } from 'react';
import { NodeLayout } from '~/layouts/NodeLayout';
import { RouteComponentProps } from 'react-router';
import { useScrollToTop } from '~/hooks/dom/useScrollToTop';
import { useFullNode } from '~/hooks/node/useFullNode';
import { useImageModal } from '~/hooks/navigation/useImageModal';
import { useNodeComments } from '~/hooks/node/useNodeComments';
import { useNodeComments } from '~/hooks/comments/useNodeComments';
import { useUser } from '~/hooks/user/userUser';
import { useNodeTags } from '~/hooks/node/useNodeTags';
import { NodeContextProvider } from '~/utils/context/NodeContextProvider';
@ -12,7 +11,7 @@ import { CommentContextProvider } from '~/utils/context/CommentContextProvider';
import { TagsContextProvider } from '~/utils/context/TagsContextProvider';
import { useNodePermissions } from '~/hooks/node/useNodePermissions';
import { NodeRelatedProvider } from '~/utils/providers/NodeRelatedProvider';
import { useGetNode } from '~/hooks/node/useGetNode';
import { useLoadNode } from '~/hooks/node/useLoadNode';
type Props = RouteComponentProps<{ id: string }> & {};
@ -21,11 +20,17 @@ const NodePage: FC<Props> = ({
params: { id },
},
}) => {
const { node, isLoading, update } = useGetNode(parseInt(id, 10));
const { isLoadingComments, comments, commentsCount, lastSeenCurrent } = useFullNode(id);
const { node, isLoading, update, lastSeen } = useLoadNode(parseInt(id, 10));
const onShowImageModal = useImageModal();
const { onLoadMoreComments, onDelete: onDeleteComment } = useNodeComments(parseInt(id, 10));
const {
onLoadMoreComments,
onDelete: onDeleteComment,
onEdit: onSaveComment,
comments,
hasMore,
isLoading: isLoadingComments,
} = useNodeComments(parseInt(id, 10));
const { onDelete: onTagDelete, onChange: onTagsChange, onClick: onTagClick } = useNodeTags(
parseInt(id, 10)
);
@ -43,9 +48,10 @@ const NodePage: FC<Props> = ({
<NodeContextProvider node={node} isLoading={isLoading} update={update}>
<NodeRelatedProvider id={parseInt(id, 10)} tags={node.tags}>
<CommentContextProvider
onSaveComment={onSaveComment}
comments={comments}
count={commentsCount}
lastSeenCurrent={lastSeenCurrent}
hasMore={hasMore}
lastSeenCurrent={lastSeen}
isLoading={isLoadingComments}
onShowImageModal={onShowImageModal}
onLoadMoreComments={onLoadMoreComments}