UNPKG

@replyke/core

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

75 lines (74 loc) 2.95 kB
import { Comment, GifData } from "../../interfaces/models/Comment"; import { EntityCommentsTree } from "../../interfaces/EntityCommentsTree"; import { CommentsSortByOptions } from "../../interfaces/CommentsSortByOptions"; import { User } from "../../interfaces/models/User"; import { Mention } from "../../interfaces/models/Mention"; import { ReactionType } from "../../interfaces/models/Reaction"; import { Entity } from "../../interfaces/models/Entity"; export interface MentionTriggers { user?: string; space?: string; } export interface UseCommentSectionDataProps { entity?: Entity | undefined | null; entityId?: string | undefined | null; foreignId?: string | undefined | null; shortId?: string | undefined | null; createIfNotFound?: boolean; callbacks?: Record<string, (...args: any[]) => void> | undefined; limit?: number; defaultSortBy?: CommentsSortByOptions; highlightedCommentId?: string | null; mentionTriggers?: MentionTriggers; } export interface CommentSectionCreateCommentProps { parentId?: string; content?: string; gif?: GifData; mentions?: Mention[]; autoReaction?: ReactionType; } export interface CommentSectionUpdateCommentProps { commentId: string; content: string; } export interface CommentSectionDeleteCommentProps { commentId: string; } export interface UseCommentSectionDataValues { entity: Entity | null | undefined; callbacks?: Record<string, (...args: any[]) => void> | undefined; entityCommentsTree: EntityCommentsTree; comments: Comment[]; newComments: Comment[]; highlightedComment: { comment: Comment; parentComment: Comment | null; } | null; loading: boolean; hasMore: boolean; submittingComment: boolean; loadMore: () => void; sortBy: CommentsSortByOptions | null; setSortBy: (newSortBy: CommentsSortByOptions) => void; pushMention: User | null; selectedComment: Comment | null; setSelectedComment: (newSelectedComment: Comment | null) => void; repliedToComment: Partial<Comment> | null; setRepliedToComment: (newRepliedToComment: Comment | null) => void; showReplyBanner: boolean; setShowReplyBanner: ({ newState }: { newState: boolean; }) => void; addCommentsToTree: (newComments: Comment[] | undefined, newlyAdded?: boolean) => void; removeCommentFromTree: ({ commentId }: { commentId: string; }) => void; handleDeepReply: (comment: Comment) => void; handleShallowReply: (comment: Comment) => void; createComment: (props: CommentSectionCreateCommentProps) => Promise<Comment | undefined>; updateComment: (props: CommentSectionUpdateCommentProps) => Promise<void>; deleteComment: (props: CommentSectionDeleteCommentProps) => Promise<void>; } declare function useCommentSectionData(props: UseCommentSectionDataProps): UseCommentSectionDataValues; export default useCommentSectionData;