mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
let users like comments
This commit is contained in:
parent
822f51f5de
commit
bd802ede10
22 changed files with 332 additions and 154 deletions
|
@ -12,6 +12,7 @@ export interface CommentProviderProps {
|
|||
onLoadMoreComments: () => void;
|
||||
onSaveComment: (comment: IComment) => Promise<IComment | undefined>;
|
||||
onDeleteComment: (id: IComment['id'], isLocked: boolean) => void;
|
||||
onLike: (id: number, liked: boolean) => void;
|
||||
}
|
||||
|
||||
const CommentContext = createContext<CommentProviderProps>({
|
||||
|
@ -20,6 +21,7 @@ const CommentContext = createContext<CommentProviderProps>({
|
|||
lastSeenCurrent: null,
|
||||
isLoading: false,
|
||||
isLoadingMore: false,
|
||||
onLike: () => {},
|
||||
onSaveComment: async () => undefined,
|
||||
onShowImageModal: () => {},
|
||||
onLoadMoreComments: () => {},
|
||||
|
|
|
@ -18,6 +18,17 @@ export const canEditComment = (
|
|||
path(['role'], user) === Role.Admin ||
|
||||
path(['user', 'id'], comment) === path(['id'], user);
|
||||
|
||||
export const canLikeComment = (
|
||||
comment?: Partial<ICommentGroup>,
|
||||
user?: Partial<IUser>,
|
||||
): boolean =>
|
||||
Boolean(
|
||||
user?.role &&
|
||||
user?.id &&
|
||||
user?.role !== Role.Guest &&
|
||||
user.id !== comment?.user?.id,
|
||||
);
|
||||
|
||||
export const canLikeNode = (
|
||||
node?: Partial<INode>,
|
||||
user?: Partial<IUser>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue