mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 13:41:10 +10:00
feat: comments
* create comment * reply to comment thread * edit comment * delete comment * resolve comment
This commit is contained in:
17
client/src/features/comment/atoms/comment-atom.ts
Normal file
17
client/src/features/comment/atoms/comment-atom.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { atom } from 'jotai';
|
||||
import { atomFamily } from 'jotai/utils';
|
||||
import { IComment } from '@/features/comment/types/comment.types';
|
||||
|
||||
export const commentsAtom = atomFamily((pageId: string) => atom<IComment[]>([]));
|
||||
export const showCommentPopupAtom = atom(false);
|
||||
export const activeCommentIdAtom = atom<string | null>(null);
|
||||
export const draftCommentIdAtom = atom<string | null>(null);
|
||||
|
||||
export const deleteCommentAtom = atomFamily((pageId: string) => atom(
|
||||
null,
|
||||
(get, set, idToDelete: string) => {
|
||||
const currentPageComments = get(commentsAtom(pageId));
|
||||
const updatedComments = currentPageComments.filter(comment => comment.id !== idToDelete);
|
||||
set(commentsAtom(pageId), updatedComments);
|
||||
}
|
||||
));
|
||||
Reference in New Issue
Block a user