@bitsocial/bitsocial-react-hooks 0.1.41 → 0.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/hooks/comments.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAC3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAY5B,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EACL,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,wBAAwB,MAAM,6BAA6B,CAAC;AACnE,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,uBAAuB,EACvB,iCAAiC,GAClC,MAAM,qCAAqC,CAAC;AAE7C,MAAM,UAAU,mBAAmB,CAAC,OAA4B;;IAC9D,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,CAAC;IACvB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAA,OAAO,CAAC,SAAS,mCAAI,CAAC,EAAE,MAAA,OAAO,CAAC,SAAS,mCAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACrE,CAAC;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,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM;KACP,CAAC,EACF,CAAC,KAAK,EAAE,KAAK,CAAC,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAccount } from \"./accounts\";\nimport validator from \"../lib/validator\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:comments:hooks\");\nimport assert from \"assert\";\nimport {\n Comment,\n UseCommentsOptions,\n UseCommentsResult,\n UseCommentOptions,\n UseCommentResult,\n UseCrosspostOptions,\n UseCrosspostResult,\n UseValidateCommentOptions,\n UseValidateCommentResult,\n} from \"../types\";\nimport useCommentsStore from \"../stores/comments\";\nimport useAccountsStore from \"../stores/accounts\";\nimport utils, { commentIsValid } from \"../lib/utils\";\nimport {\n addCommentModeration,\n addCommentModerationToComments,\n} from \"../lib/utils/comment-moderation\";\nimport useCommunitiesPagesStore from \"../stores/communities-pages\";\nimport useRepliesPagesStore from \"../stores/replies-pages\";\nimport shallow from \"zustand/shallow\";\nimport { assertCommunityRef } from \"../lib/community-ref\";\nimport {\n addOptimisticVoteCounts,\n addOptimisticVoteCountsToComments,\n} from \"../lib/utils/optimistic-vote-counts\";\n\nexport function getCommentFreshness(comment: Comment | undefined): number {\n if (!comment) return 0;\n return Math.max(comment.updatedAt ?? 0, comment.timestamp ?? 0, 0);\n}\n\nexport function preferFresher(\n current: Comment | undefined,\n candidate: Comment | undefined,\n): Comment | undefined {\n if (!candidate) return current;\n if (!current) return candidate;\n return getCommentFreshness(candidate) > getCommentFreshness(current) ? candidate : current;\n}\n\nconst getCommentStateAndReplyCount = (comment: Comment | undefined) => {\n let state = comment?.updatingState || \"initializing\";\n // force 'fetching-ipns' even if could be something else, so the frontend can use\n // the correct loading skeleton\n if (comment?.timestamp) {\n state = \"fetching-update-ipns\";\n }\n // force succeeded even if the comment is fecthing a new update\n if (comment?.updatedAt) {\n state = \"succeeded\";\n }\n\n // force succeeded if the comment is newer than 5 minutes, no need to display loading skeleton if comment was just created\n let replyCount = comment?.replyCount;\n if (\n comment?.replyCount === undefined &&\n comment?.timestamp &&\n comment?.timestamp > Date.now() / 1000 - 5 * 60\n ) {\n state = \"succeeded\";\n // set replyCount because some frontend are likely to check if replyCount === undefined to show a loading skeleton\n replyCount = 0;\n }\n\n return { state, replyCount };\n};\n\nconst getCommentsState = (comments: (Comment | undefined)[]) =>\n comments.every((comment) => getCommentStateAndReplyCount(comment).state === \"succeeded\")\n ? \"succeeded\"\n : \"fetching-ipfs\";\n\nlet commentAutoUpdateSubscriptionCount = 0;\nlet commentsAutoUpdateSubscriptionCount = 0;\n\nconst getCommentCreateCommentData = (\n commentCid: string | undefined,\n community: UseCommentOptions[\"community\"] | undefined,\n initialComment: Comment | undefined,\n ...comments: (Comment | undefined)[]\n) => {\n if (!commentCid) {\n return undefined;\n }\n\n const createCommentData: Comment = initialComment\n ? { ...utils.clone(initialComment), cid: commentCid }\n : { cid: commentCid };\n let hasCreateCommentData = Boolean(initialComment);\n for (const comment of comments) {\n if (!comment) {\n continue;\n }\n if (!createCommentData.communityPublicKey && comment.communityPublicKey) {\n createCommentData.communityPublicKey = comment.communityPublicKey;\n hasCreateCommentData = true;\n }\n if (!createCommentData.communityName && comment.communityName) {\n createCommentData.communityName = comment.communityName;\n hasCreateCommentData = true;\n }\n }\n\n if (community?.publicKey) {\n createCommentData.communityPublicKey = community.publicKey;\n hasCreateCommentData = true;\n }\n if (community?.name) {\n createCommentData.communityName = community.name;\n hasCreateCommentData = true;\n }\n\n return hasCreateCommentData ? createCommentData : undefined;\n};\n\n/**\n * @param commentCid - The IPFS CID of the comment to get\n * @param community - The community identifier, e.g. {name: 'memes.eth', publicKey: '12D3KooW...'}.\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\nexport function useComment(options?: UseCommentOptions): UseCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useComment options argument '${options}' not an object`,\n );\n const {\n commentCid,\n community,\n initialComment,\n accountName,\n onlyIfCached,\n autoUpdate = true,\n } = options ?? {};\n if (community !== undefined) {\n assertCommunityRef(community, \"useComment community\");\n }\n const account = useAccount({ accountName });\n const commentFromStore = useCommentsStore((state: any) => state.comments[commentCid || \"\"]);\n const addCommentToStore = useCommentsStore((state: any) => state.addCommentToStore);\n const startCommentAutoUpdate = useCommentsStore((state: any) => state.startCommentAutoUpdate);\n const stopCommentAutoUpdate = useCommentsStore((state: any) => state.stopCommentAutoUpdate);\n const refreshCommentInStore = useCommentsStore((state: any) => state.refreshComment);\n const communitiesPagesComment = useCommunitiesPagesStore(\n (state: any) => state.comments[commentCid || \"\"],\n );\n const repliesPagesComment = useRepliesPagesStore(\n (state: any) => state.comments[commentCid || \"\"],\n );\n const errors = useCommentsStore((state: any) => state.errors[commentCid || \"\"]);\n\n // get account comment of the cid if any\n const accountCommentInfo = useAccountsStore(\n (state: any) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const accountComment = useAccountsStore(\n (state: any) =>\n state.accountsComments[accountCommentInfo?.accountId || \"\"]?.[\n Number(accountCommentInfo?.accountCommentIndex)\n ],\n );\n const accountVote = useAccountsStore((state: any) =>\n account?.id && commentCid ? state.accountsVotes[account.id]?.[commentCid] : undefined,\n );\n const createCommentData = useMemo(\n () =>\n getCommentCreateCommentData(\n commentCid,\n community,\n initialComment,\n communitiesPagesComment,\n repliesPagesComment,\n ),\n [\n commentCid,\n community?.name,\n community?.publicKey,\n initialComment,\n communitiesPagesComment?.communityName,\n communitiesPagesComment?.communityPublicKey,\n repliesPagesComment?.communityName,\n repliesPagesComment?.communityPublicKey,\n ],\n );\n const autoUpdateSubscriptionId = useRef(`useComment-${++commentAutoUpdateSubscriptionCount}`);\n const currentCommentCidRef = useRef<string | undefined>(commentCid);\n currentCommentCidRef.current = commentCid;\n const [frozenComment, setFrozenComment] = useState<Comment | undefined>();\n const [freezeSettledCid, setFreezeSettledCid] = useState<string>();\n\n useEffect(() => {\n if (!commentCid || !account) {\n return;\n }\n validator.validateUseCommentArguments(commentCid, account);\n if (!commentFromStore && !onlyIfCached) {\n // if comment isn't already in store, add it\n const addCommentPromise = createCommentData\n ? addCommentToStore(commentCid, account, createCommentData)\n : addCommentToStore(commentCid, account);\n addCommentPromise.catch((error: unknown) =>\n log.error(\"useComment addCommentToStore error\", { commentCid, error }),\n );\n }\n }, [commentCid, account?.id, onlyIfCached, createCommentData]);\n\n useEffect(() => {\n if (!commentCid || !account || onlyIfCached || !autoUpdate) {\n return;\n }\n\n const startAutoUpdatePromise = createCommentData\n ? startCommentAutoUpdate(\n commentCid,\n autoUpdateSubscriptionId.current,\n account,\n createCommentData,\n )\n : startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account);\n startAutoUpdatePromise.catch((error: unknown) =>\n log.error(\"useComment startCommentAutoUpdate error\", { commentCid, error }),\n );\n\n return () => {\n stopCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current).catch((error: unknown) =>\n log.error(\"useComment stopCommentAutoUpdate error\", { commentCid, error }),\n );\n };\n }, [commentCid, account?.id, onlyIfCached, autoUpdate, createCommentData]);\n\n let selectedComment = commentFromStore;\n\n if (commentCid && communitiesPagesComment) {\n selectedComment = preferFresher(selectedComment, communitiesPagesComment);\n }\n if (commentCid && repliesPagesComment) {\n selectedComment = preferFresher(selectedComment, repliesPagesComment);\n }\n\n // if comment is still not defined, but account comment is, use account comment\n // check `comment.timestamp` instead of `comment` in case comment exists but in a loading state\n const commentFromStoreNotLoaded = !selectedComment?.timestamp;\n if (commentCid && commentFromStoreNotLoaded && accountComment) {\n selectedComment = accountComment;\n }\n const selectedCommentWithFallback = useMemo(() => {\n if (!commentCid || !commentFromStoreNotLoaded || !initialComment) {\n return selectedComment;\n }\n const commentWithFallback = utils.merge(\n initialComment.raw?.comment || {},\n initialComment,\n { cid: commentCid },\n selectedComment || {},\n );\n commentWithFallback.raw = utils.merge(initialComment.raw || {}, selectedComment?.raw || {});\n return commentWithFallback;\n }, [commentCid, commentFromStoreNotLoaded, initialComment, selectedComment]);\n selectedComment = selectedCommentWithFallback;\n\n const selectedCommentState = getCommentStateAndReplyCount(selectedComment).state;\n const initialCommentUpdatePending = Boolean(\n initialComment?.raw?.comment && !selectedComment?.raw?.commentUpdate,\n );\n const freezeSettledForCurrentCid = freezeSettledCid === commentCid;\n\n useEffect(() => {\n if (autoUpdate) {\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n return;\n }\n\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n }, [commentCid, autoUpdate]);\n\n useEffect(() => {\n if (autoUpdate) {\n return;\n }\n if (!commentCid) {\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n return;\n }\n if (freezeSettledForCurrentCid || !selectedComment) {\n return;\n }\n\n setFrozenComment(selectedComment);\n if (selectedCommentState === \"succeeded\" && !initialCommentUpdatePending) {\n setFreezeSettledCid(commentCid);\n }\n }, [\n autoUpdate,\n commentCid,\n selectedComment,\n selectedCommentState,\n initialCommentUpdatePending,\n freezeSettledForCurrentCid,\n ]);\n\n const frozenCommentForCurrentCid = frozenComment?.cid === commentCid ? frozenComment : undefined;\n let comment = autoUpdate\n ? selectedComment\n : freezeSettledForCurrentCid\n ? frozenCommentForCurrentCid\n : frozenCommentForCurrentCid || selectedComment;\n comment = addCommentModeration(comment);\n comment = addOptimisticVoteCounts(comment, accountVote);\n\n const { state, replyCount } = getCommentStateAndReplyCount(comment);\n\n if (account && commentCid) {\n log(\"useComment\", {\n commentCid,\n comment,\n replyCount,\n state,\n commentFromStore,\n communitiesPagesComment,\n repliesPagesComment,\n accountComment,\n commentsStore: useCommentsStore.getState().comments,\n account,\n onlyIfCached,\n autoUpdate,\n });\n }\n\n const refresh = useCallback(async () => {\n if (!commentCid || !account) {\n throw Error(\"useComment cannot refresh comment not initialized yet\");\n }\n\n const refreshCommentCid = commentCid;\n const refreshedComment = createCommentData\n ? await refreshCommentInStore(refreshCommentCid, account, createCommentData)\n : await refreshCommentInStore(refreshCommentCid, account);\n if (!autoUpdate && refreshedComment && currentCommentCidRef.current === refreshCommentCid) {\n setFrozenComment(refreshedComment);\n setFreezeSettledCid(refreshCommentCid);\n }\n }, [account, autoUpdate, commentCid, createCommentData, refreshCommentInStore]);\n\n return useMemo(\n () => ({\n ...comment,\n replyCount,\n state,\n refresh,\n error: errors?.[errors.length - 1],\n errors: errors || [],\n }),\n [comment, commentCid, errors, refresh, state, replyCount],\n );\n}\n\n/**\n * Read a crosspost from its embedded signed record immediately, then use the normal comment store\n * to load the referenced community's current CommentUpdate when it is available.\n */\nexport function useCrosspost(options?: UseCrosspostOptions): UseCrosspostResult {\n assert(\n !options || typeof options === \"object\",\n `useCrosspost options argument '${options}' not an object`,\n );\n const { crosspost, accountName, autoUpdate = true } = options ?? {};\n const initialComment = useMemo(\n () =>\n crosspost\n ? {\n cid: crosspost.cid,\n raw: { comment: crosspost.comment },\n }\n : undefined,\n [crosspost],\n );\n const comment = useComment({\n accountName,\n autoUpdate,\n commentCid: crosspost?.cid,\n initialComment,\n });\n\n return useMemo(\n () => ({\n ...comment,\n isCommunityVerified: Boolean(comment.raw?.commentUpdate),\n }),\n [comment],\n );\n}\n\n/**\n * @param commentCids - The IPFS CIDs of the comments to get\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\nexport function useComments(options?: UseCommentsOptions): UseCommentsResult {\n assert(\n !options || typeof options === \"object\",\n `useComments options argument '${options}' not an object`,\n );\n const { commentCids = [], accountName, onlyIfCached, autoUpdate = true } = options ?? {};\n const account = useAccount({ accountName });\n const accountVotes = useAccountsStore((state: any) =>\n account?.id ? state.accountsVotes[account.id] : undefined,\n );\n const commentsStoreComments: (Comment | undefined)[] = useCommentsStore(\n (state: any) => commentCids.map((commentCid) => state.comments[commentCid || \"\"]),\n shallow,\n );\n const communitiesPagesComments: (Comment | undefined)[] = useCommunitiesPagesStore(\n (state: any) => commentCids.map((commentCid) => state.comments[commentCid || \"\"]),\n shallow,\n );\n\n const addCommentToStore = useCommentsStore((state: any) => state.addCommentToStore);\n const startCommentAutoUpdate = useCommentsStore((state: any) => state.startCommentAutoUpdate);\n const stopCommentAutoUpdate = useCommentsStore((state: any) => state.stopCommentAutoUpdate);\n const refreshCommentInStore = useCommentsStore((state: any) => state.refreshComment);\n const autoUpdateSubscriptionId = useRef(`useComments-${++commentsAutoUpdateSubscriptionCount}`);\n const commentCidsKey = JSON.stringify(commentCids);\n const commentsKey = `${account?.id || \"\"}:${commentCidsKey}`;\n const currentCommentsKeyRef = useRef(commentsKey);\n currentCommentsKeyRef.current = commentsKey;\n const [frozenComments, setFrozenComments] = useState<(Comment | undefined)[]>([]);\n const [frozenCommentsKey, setFrozenCommentsKey] = useState<string>();\n const [freezeSettledKey, setFreezeSettledKey] = useState<string>();\n\n useEffect(() => {\n if (!commentCids || !account) {\n return;\n }\n validator.validateUseCommentsArguments(commentCids, account);\n if (onlyIfCached) {\n return;\n }\n const uniqueCommentCids = new Set(commentCids);\n for (const commentCid of uniqueCommentCids) {\n addCommentToStore(commentCid, account).catch((error: unknown) =>\n log.error(\"useComments addCommentToStore error\", { commentCid, error }),\n );\n }\n }, [commentCidsKey, account?.id, onlyIfCached]);\n\n useEffect(() => {\n if (!commentCids || !account || onlyIfCached || !autoUpdate) {\n return;\n }\n\n const uniqueCommentCids = [...new Set(commentCids)];\n for (const commentCid of uniqueCommentCids) {\n startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account).catch(\n (error: unknown) =>\n log.error(\"useComments startCommentAutoUpdate error\", { commentCid, error }),\n );\n }\n\n return () => {\n for (const commentCid of uniqueCommentCids) {\n stopCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current).catch(\n (error: unknown) =>\n log.error(\"useComments stopCommentAutoUpdate error\", { commentCid, error }),\n );\n }\n };\n }, [commentCidsKey, account?.id, onlyIfCached, autoUpdate]);\n\n if (account && commentCids?.length) {\n log(\"useComments\", {\n commentCids,\n commentsStoreComments,\n commentsStore: useCommentsStore.getState().comments,\n account,\n });\n }\n\n // if comment from community pages exists and is fresher (or current missing), use it instead\n const liveComments = useMemo(() => {\n const result = [...commentsStoreComments];\n for (const i in result) {\n const candidate = communitiesPagesComments[i];\n if (candidate) result[i] = preferFresher(result[i], candidate);\n }\n return result;\n }, [commentsStoreComments, communitiesPagesComments]);\n\n const liveCommentsSettled = liveComments.every(\n (comment) => getCommentStateAndReplyCount(comment).state === \"succeeded\",\n );\n const freezeSettledForCurrentKey = freezeSettledKey === commentsKey;\n\n useEffect(() => {\n if (autoUpdate) {\n setFrozenComments([]);\n setFrozenCommentsKey(undefined);\n setFreezeSettledKey(undefined);\n return;\n }\n\n setFrozenComments([]);\n setFrozenCommentsKey(undefined);\n setFreezeSettledKey(undefined);\n }, [commentsKey, autoUpdate]);\n\n useEffect(() => {\n if (autoUpdate || freezeSettledForCurrentKey) {\n return;\n }\n\n setFrozenComments(liveComments);\n setFrozenCommentsKey(commentsKey);\n if (liveCommentsSettled) {\n setFreezeSettledKey(commentsKey);\n }\n }, [autoUpdate, commentsKey, freezeSettledForCurrentKey, liveComments, liveCommentsSettled]);\n\n const frozenCommentsForCurrentSelection =\n frozenCommentsKey === commentsKey ? frozenComments : undefined;\n const comments = autoUpdate ? liveComments : frozenCommentsForCurrentSelection || liveComments;\n const normalizedComments = useMemo(\n () => addOptimisticVoteCountsToComments(addCommentModerationToComments(comments), accountVotes),\n [comments, accountVotes],\n );\n\n // succeed if no comments are undefined\n const state = getCommentsState(normalizedComments);\n\n const refresh = useCallback(async () => {\n if (!account) {\n throw Error(\"useComments cannot refresh comments not initialized yet\");\n }\n const uniqueCommentCids = [...new Set(commentCids)];\n const refreshedComments = await Promise.all(\n uniqueCommentCids.map((commentCid) => refreshCommentInStore(commentCid, account)),\n );\n\n if (!autoUpdate && currentCommentsKeyRef.current === commentsKey) {\n const latestCommunitiesPagesComments = useCommunitiesPagesStore.getState().comments;\n const refreshedCommentsByCid = uniqueCommentCids.reduce(\n (\n refreshedCommentsMap: { [commentCid: string]: Comment | undefined },\n commentCid,\n index,\n ) => {\n refreshedCommentsMap[commentCid] = refreshedComments[index];\n return refreshedCommentsMap;\n },\n {},\n );\n setFrozenComments(\n commentCids.map((commentCid) =>\n preferFresher(\n refreshedCommentsByCid[commentCid || \"\"],\n latestCommunitiesPagesComments[commentCid || \"\"],\n ),\n ),\n );\n setFrozenCommentsKey(commentsKey);\n setFreezeSettledKey(commentsKey);\n }\n }, [account, autoUpdate, commentCids, commentsKey, refreshCommentInStore]);\n\n return useMemo(\n () => ({\n comments: normalizedComments,\n state,\n refresh,\n error: undefined,\n errors: [],\n }),\n [normalizedComments, commentsKey, refresh, state],\n );\n}\n\nexport function useValidateComment(options?: UseValidateCommentOptions): UseValidateCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useValidateComment options argument '${options}' not an object`,\n );\n let { comment, validateReplies, accountName } = options ?? {};\n validateReplies = validateReplies ?? true;\n const [validated, setValidated] = useState<boolean | undefined>();\n const [errors] = useState([]);\n const account = useAccount({ accountName });\n\n useEffect(() => {\n if (!comment || !account?.pkc) {\n setValidated(undefined);\n return;\n }\n // don't automatically block community because what community it comes from\n // a malicious community could try to block other communities, etc\n const blockCommunity = false;\n commentIsValid(comment, { validateReplies, blockCommunity }, account.pkc).then((validated) =>\n setValidated(validated),\n );\n }, [comment, validateReplies, account?.pkc]);\n\n let state = \"initializing\";\n if (validated === true) {\n state = \"succeeded\";\n }\n if (validated === false) {\n state = \"failed\";\n }\n\n // start valid at true always because most of the time the value will be true and we dont want to cause a rerender\n let valid = true;\n if (validated == false) {\n valid = false;\n }\n // if comment isn't defined, it would be confusing for valid to be true\n if (!comment) {\n valid = false;\n }\n\n return useMemo(\n () => ({\n valid,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [valid, state],\n );\n}\n"]}
1
+ {"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/hooks/comments.ts"],"names":[],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K,CAAC,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAccount } from \"./accounts\";\nimport validator from \"../lib/validator\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:comments:hooks\");\nimport assert from \"assert\";\nimport {\n Comment,\n UseCommentsOptions,\n UseCommentsResult,\n UseCommentOptions,\n UseCommentResult,\n UseCrosspostOptions,\n UseCrosspostResult,\n UseValidateCommentOptions,\n UseValidateCommentResult,\n} from \"../types\";\nimport useCommentsStore from \"../stores/comments\";\nimport useAccountsStore from \"../stores/accounts\";\nimport utils, { commentIsValid } from \"../lib/utils\";\nimport {\n addCommentModeration,\n addCommentModerationToComments,\n} from \"../lib/utils/comment-moderation\";\nimport useCommunitiesPagesStore from \"../stores/communities-pages\";\nimport useRepliesPagesStore from \"../stores/replies-pages\";\nimport shallow from \"zustand/shallow\";\nimport { assertCommunityRef } from \"../lib/community-ref\";\nimport {\n addOptimisticVoteCounts,\n addOptimisticVoteCountsToComments,\n} from \"../lib/utils/optimistic-vote-counts\";\n\nexport function getCommentFreshness(comment: Comment | undefined): number {\n if (!comment) return 0;\n return Math.max(comment.updatedAt ?? 0, comment.timestamp ?? 0, 0);\n}\n\nexport function preferFresher(\n current: Comment | undefined,\n candidate: Comment | undefined,\n): Comment | undefined {\n if (!candidate) return current;\n if (!current) return candidate;\n return getCommentFreshness(candidate) > getCommentFreshness(current) ? candidate : current;\n}\n\nconst getCommentStateAndReplyCount = (comment: Comment | undefined) => {\n let state = comment?.updatingState || \"initializing\";\n // force 'fetching-ipns' even if could be something else, so the frontend can use\n // the correct loading skeleton\n if (comment?.timestamp) {\n state = \"fetching-update-ipns\";\n }\n // force succeeded even if the comment is fecthing a new update\n if (comment?.updatedAt) {\n state = \"succeeded\";\n }\n\n // force succeeded if the comment is newer than 5 minutes, no need to display loading skeleton if comment was just created\n let replyCount = comment?.replyCount;\n if (\n comment?.replyCount === undefined &&\n comment?.timestamp &&\n comment?.timestamp > Date.now() / 1000 - 5 * 60\n ) {\n state = \"succeeded\";\n // set replyCount because some frontend are likely to check if replyCount === undefined to show a loading skeleton\n replyCount = 0;\n }\n\n return { state, replyCount };\n};\n\nconst getCommentsState = (comments: (Comment | undefined)[]) =>\n comments.every((comment) => getCommentStateAndReplyCount(comment).state === \"succeeded\")\n ? \"succeeded\"\n : \"fetching-ipfs\";\n\nlet commentAutoUpdateSubscriptionCount = 0;\nlet commentsAutoUpdateSubscriptionCount = 0;\n\nconst getCommentCreateCommentData = (\n commentCid: string | undefined,\n community: UseCommentOptions[\"community\"] | undefined,\n initialComment: Comment | undefined,\n ...comments: (Comment | undefined)[]\n) => {\n if (!commentCid) {\n return undefined;\n }\n\n const createCommentData: Comment = initialComment\n ? { ...utils.clone(initialComment), cid: commentCid }\n : { cid: commentCid };\n let hasCreateCommentData = Boolean(initialComment);\n for (const comment of comments) {\n if (!comment) {\n continue;\n }\n if (!createCommentData.communityPublicKey && comment.communityPublicKey) {\n createCommentData.communityPublicKey = comment.communityPublicKey;\n hasCreateCommentData = true;\n }\n if (!createCommentData.communityName && comment.communityName) {\n createCommentData.communityName = comment.communityName;\n hasCreateCommentData = true;\n }\n }\n\n if (community?.publicKey) {\n createCommentData.communityPublicKey = community.publicKey;\n hasCreateCommentData = true;\n }\n if (community?.name) {\n createCommentData.communityName = community.name;\n hasCreateCommentData = true;\n }\n\n return hasCreateCommentData ? createCommentData : undefined;\n};\n\n/**\n * @param commentCid - The IPFS CID of the comment to get\n * @param community - The community identifier, e.g. {name: 'memes.eth', publicKey: '12D3KooW...'}.\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\nexport function useComment(options?: UseCommentOptions): UseCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useComment options argument '${options}' not an object`,\n );\n const {\n commentCid,\n community,\n initialComment,\n accountName,\n onlyIfCached,\n autoUpdate = true,\n } = options ?? {};\n if (community !== undefined) {\n assertCommunityRef(community, \"useComment community\");\n }\n const account = useAccount({ accountName });\n const commentFromStore = useCommentsStore((state: any) => state.comments[commentCid || \"\"]);\n const addCommentToStore = useCommentsStore((state: any) => state.addCommentToStore);\n const startCommentAutoUpdate = useCommentsStore((state: any) => state.startCommentAutoUpdate);\n const stopCommentAutoUpdate = useCommentsStore((state: any) => state.stopCommentAutoUpdate);\n const refreshCommentInStore = useCommentsStore((state: any) => state.refreshComment);\n const communitiesPagesComment = useCommunitiesPagesStore(\n (state: any) => state.comments[commentCid || \"\"],\n );\n const repliesPagesComment = useRepliesPagesStore(\n (state: any) => state.comments[commentCid || \"\"],\n );\n const errors = useCommentsStore((state: any) => state.errors[commentCid || \"\"]);\n\n // get account comment of the cid if any\n const accountCommentInfo = useAccountsStore(\n (state: any) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const accountComment = useAccountsStore(\n (state: any) =>\n state.accountsComments[accountCommentInfo?.accountId || \"\"]?.[\n Number(accountCommentInfo?.accountCommentIndex)\n ],\n );\n const accountVote = useAccountsStore((state: any) =>\n account?.id && commentCid ? state.accountsVotes[account.id]?.[commentCid] : undefined,\n );\n const createCommentData = useMemo(\n () =>\n getCommentCreateCommentData(\n commentCid,\n community,\n initialComment,\n communitiesPagesComment,\n repliesPagesComment,\n ),\n [\n commentCid,\n community?.name,\n community?.publicKey,\n initialComment,\n communitiesPagesComment?.communityName,\n communitiesPagesComment?.communityPublicKey,\n repliesPagesComment?.communityName,\n repliesPagesComment?.communityPublicKey,\n ],\n );\n const autoUpdateSubscriptionId = useRef(`useComment-${++commentAutoUpdateSubscriptionCount}`);\n const currentCommentCidRef = useRef<string | undefined>(commentCid);\n currentCommentCidRef.current = commentCid;\n const [frozenComment, setFrozenComment] = useState<Comment | undefined>();\n const [freezeSettledCid, setFreezeSettledCid] = useState<string>();\n\n useEffect(() => {\n if (!commentCid || !account) {\n return;\n }\n validator.validateUseCommentArguments(commentCid, account);\n if (!commentFromStore && !onlyIfCached) {\n // if comment isn't already in store, add it\n const addCommentPromise = createCommentData\n ? addCommentToStore(commentCid, account, createCommentData)\n : addCommentToStore(commentCid, account);\n addCommentPromise.catch((error: unknown) =>\n log.error(\"useComment addCommentToStore error\", { commentCid, error }),\n );\n }\n }, [commentCid, account?.id, onlyIfCached, createCommentData]);\n\n useEffect(() => {\n if (!commentCid || !account || onlyIfCached || !autoUpdate) {\n return;\n }\n\n const startAutoUpdatePromise = createCommentData\n ? startCommentAutoUpdate(\n commentCid,\n autoUpdateSubscriptionId.current,\n account,\n createCommentData,\n )\n : startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account);\n startAutoUpdatePromise.catch((error: unknown) =>\n log.error(\"useComment startCommentAutoUpdate error\", { commentCid, error }),\n );\n\n return () => {\n stopCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current).catch((error: unknown) =>\n log.error(\"useComment stopCommentAutoUpdate error\", { commentCid, error }),\n );\n };\n }, [commentCid, account?.id, onlyIfCached, autoUpdate, createCommentData]);\n\n let selectedComment = commentFromStore;\n\n if (commentCid && communitiesPagesComment) {\n selectedComment = preferFresher(selectedComment, communitiesPagesComment);\n }\n if (commentCid && repliesPagesComment) {\n selectedComment = preferFresher(selectedComment, repliesPagesComment);\n }\n\n // if comment is still not defined, but account comment is, use account comment\n // check `comment.timestamp` instead of `comment` in case comment exists but in a loading state\n const commentFromStoreNotLoaded = !selectedComment?.timestamp;\n if (commentCid && commentFromStoreNotLoaded && accountComment) {\n selectedComment = accountComment;\n }\n const selectedCommentWithFallback = useMemo(() => {\n if (!commentCid || !commentFromStoreNotLoaded || !initialComment) {\n return selectedComment;\n }\n const commentWithFallback = utils.merge(\n initialComment.raw?.comment || {},\n initialComment,\n { cid: commentCid },\n selectedComment || {},\n );\n commentWithFallback.raw = utils.merge(initialComment.raw || {}, selectedComment?.raw || {});\n return commentWithFallback;\n }, [commentCid, commentFromStoreNotLoaded, initialComment, selectedComment]);\n selectedComment = selectedCommentWithFallback;\n\n const selectedCommentState = getCommentStateAndReplyCount(selectedComment).state;\n const selectedCommentShortAddress = selectedComment?.author?.shortAddress;\n const initialCommentUpdatePending = Boolean(\n initialComment?.raw?.comment && !selectedComment?.raw?.commentUpdate,\n );\n const freezeSettledForCurrentCid = freezeSettledCid === commentCid;\n\n useEffect(() => {\n if (autoUpdate) {\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n return;\n }\n\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n }, [commentCid, autoUpdate]);\n\n useEffect(() => {\n if (autoUpdate) {\n return;\n }\n if (!commentCid) {\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n return;\n }\n if (!selectedComment) {\n return;\n }\n if (freezeSettledForCurrentCid) {\n // A new local publication can look settled from its timestamp before the\n // canonical number and author identity arrive. Absorb only that immutable\n // metadata while keeping later vote and reply updates frozen.\n const frozenCommentForCurrentCid =\n frozenComment?.cid === commentCid ? frozenComment : undefined;\n const frozenCommentShortAddress = frozenCommentForCurrentCid?.author?.shortAddress;\n const hasReconciledPublicationMetadata =\n (selectedComment.number !== undefined &&\n selectedComment.number !== frozenCommentForCurrentCid?.number) ||\n (selectedComment.postNumber !== undefined &&\n selectedComment.postNumber !== frozenCommentForCurrentCid?.postNumber) ||\n (selectedCommentShortAddress && selectedCommentShortAddress !== frozenCommentShortAddress);\n if (hasReconciledPublicationMetadata && frozenCommentForCurrentCid) {\n setFrozenComment({\n ...frozenCommentForCurrentCid,\n ...(selectedComment.number !== undefined ? { number: selectedComment.number } : {}),\n ...(selectedComment.postNumber !== undefined\n ? { postNumber: selectedComment.postNumber }\n : {}),\n ...(selectedCommentShortAddress\n ? {\n author: {\n ...frozenCommentForCurrentCid.author,\n shortAddress: selectedCommentShortAddress,\n },\n }\n : {}),\n });\n }\n return;\n }\n\n setFrozenComment(selectedComment);\n if (selectedCommentState === \"succeeded\" && !initialCommentUpdatePending) {\n setFreezeSettledCid(commentCid);\n }\n }, [\n autoUpdate,\n commentCid,\n selectedComment,\n selectedCommentState,\n initialCommentUpdatePending,\n freezeSettledForCurrentCid,\n frozenComment,\n selectedCommentShortAddress,\n ]);\n\n const frozenCommentForCurrentCid = frozenComment?.cid === commentCid ? frozenComment : undefined;\n let comment = autoUpdate\n ? selectedComment\n : freezeSettledForCurrentCid\n ? frozenCommentForCurrentCid\n : frozenCommentForCurrentCid || selectedComment;\n comment = addCommentModeration(comment);\n comment = addOptimisticVoteCounts(comment, accountVote);\n\n const { state, replyCount } = getCommentStateAndReplyCount(comment);\n\n if (account && commentCid) {\n log(\"useComment\", {\n commentCid,\n comment,\n replyCount,\n state,\n commentFromStore,\n communitiesPagesComment,\n repliesPagesComment,\n accountComment,\n commentsStore: useCommentsStore.getState().comments,\n account,\n onlyIfCached,\n autoUpdate,\n });\n }\n\n const refresh = useCallback(async () => {\n if (!commentCid || !account) {\n throw Error(\"useComment cannot refresh comment not initialized yet\");\n }\n\n const refreshCommentCid = commentCid;\n const refreshedComment = createCommentData\n ? await refreshCommentInStore(refreshCommentCid, account, createCommentData)\n : await refreshCommentInStore(refreshCommentCid, account);\n if (!autoUpdate && refreshedComment && currentCommentCidRef.current === refreshCommentCid) {\n setFrozenComment(refreshedComment);\n setFreezeSettledCid(refreshCommentCid);\n }\n }, [account, autoUpdate, commentCid, createCommentData, refreshCommentInStore]);\n\n return useMemo(\n () => ({\n ...comment,\n replyCount,\n state,\n refresh,\n error: errors?.[errors.length - 1],\n errors: errors || [],\n }),\n [comment, commentCid, errors, refresh, state, replyCount],\n );\n}\n\n/**\n * Read a crosspost from its embedded signed record immediately, then use the normal comment store\n * to load the referenced community's current CommentUpdate when it is available.\n */\nexport function useCrosspost(options?: UseCrosspostOptions): UseCrosspostResult {\n assert(\n !options || typeof options === \"object\",\n `useCrosspost options argument '${options}' not an object`,\n );\n const { crosspost, accountName, autoUpdate = true } = options ?? {};\n const initialComment = useMemo(\n () =>\n crosspost\n ? {\n cid: crosspost.cid,\n raw: { comment: crosspost.comment },\n }\n : undefined,\n [crosspost],\n );\n const comment = useComment({\n accountName,\n autoUpdate,\n commentCid: crosspost?.cid,\n initialComment,\n });\n\n return useMemo(\n () => ({\n ...comment,\n isCommunityVerified: Boolean(comment.raw?.commentUpdate),\n }),\n [comment],\n );\n}\n\n/**\n * @param commentCids - The IPFS CIDs of the comments to get\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\nexport function useComments(options?: UseCommentsOptions): UseCommentsResult {\n assert(\n !options || typeof options === \"object\",\n `useComments options argument '${options}' not an object`,\n );\n const { commentCids = [], accountName, onlyIfCached, autoUpdate = true } = options ?? {};\n const account = useAccount({ accountName });\n const accountVotes = useAccountsStore((state: any) =>\n account?.id ? state.accountsVotes[account.id] : undefined,\n );\n const commentsStoreComments: (Comment | undefined)[] = useCommentsStore(\n (state: any) => commentCids.map((commentCid) => state.comments[commentCid || \"\"]),\n shallow,\n );\n const communitiesPagesComments: (Comment | undefined)[] = useCommunitiesPagesStore(\n (state: any) => commentCids.map((commentCid) => state.comments[commentCid || \"\"]),\n shallow,\n );\n\n const addCommentToStore = useCommentsStore((state: any) => state.addCommentToStore);\n const startCommentAutoUpdate = useCommentsStore((state: any) => state.startCommentAutoUpdate);\n const stopCommentAutoUpdate = useCommentsStore((state: any) => state.stopCommentAutoUpdate);\n const refreshCommentInStore = useCommentsStore((state: any) => state.refreshComment);\n const autoUpdateSubscriptionId = useRef(`useComments-${++commentsAutoUpdateSubscriptionCount}`);\n const commentCidsKey = JSON.stringify(commentCids);\n const commentsKey = `${account?.id || \"\"}:${commentCidsKey}`;\n const currentCommentsKeyRef = useRef(commentsKey);\n currentCommentsKeyRef.current = commentsKey;\n const [frozenComments, setFrozenComments] = useState<(Comment | undefined)[]>([]);\n const [frozenCommentsKey, setFrozenCommentsKey] = useState<string>();\n const [freezeSettledKey, setFreezeSettledKey] = useState<string>();\n\n useEffect(() => {\n if (!commentCids || !account) {\n return;\n }\n validator.validateUseCommentsArguments(commentCids, account);\n if (onlyIfCached) {\n return;\n }\n const uniqueCommentCids = new Set(commentCids);\n for (const commentCid of uniqueCommentCids) {\n addCommentToStore(commentCid, account).catch((error: unknown) =>\n log.error(\"useComments addCommentToStore error\", { commentCid, error }),\n );\n }\n }, [commentCidsKey, account?.id, onlyIfCached]);\n\n useEffect(() => {\n if (!commentCids || !account || onlyIfCached || !autoUpdate) {\n return;\n }\n\n const uniqueCommentCids = [...new Set(commentCids)];\n for (const commentCid of uniqueCommentCids) {\n startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account).catch(\n (error: unknown) =>\n log.error(\"useComments startCommentAutoUpdate error\", { commentCid, error }),\n );\n }\n\n return () => {\n for (const commentCid of uniqueCommentCids) {\n stopCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current).catch(\n (error: unknown) =>\n log.error(\"useComments stopCommentAutoUpdate error\", { commentCid, error }),\n );\n }\n };\n }, [commentCidsKey, account?.id, onlyIfCached, autoUpdate]);\n\n if (account && commentCids?.length) {\n log(\"useComments\", {\n commentCids,\n commentsStoreComments,\n commentsStore: useCommentsStore.getState().comments,\n account,\n });\n }\n\n // if comment from community pages exists and is fresher (or current missing), use it instead\n const liveComments = useMemo(() => {\n const result = [...commentsStoreComments];\n for (const i in result) {\n const candidate = communitiesPagesComments[i];\n if (candidate) result[i] = preferFresher(result[i], candidate);\n }\n return result;\n }, [commentsStoreComments, communitiesPagesComments]);\n\n const liveCommentsSettled = liveComments.every(\n (comment) => getCommentStateAndReplyCount(comment).state === \"succeeded\",\n );\n const freezeSettledForCurrentKey = freezeSettledKey === commentsKey;\n\n useEffect(() => {\n if (autoUpdate) {\n setFrozenComments([]);\n setFrozenCommentsKey(undefined);\n setFreezeSettledKey(undefined);\n return;\n }\n\n setFrozenComments([]);\n setFrozenCommentsKey(undefined);\n setFreezeSettledKey(undefined);\n }, [commentsKey, autoUpdate]);\n\n useEffect(() => {\n if (autoUpdate || freezeSettledForCurrentKey) {\n return;\n }\n\n setFrozenComments(liveComments);\n setFrozenCommentsKey(commentsKey);\n if (liveCommentsSettled) {\n setFreezeSettledKey(commentsKey);\n }\n }, [autoUpdate, commentsKey, freezeSettledForCurrentKey, liveComments, liveCommentsSettled]);\n\n const frozenCommentsForCurrentSelection =\n frozenCommentsKey === commentsKey ? frozenComments : undefined;\n const comments = autoUpdate ? liveComments : frozenCommentsForCurrentSelection || liveComments;\n const normalizedComments = useMemo(\n () => addOptimisticVoteCountsToComments(addCommentModerationToComments(comments), accountVotes),\n [comments, accountVotes],\n );\n\n // succeed if no comments are undefined\n const state = getCommentsState(normalizedComments);\n\n const refresh = useCallback(async () => {\n if (!account) {\n throw Error(\"useComments cannot refresh comments not initialized yet\");\n }\n const uniqueCommentCids = [...new Set(commentCids)];\n const refreshedComments = await Promise.all(\n uniqueCommentCids.map((commentCid) => refreshCommentInStore(commentCid, account)),\n );\n\n if (!autoUpdate && currentCommentsKeyRef.current === commentsKey) {\n const latestCommunitiesPagesComments = useCommunitiesPagesStore.getState().comments;\n const refreshedCommentsByCid = uniqueCommentCids.reduce(\n (\n refreshedCommentsMap: { [commentCid: string]: Comment | undefined },\n commentCid,\n index,\n ) => {\n refreshedCommentsMap[commentCid] = refreshedComments[index];\n return refreshedCommentsMap;\n },\n {},\n );\n setFrozenComments(\n commentCids.map((commentCid) =>\n preferFresher(\n refreshedCommentsByCid[commentCid || \"\"],\n latestCommunitiesPagesComments[commentCid || \"\"],\n ),\n ),\n );\n setFrozenCommentsKey(commentsKey);\n setFreezeSettledKey(commentsKey);\n }\n }, [account, autoUpdate, commentCids, commentsKey, refreshCommentInStore]);\n\n return useMemo(\n () => ({\n comments: normalizedComments,\n state,\n refresh,\n error: undefined,\n errors: [],\n }),\n [normalizedComments, commentsKey, refresh, state],\n );\n}\n\nexport function useValidateComment(options?: UseValidateCommentOptions): UseValidateCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useValidateComment options argument '${options}' not an object`,\n );\n let { comment, validateReplies, accountName } = options ?? {};\n validateReplies = validateReplies ?? true;\n const [validated, setValidated] = useState<boolean | undefined>();\n const [errors] = useState([]);\n const account = useAccount({ accountName });\n\n useEffect(() => {\n if (!comment || !account?.pkc) {\n setValidated(undefined);\n return;\n }\n // don't automatically block community because what community it comes from\n // a malicious community could try to block other communities, etc\n const blockCommunity = false;\n commentIsValid(comment, { validateReplies, blockCommunity }, account.pkc).then((validated) =>\n setValidated(validated),\n );\n }, [comment, validateReplies, account?.pkc]);\n\n let state = \"initializing\";\n if (validated === true) {\n state = \"succeeded\";\n }\n if (validated === false) {\n state = \"failed\";\n }\n\n // start valid at true always because most of the time the value will be true and we dont want to cause a rerender\n let valid = true;\n if (validated == false) {\n valid = false;\n }\n // if comment isn't defined, it would be confusing for valid to be true\n if (!comment) {\n valid = false;\n }\n\n return useMemo(\n () => ({\n valid,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [valid, state],\n );\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { useReplies } from "./hooks/replies.js";
4
4
  import { useCommunity, useCommunities, useCommunityStats, useListCommunities, useResolvedCommunityAddress } from "./hooks/communities.js";
5
5
  import { useFeed, useBufferedFeeds } from "./hooks/feeds/index.js";
6
6
  import { useAuthor, useAuthorComments, useAuthorAvatar, useResolvedAuthorAddress, useAuthorAddress, setAuthorAvatarsWhitelistedTokenAddresses, resetAuthorAddressCacheForTesting } from "./hooks/authors/index.js";
7
- import { useSubscribe, useBlock, usePublishComment, usePublishVote, useCreateCommunity, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useExportCommunity } from "./hooks/actions/index.js";
7
+ import { useSubscribe, useBlock, useSaveComment, usePublishComment, usePublishVote, useCreateCommunity, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useExportCommunity } from "./hooks/actions/index.js";
8
8
  import { createAccount, deleteAccount, deleteComment, setAccount, setActiveAccount, setAccountsOrder, importAccount, exportAccount, deleteCommunity } from "./stores/accounts/accounts-actions.js";
9
9
  import { useClientsStates, useCommunitiesStates } from "./hooks/states.js";
10
10
  import { usePkcRpcSettings } from "./hooks/pkc-rpc.js";
@@ -14,7 +14,7 @@ import { deleteDatabases, deleteCaches } from "./lib/debug-utils.js";
14
14
  import { createCrosspost } from "./lib/crosspost.js";
15
15
  import { getAvailablePostSortTypes, getAvailableReplySortTypes, getPreloadedPostSortType, getPreloadedReplySortType, resolvePostSortType, resolveReplySortType } from "./lib/page-sorts.js";
16
16
  export * from "./types.js";
17
- export { useAccount, useAccounts, useAccountComment, useAccountComments, useAccountVotes, useAccountVote, useAccountEdits, useAccountCommunities, useNotifications, usePubsubSubscribe, useComment, useComments, useCrosspost, useEditedComment, useValidateComment, useReplies, useCommunity, useCommunities, useCommunityStats, useListCommunities, useResolvedCommunityAddress, useAuthor, useAuthorComments, useAuthorAvatar, useResolvedAuthorAddress, useAuthorAddress, setAuthorAvatarsWhitelistedTokenAddresses, resetAuthorAddressCacheForTesting, useFeed, useBufferedFeeds, useSubscribe, useBlock, usePublishComment, usePublishVote, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useCreateCommunity, useExportCommunity, createAccount, deleteAccount, deleteComment, setAccount, setActiveAccount, setAccountsOrder, importAccount, exportAccount, deleteCommunity, useClientsStates, useCommunitiesStates, usePkcRpcSettings, getEthWalletFromPkcPrivateKey, getEthPrivateKeyFromPkcPrivateKey, validateEthWallet, setPkcJs, restorePkcJs, deleteDatabases, deleteCaches, createCrosspost, getAvailablePostSortTypes, getAvailableReplySortTypes, getPreloadedPostSortType, getPreloadedReplySortType, resolvePostSortType, resolveReplySortType, };
17
+ export { useAccount, useAccounts, useAccountComment, useAccountComments, useAccountVotes, useAccountVote, useAccountEdits, useAccountCommunities, useNotifications, usePubsubSubscribe, useComment, useComments, useCrosspost, useEditedComment, useValidateComment, useReplies, useCommunity, useCommunities, useCommunityStats, useListCommunities, useResolvedCommunityAddress, useAuthor, useAuthorComments, useAuthorAvatar, useResolvedAuthorAddress, useAuthorAddress, setAuthorAvatarsWhitelistedTokenAddresses, resetAuthorAddressCacheForTesting, useFeed, useBufferedFeeds, useSubscribe, useBlock, useSaveComment, usePublishComment, usePublishVote, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useCreateCommunity, useExportCommunity, createAccount, deleteAccount, deleteComment, setAccount, setActiveAccount, setAccountsOrder, importAccount, exportAccount, deleteCommunity, useClientsStates, useCommunitiesStates, usePkcRpcSettings, getEthWalletFromPkcPrivateKey, getEthPrivateKeyFromPkcPrivateKey, validateEthWallet, setPkcJs, restorePkcJs, deleteDatabases, deleteCaches, createCrosspost, getAvailablePostSortTypes, getAvailableReplySortTypes, getPreloadedPostSortType, getPreloadedReplySortType, resolvePostSortType, resolveReplySortType, };
18
18
  declare const hooks: {
19
19
  useAccount: typeof useAccount;
20
20
  useAccounts: typeof useAccounts;
@@ -48,6 +48,7 @@ declare const hooks: {
48
48
  useBufferedFeeds: typeof useBufferedFeeds;
49
49
  useSubscribe: typeof useSubscribe;
50
50
  useBlock: typeof useBlock;
51
+ useSaveComment: typeof useSaveComment;
51
52
  usePublishComment: typeof usePublishComment;
52
53
  usePublishVote: typeof usePublishVote;
53
54
  usePublishCommentEdit: typeof usePublishCommentEdit;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG7F,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,2BA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,eAAe,EACf,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAElB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAElB,UAAU,EAEV,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,EAE3B,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,yCAAyC,EACzC,iCAAiC,EAEjC,OAAO,EACP,gBAAgB,EAEhB,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAElB,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,eAAe,EAEf,gBAAgB,EAChB,oBAAoB,EAEpB,iBAAiB,EAEjB,6BAA6B,EAC7B,iCAAiC,EACjC,iBAAiB,EAEjB,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,GACrB,CAAC;AAGF,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EV,CAAC;AAEF,eAAe,KAAK,CAAC"}
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { useFeed, useBufferedFeeds } from "./hooks/feeds/index.js";
13
13
  // authors
14
14
  import { useAuthor, useAuthorComments, useAuthorAvatar, useResolvedAuthorAddress, useAuthorAddress, setAuthorAvatarsWhitelistedTokenAddresses, resetAuthorAddressCacheForTesting, } from "./hooks/authors/index.js";
15
15
  // actions
16
- import { useSubscribe, useBlock, usePublishComment, usePublishVote, useCreateCommunity, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useExportCommunity, } from "./hooks/actions/index.js";
16
+ import { useSubscribe, useBlock, useSaveComment, usePublishComment, usePublishVote, useCreateCommunity, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useExportCommunity, } from "./hooks/actions/index.js";
17
17
  // actions that don't have their own hooks yet
18
18
  import { createAccount, deleteAccount, deleteComment, setAccount, setActiveAccount, setAccountsOrder, importAccount, exportAccount, deleteCommunity, } from "./stores/accounts/accounts-actions.js";
19
19
  // states
@@ -44,7 +44,7 @@ useAuthor, useAuthorComments, useAuthorAvatar, useResolvedAuthorAddress, useAuth
44
44
  // feeds
45
45
  useFeed, useBufferedFeeds,
46
46
  // actions
47
- useSubscribe, useBlock, usePublishComment, usePublishVote, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useCreateCommunity, useExportCommunity,
47
+ useSubscribe, useBlock, useSaveComment, usePublishComment, usePublishVote, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useCreateCommunity, useExportCommunity,
48
48
  // actions that don't have their own hooks yet
49
49
  createAccount, deleteAccount, deleteComment, setAccount, setActiveAccount, setAccountsOrder, importAccount, exportAccount, deleteCommunity,
50
50
  // states
@@ -96,6 +96,7 @@ const hooks = {
96
96
  // actions
97
97
  useSubscribe,
98
98
  useBlock,
99
+ useSaveComment,
99
100
  usePublishComment,
100
101
  usePublishVote,
101
102
  usePublishCommentEdit,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,QAAQ,EAAE,CAAC;AAEX,WAAW;AACX,OAAO,EACL,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,E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oB,GACrB,CAAC;AAEF,+CAA+C;AAC/C,MAAM,KAAK,GAAG;IACZ,WAAW;IACX,UAAU;IACV,WAAW;IACX,iBAAiB;IACjB,kBAAkB;IAClB,eAAe;IACf,cAAc;IACd,eAAe;IACf,qBAAqB;IACrB,gBAAgB;IAChB,kBAAkB;IAClB,WAAW;IACX,UAAU;IACV,WAAW;IACX,YAAY;IACZ,gBAAgB;IAChB,kBAAkB;IAClB,UAAU;IACV,UAAU;IACV,cAAc;IACd,YAAY;IACZ,cAAc;IACd,iBAAiB;IACjB,kBAAkB;IAClB,2BAA2B;IAC3B,UAAU;IACV,SAAS;IACT,iBAAiB;IACjB,eAAe;IACf,wBAAwB;IACxB,gBAAgB;IAChB,yCAAyC;IACzC,iCAAiC;IACjC,QAAQ;IACR,OAAO;IACP,gBAAgB;IAChB,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,iBAAiB;IACjB,cAAc;IACd,qBAAqB;IACrB,2BAA2B;IAC3B,uBAAuB;IACvB,kBAAkB;IAClB,kBAAkB;IAClB,8CAA8C;IAC9C,aAAa;IACb,aAAa;IACb,aAAa;IACb,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,eAAe;IACf,SAAS;IACT,gBAAgB;IAChB,oBAAoB;IACpB,UAAU;IACV,iBAAiB;IACjB,QAAQ;IACR,6BAA6B;IAC7B,iCAAiC;IACjC,iBAAiB;IACjB,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,eAAe;IACf,yBAAyB;IACzB,0BAA0B;IAC1B,wBAAwB;IACxB,yBAAyB;IACzB,mBAAmB;IACnB,oBAAoB;CACrB,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import polyfill from \"./lib/polyfill\";\npolyfill();\n\n// accounts\nimport {\n useAccount,\n useAccounts,\n useAccountComment,\n useAccountComments,\n useAccountVotes,\n useAccountVote,\n useAccountEdits,\n useEditedComment,\n useNotifications,\n useAccountCommunities,\n usePubsubSubscribe,\n} from \"./hooks/accounts\";\n\n// comments\nimport { useComment, useComments, useCrosspost, useValidateComment } from \"./hooks/comments\";\n\n// replies\nimport { useReplies } from \"./hooks/replies\";\n\n// communities\nimport {\n useCommunity,\n useCommunities,\n useCommunityStats,\n useListCommunities,\n useResolvedCommunityAddress,\n} from \"./hooks/communities\";\n\n// feeds\nimport { useFeed, useBufferedFeeds } from \"./hooks/feeds\";\n\n// authors\nimport {\n useAuthor,\n useAuthorComments,\n useAuthorAvatar,\n useResolvedAuthorAddress,\n useAuthorAddress,\n setAuthorAvatarsWhitelistedTokenAddresses,\n resetAuthorAddressCacheForTesting,\n} from \"./hooks/authors\";\n\n// actions\nimport {\n useSubscribe,\n useBlock,\n usePublishComment,\n usePublishVote,\n useCreateCommunity,\n usePublishCommentEdit,\n usePublishCommentModeration,\n usePublishCommunityEdit,\n useExportCommunity,\n} from \"./hooks/actions\";\n\n// actions that don't have their own hooks yet\nimport {\n createAccount,\n deleteAccount,\n deleteComment,\n setAccount,\n setActiveAccount,\n setAccountsOrder,\n importAccount,\n exportAccount,\n deleteCommunity,\n} from \"./stores/accounts/accounts-actions\";\n\n// states\nimport { useClientsStates, useCommunitiesStates } from \"./hooks/states\";\n\n// pkc-rpc\nimport { usePkcRpcSettings } from \"./hooks/pkc-rpc\";\n\n// chain\nimport {\n getEthWalletFromPkcPrivateKey,\n getEthPrivateKeyFromPkcPrivateKey,\n validateEthWallet,\n} from \"./lib/chain\";\n\n// utils\nimport { setPkcJs, restorePkcJs } from \"./lib/pkc-js\";\nimport { deleteDatabases, deleteCaches } from \"./lib/debug-utils\";\nimport { createCrosspost } from \"./lib/crosspost\";\nimport {\n getAvailablePostSortTypes,\n getAvailableReplySortTypes,\n getPreloadedPostSortType,\n getPreloadedReplySortType,\n resolvePostSortType,\n resolveReplySortType,\n} from \"./lib/page-sorts\";\n\n// types\nexport * from \"./types\";\n\n// IMPORTANT: should be the same as 'export default hooks'\nexport {\n // accounts\n useAccount,\n useAccounts,\n useAccountComment,\n useAccountComments,\n useAccountVotes,\n useAccountVote,\n useAccountEdits,\n useAccountCommunities,\n useNotifications,\n usePubsubSubscribe,\n // comments\n useComment,\n useComments,\n useCrosspost,\n useEditedComment,\n useValidateComment,\n // replies\n useReplies,\n // communities\n useCommunity,\n useCommunities,\n useCommunityStats,\n useListCommunities,\n useResolvedCommunityAddress,\n // authors\n useAuthor,\n useAuthorComments,\n useAuthorAvatar,\n useResolvedAuthorAddress,\n useAuthorAddress,\n setAuthorAvatarsWhitelistedTokenAddresses,\n resetAuthorAddressCacheForTesting,\n // feeds\n useFeed,\n useBufferedFeeds,\n // actions\n useSubscribe,\n useBlock,\n usePublishComment,\n usePublishVote,\n usePublishCommentEdit,\n usePublishCommentModeration,\n usePublishCommunityEdit,\n useCreateCommunity,\n useExportCommunity,\n // actions that don't have their own hooks yet\n createAccount,\n deleteAccount,\n deleteComment,\n setAccount,\n setActiveAccount,\n setAccountsOrder,\n importAccount,\n exportAccount,\n deleteCommunity,\n // states\n useClientsStates,\n useCommunitiesStates,\n // pkc-rpc\n usePkcRpcSettings,\n // chain\n getEthWalletFromPkcPrivateKey,\n getEthPrivateKeyFromPkcPrivateKey,\n validateEthWallet,\n // utils\n setPkcJs,\n restorePkcJs,\n deleteDatabases,\n deleteCaches,\n createCrosspost,\n getAvailablePostSortTypes,\n getAvailableReplySortTypes,\n getPreloadedPostSortType,\n getPreloadedReplySortType,\n resolvePostSortType,\n resolveReplySortType,\n};\n\n// IMPORTANT: should be the same as 'export {}'\nconst hooks = {\n // accounts\n useAccount,\n useAccounts,\n useAccountComment,\n useAccountComments,\n useAccountVotes,\n useAccountVote,\n useAccountEdits,\n useAccountCommunities,\n useNotifications,\n usePubsubSubscribe,\n // comments\n useComment,\n useComments,\n useCrosspost,\n useEditedComment,\n useValidateComment,\n // replies\n useReplies,\n // communities\n useCommunity,\n useCommunities,\n useCommunityStats,\n useListCommunities,\n useResolvedCommunityAddress,\n // authors\n useAuthor,\n useAuthorComments,\n useAuthorAvatar,\n useResolvedAuthorAddress,\n useAuthorAddress,\n setAuthorAvatarsWhitelistedTokenAddresses,\n resetAuthorAddressCacheForTesting,\n // feeds\n useFeed,\n useBufferedFeeds,\n // actions\n useSubscribe,\n useBlock,\n usePublishComment,\n usePublishVote,\n usePublishCommentEdit,\n usePublishCommentModeration,\n usePublishCommunityEdit,\n useCreateCommunity,\n useExportCommunity,\n // actions that don't have their own hooks yet\n createAccount,\n deleteAccount,\n deleteComment,\n setAccount,\n setActiveAccount,\n setAccountsOrder,\n importAccount,\n exportAccount,\n deleteCommunity,\n // states\n useClientsStates,\n useCommunitiesStates,\n // pkc-rpc\n usePkcRpcSettings,\n // chain\n getEthWalletFromPkcPrivateKey,\n getEthPrivateKeyFromPkcPrivateKey,\n validateEthWallet,\n // utils\n setPkcJs,\n restorePkcJs,\n deleteDatabases,\n deleteCaches,\n createCrosspost,\n getAvailablePostSortTypes,\n getAvailableReplySortTypes,\n getPreloadedPostSortType,\n getPreloadedReplySortType,\n resolvePostSortType,\n resolveReplySortType,\n};\n\nexport default hooks;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,QAAQ,EAAE,CAAC;AAEX,WAAW;AACX,OAAO,EACL,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,WAAW;AACX,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE7F,UAAU;AACV,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,cAAc;AACd,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB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AgB;IAChB,kBAAkB;IAClB,UAAU;IACV,UAAU;IACV,cAAc;IACd,YAAY;IACZ,cAAc;IACd,iBAAiB;IACjB,kBAAkB;IAClB,2BAA2B;IAC3B,UAAU;IACV,SAAS;IACT,iBAAiB;IACjB,eAAe;IACf,wBAAwB;IACxB,gBAAgB;IAChB,yCAAyC;IACzC,iCAAiC;IACjC,QAAQ;IACR,OAAO;IACP,gBAAgB;IAChB,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,cAAc;IACd,iBAAiB;IACjB,cAAc;IACd,qBAAqB;IACrB,2BAA2B;IAC3B,uBAAuB;IACvB,kBAAkB;IAClB,kBAAkB;IAClB,8CAA8C;IAC9C,aAAa;IACb,aAAa;IACb,aAAa;IACb,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,eAAe;IACf,SAAS;IACT,gBAAgB;IAChB,oBAAoB;IACpB,UAAU;IACV,iBAAiB;IACjB,QAAQ;IACR,6BAA6B;IAC7B,iCAAiC;IACjC,iBAAiB;IACjB,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,eAAe;IACf,yBAAyB;IACzB,0BAA0B;IAC1B,wBAAwB;IACxB,yBAAyB;IACzB,mBAAmB;IACnB,oBAAoB;CACrB,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import polyfill from \"./lib/polyfill\";\npolyfill();\n\n// accounts\nimport {\n useAccount,\n useAccounts,\n useAccountComment,\n useAccountComments,\n useAccountVotes,\n useAccountVote,\n useAccountEdits,\n useEditedComment,\n useNotifications,\n useAccountCommunities,\n usePubsubSubscribe,\n} from \"./hooks/accounts\";\n\n// comments\nimport { useComment, useComments, useCrosspost, useValidateComment } from \"./hooks/comments\";\n\n// replies\nimport { useReplies } from \"./hooks/replies\";\n\n// communities\nimport {\n useCommunity,\n useCommunities,\n useCommunityStats,\n useListCommunities,\n useResolvedCommunityAddress,\n} from \"./hooks/communities\";\n\n// feeds\nimport { useFeed, useBufferedFeeds } from \"./hooks/feeds\";\n\n// authors\nimport {\n useAuthor,\n useAuthorComments,\n useAuthorAvatar,\n useResolvedAuthorAddress,\n useAuthorAddress,\n setAuthorAvatarsWhitelistedTokenAddresses,\n resetAuthorAddressCacheForTesting,\n} from \"./hooks/authors\";\n\n// actions\nimport {\n useSubscribe,\n useBlock,\n useSaveComment,\n usePublishComment,\n usePublishVote,\n useCreateCommunity,\n usePublishCommentEdit,\n usePublishCommentModeration,\n usePublishCommunityEdit,\n useExportCommunity,\n} from \"./hooks/actions\";\n\n// actions that don't have their own hooks yet\nimport {\n createAccount,\n deleteAccount,\n deleteComment,\n setAccount,\n setActiveAccount,\n setAccountsOrder,\n importAccount,\n exportAccount,\n deleteCommunity,\n} from \"./stores/accounts/accounts-actions\";\n\n// states\nimport { useClientsStates, useCommunitiesStates } from \"./hooks/states\";\n\n// pkc-rpc\nimport { usePkcRpcSettings } from \"./hooks/pkc-rpc\";\n\n// chain\nimport {\n getEthWalletFromPkcPrivateKey,\n getEthPrivateKeyFromPkcPrivateKey,\n validateEthWallet,\n} from \"./lib/chain\";\n\n// utils\nimport { setPkcJs, restorePkcJs } from \"./lib/pkc-js\";\nimport { deleteDatabases, deleteCaches } from \"./lib/debug-utils\";\nimport { createCrosspost } from \"./lib/crosspost\";\nimport {\n getAvailablePostSortTypes,\n getAvailableReplySortTypes,\n getPreloadedPostSortType,\n getPreloadedReplySortType,\n resolvePostSortType,\n resolveReplySortType,\n} from \"./lib/page-sorts\";\n\n// types\nexport * from \"./types\";\n\n// IMPORTANT: should be the same as 'export default hooks'\nexport {\n // accounts\n useAccount,\n useAccounts,\n useAccountComment,\n useAccountComments,\n useAccountVotes,\n useAccountVote,\n useAccountEdits,\n useAccountCommunities,\n useNotifications,\n usePubsubSubscribe,\n // comments\n useComment,\n useComments,\n useCrosspost,\n useEditedComment,\n useValidateComment,\n // replies\n useReplies,\n // communities\n useCommunity,\n useCommunities,\n useCommunityStats,\n useListCommunities,\n useResolvedCommunityAddress,\n // authors\n useAuthor,\n useAuthorComments,\n useAuthorAvatar,\n useResolvedAuthorAddress,\n useAuthorAddress,\n setAuthorAvatarsWhitelistedTokenAddresses,\n resetAuthorAddressCacheForTesting,\n // feeds\n useFeed,\n useBufferedFeeds,\n // actions\n useSubscribe,\n useBlock,\n useSaveComment,\n usePublishComment,\n usePublishVote,\n usePublishCommentEdit,\n usePublishCommentModeration,\n usePublishCommunityEdit,\n useCreateCommunity,\n useExportCommunity,\n // actions that don't have their own hooks yet\n createAccount,\n deleteAccount,\n deleteComment,\n setAccount,\n setActiveAccount,\n setAccountsOrder,\n importAccount,\n exportAccount,\n deleteCommunity,\n // states\n useClientsStates,\n useCommunitiesStates,\n // pkc-rpc\n usePkcRpcSettings,\n // chain\n getEthWalletFromPkcPrivateKey,\n getEthPrivateKeyFromPkcPrivateKey,\n validateEthWallet,\n // utils\n setPkcJs,\n restorePkcJs,\n deleteDatabases,\n deleteCaches,\n createCrosspost,\n getAvailablePostSortTypes,\n getAvailableReplySortTypes,\n getPreloadedPostSortType,\n getPreloadedReplySortType,\n resolvePostSortType,\n resolveReplySortType,\n};\n\n// IMPORTANT: should be the same as 'export {}'\nconst hooks = {\n // accounts\n useAccount,\n useAccounts,\n useAccountComment,\n useAccountComments,\n useAccountVotes,\n useAccountVote,\n useAccountEdits,\n useAccountCommunities,\n useNotifications,\n usePubsubSubscribe,\n // comments\n useComment,\n useComments,\n useCrosspost,\n useEditedComment,\n useValidateComment,\n // replies\n useReplies,\n // communities\n useCommunity,\n useCommunities,\n useCommunityStats,\n useListCommunities,\n useResolvedCommunityAddress,\n // authors\n useAuthor,\n useAuthorComments,\n useAuthorAvatar,\n useResolvedAuthorAddress,\n useAuthorAddress,\n setAuthorAvatarsWhitelistedTokenAddresses,\n resetAuthorAddressCacheForTesting,\n // feeds\n useFeed,\n useBufferedFeeds,\n // actions\n useSubscribe,\n useBlock,\n useSaveComment,\n usePublishComment,\n usePublishVote,\n usePublishCommentEdit,\n usePublishCommentModeration,\n usePublishCommunityEdit,\n useCreateCommunity,\n useExportCommunity,\n // actions that don't have their own hooks yet\n createAccount,\n deleteAccount,\n deleteComment,\n setAccount,\n setActiveAccount,\n setAccountsOrder,\n importAccount,\n exportAccount,\n deleteCommunity,\n // states\n useClientsStates,\n useCommunitiesStates,\n // pkc-rpc\n usePkcRpcSettings,\n // chain\n getEthWalletFromPkcPrivateKey,\n getEthPrivateKeyFromPkcPrivateKey,\n validateEthWallet,\n // utils\n setPkcJs,\n restorePkcJs,\n deleteDatabases,\n deleteCaches,\n createCrosspost,\n getAvailablePostSortTypes,\n getAvailableReplySortTypes,\n getPreloadedPostSortType,\n getPreloadedReplySortType,\n resolvePostSortType,\n resolveReplySortType,\n};\n\nexport default hooks;\n"]}
@@ -16,6 +16,7 @@ export declare const getDefaultAccountFields: () => {
16
16
  subscriptions: never[];
17
17
  blockedAddresses: {};
18
18
  blockedCids: {};
19
+ savedComments: never[];
19
20
  communities: {};
20
21
  mediaIpfsGatewayUrl: string;
21
22
  };
@@ -27,6 +28,7 @@ declare const accountGenerator: {
27
28
  subscriptions: never[];
28
29
  blockedAddresses: {};
29
30
  blockedCids: {};
31
+ savedComments: never[];
30
32
  mediaIpfsGatewayUrl: string;
31
33
  id: string;
32
34
  version: number;
@@ -55,6 +57,7 @@ declare const accountGenerator: {
55
57
  subscriptions: never[];
56
58
  blockedAddresses: {};
57
59
  blockedCids: {};
60
+ savedComments: never[];
58
61
  communities: {};
59
62
  mediaIpfsGatewayUrl: string;
60
63
  };
@@ -1 +1 @@
1
- {"version":3,"file":"account-generator.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAY,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASzE,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AACzE,eAAO,MAAM,oBAAoB,UAOhC,CAAC;AACF,eAAO,MAAM,wBAAwB,UAOpC,CAAC;AAgBF,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAqBF,eAAO,MAAM,wBAAwB,QAQd,cACtB,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;CAwBhC,CAAC;AAMF,eAAO,MAAM,uBAAuB;;;;;;CAMlC,CAAC;AAsFH,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"account-generator.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAY,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASzE,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AACzE,eAAO,MAAM,oBAAoB,UAOhC,CAAC;AACF,eAAO,MAAM,wBAAwB,UAOpC,CAAC;AAgBF,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAqBF,eAAO,MAAM,wBAAwB,QAQd,cACtB,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;CAwBhC,CAAC;AAMF,eAAO,MAAM,uBAAuB;;;;;;;CAOlC,CAAC;AAsFH,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -100,6 +100,7 @@ export const getDefaultAccountFields = () => ({
100
100
  subscriptions: [],
101
101
  blockedAddresses: {},
102
102
  blockedCids: {},
103
+ savedComments: [],
103
104
  communities: {},
104
105
  mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,
105
106
  });
@@ -1 +1 @@
1
- {"version":3,"file":"account-generator.js","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,O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,QAAQ,GAAoB,MAAM,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACjF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,CAAA,EAAE,CAAC;QAC1B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,SAAS,CAAC,oCAAoC,CAAC,YAAY,CAAC,CAAC;IAE7D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC7C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,GAAG,kBAAkB,IAAI,aAAa,EAAE,CAAC;QAC7D,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACtC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,aAAa,EAAE,CAAC;IAClB,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,sBAAsB;IACtB,uBAAuB;IACvB,oBAAoB;CACrB,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import PkcJs from \"../../lib/pkc-js\";\nimport validator from \"../../lib/validator\";\nimport chain from \"../../lib/chain\";\nimport { v4 as uuid } from \"uuid\";\nimport accountsDatabase from \"./accounts-database\";\nimport { Accounts, AccountCommunity, ChainProviders } from \"../../types\";\nimport {\n getPkcClientOptions,\n normalizeAccountProtocolConfig,\n withProtocolAliases,\n} from \"../../lib/pkc-compat\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\n\nexport const DEFAULT_ETH_RPC_URL = \"https://ethereum-rpc.publicnode.com\";\nexport const DEFAULT_ETH_RPC_URLS = [\n DEFAULT_ETH_RPC_URL,\n \"https://eth.drpc.org\",\n \"https://ethereum.publicnode.com\",\n \"https://rpc.mevblocker.io\",\n \"https://1rpc.io/eth\",\n \"https://eth-pokt.nodies.app\",\n];\nexport const DEFAULT_HTTP_ROUTER_URLS = [\n \"https://peers.pleb.bot\",\n \"https://routing.lol\",\n \"https://peers.forumindex.com\",\n \"https://peers.plebpubsub.xyz\",\n \"https://routerofbitsocial.xyz\",\n \"https://bsotracker.online\",\n];\n\n// default chain providers\nconst chainProviders: ChainProviders = {\n eth: {\n // Use explicit RPCs for default name resolution; viem's default transport is opt-in.\n urls: [...DEFAULT_ETH_RPC_URLS, \"ethers.js\"],\n chainId: 1,\n },\n matic: {\n urls: [\"https://polygon-rpc.com\"],\n chainId: 137,\n },\n};\n\n// force using these options or can cause bugs\nexport const overwritePkcOptions = {\n resolveAuthorNames: false,\n resolveAuthorAddresses: false,\n validatePages: false,\n};\n\nconst aliasProtocolOptions = (options: Record<string, any>) => ({\n ...options,\n resolveAuthorNames: options.resolveAuthorNames ?? options.resolveAuthorAddresses ?? false,\n resolveAuthorAddresses: options.resolveAuthorAddresses ?? options.resolveAuthorNames ?? false,\n});\n\nconst addMissingChainProviders = (options: Record<string, any>) => {\n const optionsWithChainProviders = { ...options };\n if (!optionsWithChainProviders.chainProviders) {\n optionsWithChainProviders.chainProviders = {};\n }\n for (const chainTicker in chainProviders) {\n if (!optionsWithChainProviders.chainProviders[chainTicker]) {\n optionsWithChainProviders.chainProviders[chainTicker] = chainProviders[chainTicker];\n }\n }\n return optionsWithChainProviders;\n};\n\nexport const getDefaultChainProviders = () => {\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n const windowChainProviders = defaultWindowOptions?.chainProviders\n ? JSON.parse(JSON.stringify(defaultWindowOptions.chainProviders))\n : undefined;\n return addMissingChainProviders({\n chainProviders: windowChainProviders,\n }).chainProviders as ChainProviders;\n};\n\n// default options aren't saved to database so they can be changed\nexport const getDefaultPkcOptions = () => {\n // default PKC options defined by the electron process\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n if (defaultWindowOptions) {\n // @ts-ignore\n const defaultPkcOptions: any = JSON.parse(\n JSON.stringify({ ...defaultWindowOptions, libp2pJsClientsOptions: undefined }),\n );\n delete defaultPkcOptions.chainProviders;\n delete defaultPkcOptions.nameResolversChainProviders;\n // @ts-ignore\n defaultPkcOptions.libp2pJsClientsOptions = defaultWindowOptions.libp2pJsClientsOptions; // libp2pJsClientsOptions is not always just json\n return aliasProtocolOptions({ ...defaultPkcOptions, ...overwritePkcOptions });\n }\n // default PKC options for web client\n return aliasProtocolOptions({\n libp2pJsClientsOptions: [{ key: \"libp2pjs\" }],\n ipfsGatewayUrls: undefined,\n kuboRpcClientsOptions: undefined,\n pubsubKuboRpcClientsOptions: undefined,\n httpRoutersOptions: [...DEFAULT_HTTP_ROUTER_URLS],\n ...overwritePkcOptions,\n });\n};\n\n// the gateway to use in <img src> for nft avatars\n// @ts-ignore\nconst defaultMediaIpfsGatewayUrl = window.defaultMediaIpfsGatewayUrl || \"https://ipfs.io\";\n\nexport const getDefaultAccountFields = () => ({\n subscriptions: [],\n blockedAddresses: {},\n blockedCids: {},\n communities: {},\n mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,\n});\n\nconst generateDefaultAccount = async () => {\n const pkcOptions = getDefaultPkcOptions();\n const chainProviders = getDefaultChainProviders();\n const pkc = await PkcJs.PKC(\n getPkcClientOptions(\n {\n chainProviders,\n pkcOptions,\n },\n pkcOptions,\n ),\n );\n // handle errors or error events are uncaught\n // no need to log them because pkc-js already logs them\n pkc.on(\"error\", (error: any) =>\n log.error(\"uncaught pkc instance error, should never happen\", { error }),\n );\n\n const signer = await pkc.createSigner();\n const author = {\n address: signer.address,\n wallets: {\n eth: await chain.getEthWalletFromPkcPrivateKey(signer.privateKey, signer.address),\n },\n };\n\n const accountName = await getNextAvailableDefaultAccountName(author.address);\n\n // communities where the account has a role, like moderator, admin, owner, etc.\n const communities: { [communityAddress: string]: AccountCommunity } = {};\n\n const account = normalizeAccountProtocolConfig(\n withProtocolAliases(\n {\n id: uuid(),\n version: accountsDatabase.accountVersion,\n name: accountName,\n author,\n signer,\n chainProviders,\n pkcOptions,\n ...getDefaultAccountFields(),\n communities,\n },\n pkc,\n pkcOptions,\n ),\n chainProviders,\n );\n return account;\n};\n\nconst getNextAvailableDefaultAccountName = async (authorAddress: string) => {\n const shortAddress = PkcJs.PKC.getShortAddress?.({ address: authorAddress }) || authorAddress;\n const defaultAccountName = `Account ${shortAddress}`;\n const accountIds: string[] | null =\n await accountsDatabase.accountsMetadataDatabase.getItem(\"accountIds\");\n const accountNames = [];\n if (accountIds?.length) {\n const accounts: Accounts | null = await accountsDatabase.getAccounts(accountIds);\n for (const accountId of accountIds) {\n accountNames.push(accounts[accountId].name);\n }\n }\n if (!accountNames?.length) {\n return defaultAccountName;\n }\n validator.validateAccountsDatabaseAccountNames(accountNames);\n\n const accountNamesSet = new Set(accountNames);\n if (!accountNamesSet.has(defaultAccountName)) {\n return defaultAccountName;\n }\n\n let accountNumber = 2;\n while (true) {\n const accountName = `${defaultAccountName} ${accountNumber}`;\n if (!accountNamesSet.has(accountName)) {\n return accountName;\n }\n accountNumber++;\n }\n};\n\nconst accountGenerator = {\n generateDefaultAccount,\n getDefaultAccountFields,\n getDefaultPkcOptions,\n};\n\nexport default accountGenerator;\n"]}
1
+ {"version":3,"file":"account-generator.js","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,EAAE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CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACjF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,CAAA,EAAE,CAAC;QAC1B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,SAAS,CAAC,oCAAoC,CAAC,YAAY,CAAC,CAAC;IAE7D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC7C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,GAAG,kBAAkB,IAAI,aAAa,EAAE,CAAC;QAC7D,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACtC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,aAAa,EAAE,CAAC;IAClB,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,sBAAsB;IACtB,uBAAuB;IACvB,oBAAoB;CACrB,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import PkcJs from \"../../lib/pkc-js\";\nimport validator from \"../../lib/validator\";\nimport chain from \"../../lib/chain\";\nimport { v4 as uuid } from \"uuid\";\nimport accountsDatabase from \"./accounts-database\";\nimport { Accounts, AccountCommunity, ChainProviders } from \"../../types\";\nimport {\n getPkcClientOptions,\n normalizeAccountProtocolConfig,\n withProtocolAliases,\n} from \"../../lib/pkc-compat\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\n\nexport const DEFAULT_ETH_RPC_URL = \"https://ethereum-rpc.publicnode.com\";\nexport const DEFAULT_ETH_RPC_URLS = [\n DEFAULT_ETH_RPC_URL,\n \"https://eth.drpc.org\",\n \"https://ethereum.publicnode.com\",\n \"https://rpc.mevblocker.io\",\n \"https://1rpc.io/eth\",\n \"https://eth-pokt.nodies.app\",\n];\nexport const DEFAULT_HTTP_ROUTER_URLS = [\n \"https://peers.pleb.bot\",\n \"https://routing.lol\",\n \"https://peers.forumindex.com\",\n \"https://peers.plebpubsub.xyz\",\n \"https://routerofbitsocial.xyz\",\n \"https://bsotracker.online\",\n];\n\n// default chain providers\nconst chainProviders: ChainProviders = {\n eth: {\n // Use explicit RPCs for default name resolution; viem's default transport is opt-in.\n urls: [...DEFAULT_ETH_RPC_URLS, \"ethers.js\"],\n chainId: 1,\n },\n matic: {\n urls: [\"https://polygon-rpc.com\"],\n chainId: 137,\n },\n};\n\n// force using these options or can cause bugs\nexport const overwritePkcOptions = {\n resolveAuthorNames: false,\n resolveAuthorAddresses: false,\n validatePages: false,\n};\n\nconst aliasProtocolOptions = (options: Record<string, any>) => ({\n ...options,\n resolveAuthorNames: options.resolveAuthorNames ?? options.resolveAuthorAddresses ?? false,\n resolveAuthorAddresses: options.resolveAuthorAddresses ?? options.resolveAuthorNames ?? false,\n});\n\nconst addMissingChainProviders = (options: Record<string, any>) => {\n const optionsWithChainProviders = { ...options };\n if (!optionsWithChainProviders.chainProviders) {\n optionsWithChainProviders.chainProviders = {};\n }\n for (const chainTicker in chainProviders) {\n if (!optionsWithChainProviders.chainProviders[chainTicker]) {\n optionsWithChainProviders.chainProviders[chainTicker] = chainProviders[chainTicker];\n }\n }\n return optionsWithChainProviders;\n};\n\nexport const getDefaultChainProviders = () => {\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n const windowChainProviders = defaultWindowOptions?.chainProviders\n ? JSON.parse(JSON.stringify(defaultWindowOptions.chainProviders))\n : undefined;\n return addMissingChainProviders({\n chainProviders: windowChainProviders,\n }).chainProviders as ChainProviders;\n};\n\n// default options aren't saved to database so they can be changed\nexport const getDefaultPkcOptions = () => {\n // default PKC options defined by the electron process\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n if (defaultWindowOptions) {\n // @ts-ignore\n const defaultPkcOptions: any = JSON.parse(\n JSON.stringify({ ...defaultWindowOptions, libp2pJsClientsOptions: undefined }),\n );\n delete defaultPkcOptions.chainProviders;\n delete defaultPkcOptions.nameResolversChainProviders;\n // @ts-ignore\n defaultPkcOptions.libp2pJsClientsOptions = defaultWindowOptions.libp2pJsClientsOptions; // libp2pJsClientsOptions is not always just json\n return aliasProtocolOptions({ ...defaultPkcOptions, ...overwritePkcOptions });\n }\n // default PKC options for web client\n return aliasProtocolOptions({\n libp2pJsClientsOptions: [{ key: \"libp2pjs\" }],\n ipfsGatewayUrls: undefined,\n kuboRpcClientsOptions: undefined,\n pubsubKuboRpcClientsOptions: undefined,\n httpRoutersOptions: [...DEFAULT_HTTP_ROUTER_URLS],\n ...overwritePkcOptions,\n });\n};\n\n// the gateway to use in <img src> for nft avatars\n// @ts-ignore\nconst defaultMediaIpfsGatewayUrl = window.defaultMediaIpfsGatewayUrl || \"https://ipfs.io\";\n\nexport const getDefaultAccountFields = () => ({\n subscriptions: [],\n blockedAddresses: {},\n blockedCids: {},\n savedComments: [],\n communities: {},\n mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,\n});\n\nconst generateDefaultAccount = async () => {\n const pkcOptions = getDefaultPkcOptions();\n const chainProviders = getDefaultChainProviders();\n const pkc = await PkcJs.PKC(\n getPkcClientOptions(\n {\n chainProviders,\n pkcOptions,\n },\n pkcOptions,\n ),\n );\n // handle errors or error events are uncaught\n // no need to log them because pkc-js already logs them\n pkc.on(\"error\", (error: any) =>\n log.error(\"uncaught pkc instance error, should never happen\", { error }),\n );\n\n const signer = await pkc.createSigner();\n const author = {\n address: signer.address,\n wallets: {\n eth: await chain.getEthWalletFromPkcPrivateKey(signer.privateKey, signer.address),\n },\n };\n\n const accountName = await getNextAvailableDefaultAccountName(author.address);\n\n // communities where the account has a role, like moderator, admin, owner, etc.\n const communities: { [communityAddress: string]: AccountCommunity } = {};\n\n const account = normalizeAccountProtocolConfig(\n withProtocolAliases(\n {\n id: uuid(),\n version: accountsDatabase.accountVersion,\n name: accountName,\n author,\n signer,\n chainProviders,\n pkcOptions,\n ...getDefaultAccountFields(),\n communities,\n },\n pkc,\n pkcOptions,\n ),\n chainProviders,\n );\n return account;\n};\n\nconst getNextAvailableDefaultAccountName = async (authorAddress: string) => {\n const shortAddress = PkcJs.PKC.getShortAddress?.({ address: authorAddress }) || authorAddress;\n const defaultAccountName = `Account ${shortAddress}`;\n const accountIds: string[] | null =\n await accountsDatabase.accountsMetadataDatabase.getItem(\"accountIds\");\n const accountNames = [];\n if (accountIds?.length) {\n const accounts: Accounts | null = await accountsDatabase.getAccounts(accountIds);\n for (const accountId of accountIds) {\n accountNames.push(accounts[accountId].name);\n }\n }\n if (!accountNames?.length) {\n return defaultAccountName;\n }\n validator.validateAccountsDatabaseAccountNames(accountNames);\n\n const accountNamesSet = new Set(accountNames);\n if (!accountNamesSet.has(defaultAccountName)) {\n return defaultAccountName;\n }\n\n let accountNumber = 2;\n while (true) {\n const accountName = `${defaultAccountName} ${accountNumber}`;\n if (!accountNamesSet.has(accountName)) {\n return accountName;\n }\n accountNumber++;\n }\n};\n\nconst accountGenerator = {\n generateDefaultAccount,\n getDefaultAccountFields,\n getDefaultPkcOptions,\n};\n\nexport default accountGenerator;\n"]}
@@ -36,6 +36,8 @@ export declare const blockAddress: (address: string, accountName?: string) => Pr
36
36
  export declare const unblockAddress: (address: string, accountName?: string) => Promise<void>;
37
37
  export declare const blockCid: (cid: string, accountName?: string) => Promise<void>;
38
38
  export declare const unblockCid: (cid: string, accountName?: string) => Promise<void>;
39
+ export declare const saveComment: (commentCid: string, accountName?: string) => Promise<void>;
40
+ export declare const unsaveComment: (commentCid: string, accountName?: string) => Promise<void>;
39
41
  export declare const publishComment: (publishCommentOptions: PublishCommentOptions, accountName?: string) => Promise<any>;
40
42
  export declare const deleteComment: (commentCidOrAccountCommentIndex: string | number, accountName?: string) => Promise<void>;
41
43
  export declare const publishVote: (publishVoteOptions: PublishVoteOptions, accountName?: string) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-actions.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/accounts-actions.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,OAAO,EAEP,qBAAqB,EAGrB,kBAAkB,EAClB,yBAAyB,EACzB,+BAA+B,EAC/B,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EAGhB,MAAM,aAAa,CAAC;AAmPrB,sGAAsG;AACtG,eAAO,MAAM,yBAAyB,GACpC,kBAAkB,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EACvC,WAAW,MAAM,EACjB,OAAO,MAAM,EACb,SAAS,CAAC,eAAe,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,GAAG,KAAK,IAAI;;;;;;CAO/D,CAAC;AA2BF,eAAO,MAAM,0BAA0B,GAAI,mBAAmB,GAAG,EAAE,yBAAyB,GAAG,YAGtC,CAAC;AAE1D,eAAO,MAAM,yBAAyB,GAAI,mBAAmB,GAAG,QAK/D,CAAC;AAuCF,eAAO,MAAM,kCAAkC,GAC7C,wBAAwB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC3D,WAAW,MAAM,EACjB,mBAAmB,GAAG;;CAsCvB,CAAC;AAEF,eAAO,MAAM,uCAAuC,GAClD,wBAAwB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC3D,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EACpD,WAAW,MAAM,EACjB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AO,MAAM,WAAW,GAAU,oBAAoB,kBAAkB,EAAE,cAAc,MAAM,kBAmG7F,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,2BAA2B,yBAAyB,EACpD,cAAc,MAAM,kBA4IrB,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,iCAAiC,+BAA+B,EAChE,cAAc,MAAM,kBAyJrB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,kBAAkB,MAAM,EACxB,6BAA6B,2BAA2B,EACxD,cAAc,MAAM,kBAmKrB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,wBAAwB,sBAAsB,EAC9C,cAAc,MAAM,iBAkBrB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,kBAAkB,MAAM,EAAE,cAAc,MAAM,kBAcnF,CAAC"}
@@ -782,8 +782,64 @@ export const unblockCid = (cid, accountName) => __awaiter(void 0, void 0, void 0
782
782
  log("accountsActions.unblockCid", { account: updatedAccount, accountName, cid });
783
783
  accountsStore.setState({ accounts: updatedAccounts });
784
784
  });
