mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
99 use swr (#100)
* 99: made node use SWR * 99: fixed comments for SWR node * 99: added error toast to useNodeFormFormik.ts
This commit is contained in:
parent
832386d39a
commit
c2d1c2bfc9
35 changed files with 366 additions and 413 deletions
|
@ -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}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue