1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +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:
muerwre 2022-01-02 17:10:21 +07:00 committed by GitHub
parent 832386d39a
commit c2d1c2bfc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 366 additions and 413 deletions

View file

@ -9,6 +9,7 @@ import { useGrouppedComments } from '~/utils/hooks/node/useGrouppedComments';
import { useCommentContext } from '~/utils/context/CommentContextProvider';
import { Comment } from '~/components/comment/Comment';
import { useUserContext } from '~/utils/context/UserContextProvider';
import { useNodeContext } from '~/utils/context/NodeContextProvider';
interface IProps {
order: 'ASC' | 'DESC';
@ -16,6 +17,8 @@ interface IProps {
const NodeComments: FC<IProps> = memo(({ order }) => {
const user = useUserContext();
const { node } = useNodeContext();
const {
comments,
count,
@ -41,12 +44,17 @@ const NodeComments: FC<IProps> = memo(({ order }) => {
[left, onLoadMoreComments]
);
if (!node?.id) {
return null;
}
return (
<div className={styles.wrap}>
{order === 'DESC' && more}
{groupped.map(group => (
<Comment
nodeId={node.id!}
key={group.ids.join()}
group={group}
canEdit={canEditComment(group, user)}