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

99: made node use SWR

This commit is contained in:
Fedor Katurov 2022-01-02 16:38:10 +07:00
parent 832386d39a
commit a1dfcc6048
27 changed files with 217 additions and 147 deletions

View file

@ -12,6 +12,7 @@ import { CommentContextProvider } from '~/utils/context/CommentContextProvider';
import { TagsContextProvider } from '~/utils/context/TagsContextProvider';
import { useNodePermissions } from '~/utils/hooks/node/useNodePermissions';
import { NodeRelatedProvider } from '~/utils/providers/NodeRelatedProvider';
import { useGetNode } from '~/utils/hooks/data/useGetNode';
type Props = RouteComponentProps<{ id: string }> & {};
@ -20,14 +21,8 @@ const NodePage: FC<Props> = ({
params: { id },
},
}) => {
const {
node,
isLoading,
isLoadingComments,
comments,
commentsCount,
lastSeenCurrent,
} = useFullNode(id);
const { node, isLoading } = useGetNode(parseInt(id, 10));
const { isLoadingComments, comments, commentsCount, lastSeenCurrent } = useFullNode(id);
const onShowImageModal = useImageModal();
const { onLoadMoreComments, onDelete: onDeleteComment } = useNodeComments(parseInt(id, 10));
@ -39,6 +34,11 @@ const NodePage: FC<Props> = ({
useScrollToTop([id, isLoadingComments]);
if (!node) {
// TODO: do something here
return null;
}
return (
<NodeContextProvider node={node} isLoading={isLoading}>
<NodeRelatedProvider id={parseInt(id, 10)} tags={node.tags}>