785
+ const savedCommentMutationQueues = new Map();
786
+ const updateSavedComments = (commentCid, accountName, shouldSave) => __awaiter(void 0, void 0, void 0, function* () {
787
+ var _a, _b;
788
+ const { accounts, accountNamesToAccountIds, activeAccountId } = accountsStore.getState();
789
+ assert(commentCid && typeof commentCid === "string", `accountsActions.${shouldSave ? "saveComment" : "unsaveComment"} invalid commentCid '${commentCid}'`);
790
+ assert(accounts && accountNamesToAccountIds && activeAccountId, `can't use accountsStore.accountActions before initialized`);
791
+ const accountId = accountName ? accountNamesToAccountIds[accountName] : activeAccountId;
792
+ assert((_a = accounts[accountId]) === null || _a === void 0 ? void 0 : _a.id, `accountsActions.${shouldSave ? "saveComment" : "unsaveComment"} account.id '${(_b = accounts[accountId]) === null || _b === void 0 ? void 0 : _b.id}' doesn't exist, activeAccountId '${activeAccountId}' accountName '${accountName}'`);
793
+ const previousMutation = savedCommentMutationQueues.get(accountId) || Promise.resolve();
794
+ const mutation = previousMutation
795
+ .catch(() => { })
796
+ .then(() => __awaiter(void 0, void 0, void 0, function* () {
797
+ const currentAccounts = accountsStore.getState().accounts;
798
+ const account = currentAccounts[accountId];
799
+ assert(account === null || account === void 0 ? void 0 : account.id, `accountsActions.${shouldSave ? "saveComment" : "unsaveComment"} account.id '${account === null || account === void 0 ? void 0 : account.id}' doesn't exist, activeAccountId '${activeAccountId}' accountName '${accountName}'`);
800
+ const isSaved = account.savedComments.includes(commentCid);
801
+ if (shouldSave && isSaved) {
802
+ throw Error(`account '${account.id}' already saved comment '${commentCid}'`);
803
+ }
804
+ if (!shouldSave && !isSaved) {
805
+ throw Error(`account '${account.id}' already unsaved comment '${commentCid}'`);
806
+ }
807
+ const savedComments = shouldSave
808
+ ? [commentCid, ...account.savedComments]
809
+ : account.savedComments.filter((savedCommentCid) => savedCommentCid !== commentCid);
810
+ const updatedAccount = Object.assign(Object.assign({}, account), { savedComments });
811
+ yield accountsDatabase.addAccount(updatedAccount);
812
+ const latestAccounts = accountsStore.getState().accounts;
813
+ const latestAccount = latestAccounts[accountId];
814
+ assert(latestAccount === null || latestAccount === void 0 ? void 0 : latestAccount.id, `account '${accountId}' was removed while updating saved comments`);
815
+ const mergedAccount = Object.assign(Object.assign({}, latestAccount), { savedComments });
816
+ const updatedAccounts = Object.assign(Object.assign({}, latestAccounts), { [accountId]: mergedAccount });
817
+ const actionName = shouldSave ? "saveComment" : "unsaveComment";
818
+ log(`accountsActions.${actionName}`, {
819
+ accountId,
820
+ accountName,
821
+ commentCid,
822
+ });
823
+ accountsStore.setState({ accounts: updatedAccounts });
824
+ }));
825
+ savedCommentMutationQueues.set(accountId, mutation);
826
+ try {
827
+ yield mutation;
828
+ }
829
+ finally {
830
+ if (savedCommentMutationQueues.get(accountId) === mutation) {
831
+ savedCommentMutationQueues.delete(accountId);
832
+ }
833
+ }
834
+ });
835
+ export const saveComment = (commentCid, accountName) => __awaiter(void 0, void 0, void 0, function* () {
836
+ yield updateSavedComments(commentCid, accountName, true);
837
+ });
838
+ export const unsaveComment = (commentCid, accountName) => __awaiter(void 0, void 0, void 0, function* () {
839
+ yield updateSavedComments(commentCid, accountName, false);
840
+ });
785
841
  export const publishComment = (publishCommentOptions, accountName) => __awaiter(void 0, void 0, void 0, function* () {
786
- var _a, _b, _c;
842
+ var _a, _b, _c, _d, _e;
787
843
  const { accounts, accountsComments, accountNamesToAccountIds, activeAccountId } = accountsStore.getState();
788
844
  assert(accounts && accountNamesToAccountIds && activeAccountId, `can't use accountsStore.accountActions before initialized`);
789
845
  let account = accounts[activeAccountId];
@@ -806,7 +862,12 @@ export const publishComment = (publishCommentOptions, accountName) => __awaiter(
806
862
  if (previousCommentCid) {
807
863
  author.previousCommentCid = previousCommentCid;
808
864
  }
809
- let createCommentOptions = normalizePublicationOptionsForPkc(account.pkc, Object.assign({ timestamp: Math.floor(Date.now() / 1000), author, signer: account.signer }, publishCommentOptions));
865
+ const publicationAuthor = Object.assign(Object.assign({}, author), publishCommentOptions.author);
866
+ if (publicationAuthor.address !== ((_b = account.author) === null || _b === void 0 ? void 0 : _b.address) &&
867
+ ((_c = publishCommentOptions.author) === null || _c === void 0 ? void 0 : _c.previousCommentCid) === undefined) {
868
+ delete publicationAuthor.previousCommentCid;
869
+ }
870
+ let createCommentOptions = normalizePublicationOptionsForPkc(account.pkc, Object.assign(Object.assign({ timestamp: Math.floor(Date.now() / 1000), signer: account.signer }, publishCommentOptions), { author: publicationAuthor }));
810
871
  delete createCommentOptions.onChallenge;
811
872
  delete createCommentOptions.onChallengeVerification;
812
873
  delete createCommentOptions.onError;
@@ -822,7 +883,7 @@ export const publishComment = (publishCommentOptions, accountName) => __awaiter(
822
883
  // set fetching link dimensions state
823
884
  let fetchingLinkDimensionsStates;
824
885
  if (publishCommentOptions.link) {
825
- (_b = publishCommentOptions.onPublishingStateChange) === null || _b === void 0 ? void 0 : _b.call(publishCommentOptions, "fetching-link-dimensions");
886
+ (_d = publishCommentOptions.onPublishingStateChange) === null || _d === void 0 ? void 0 : _d.call(publishCommentOptions, "fetching-link-dimensions");
826
887
  fetchingLinkDimensionsStates = {
827
888
  state: "publishing",
828
889
  publishingState: "fetching-link-dimensions",
@@ -894,7 +955,7 @@ export const publishComment = (publishCommentOptions, accountName) => __awaiter(
894
955
  if (pendingCommentIndex !== accountCommentIndex) {
895
956
  notifyPendingComment(pendingCommentIndex, createdAccountComment);
896
957
  }
897
- (_c = publishCommentOptions._onPendingCommentIndex) === null || _c === void 0 ? void 0 : _c.call(publishCommentOptions, pendingCommentIndex, createdAccountComment);
958
+ (_e = publishCommentOptions._onPendingCommentIndex) === null || _e === void 0 ? void 0 : _e.call(publishCommentOptions, pendingCommentIndex, createdAccountComment);
898
959
  let comment;
899
960
  (() => __awaiter(void 0, void 0, void 0, function* () {
900
961
  // fetch comment.link dimensions