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:
parent
832386d39a
commit
c2d1c2bfc9
35 changed files with 366 additions and 413 deletions
|
@ -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)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue