@bitsocial/bitsocial-react-hooks 0.1.53 → 0.1.55
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.
- package/CHANGELOG.md +23 -0
- package/dist/hooks/accounts/accounts.js +2 -2
- package/dist/hooks/accounts/accounts.js.map +1 -1
- package/dist/hooks/accounts/utils.d.ts.map +1 -1
- package/dist/hooks/accounts/utils.js +3 -12
- package/dist/hooks/accounts/utils.js.map +1 -1
- package/dist/hooks/actions/actions.js +1 -1
- package/dist/hooks/actions/actions.js.map +1 -1
- package/dist/hooks/authors/author-avatars.js +1 -1
- package/dist/hooks/authors/author-avatars.js.map +1 -1
- package/dist/hooks/authors/authors.js +1 -1
- package/dist/hooks/authors/authors.js.map +1 -1
- package/dist/hooks/authors/utils.d.ts.map +1 -1
- package/dist/hooks/authors/utils.js +1 -13
- package/dist/hooks/authors/utils.js.map +1 -1
- package/dist/hooks/comments.d.ts +7 -1
- package/dist/hooks/comments.d.ts.map +1 -1
- package/dist/hooks/comments.js +31 -1
- package/dist/hooks/comments.js.map +1 -1
- package/dist/hooks/communities.js +1 -1
- package/dist/hooks/communities.js.map +1 -1
- package/dist/hooks/feeds/feeds.js +1 -1
- package/dist/hooks/feeds/feeds.js.map +1 -1
- package/dist/hooks/pkc-rpc.js +1 -1
- package/dist/hooks/pkc-rpc.js.map +1 -1
- package/dist/hooks/replies.js +1 -1
- package/dist/hooks/replies.js.map +1 -1
- package/dist/hooks/states.js +1 -1
- package/dist/hooks/states.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/assert.d.ts +6 -0
- package/dist/lib/assert.d.ts.map +1 -0
- package/dist/lib/assert.js +17 -0
- package/dist/lib/assert.js.map +1 -0
- package/dist/lib/chain/chain.js +1 -1
- package/dist/lib/chain/chain.js.map +1 -1
- package/dist/lib/community-ref.js +1 -1
- package/dist/lib/community-ref.js.map +1 -1
- package/dist/lib/crosspost.js +1 -1
- package/dist/lib/crosspost.js.map +1 -1
- package/dist/lib/is-equal.d.ts +6 -0
- package/dist/lib/is-equal.d.ts.map +1 -0
- package/dist/lib/is-equal.js +100 -0
- package/dist/lib/is-equal.js.map +1 -0
- package/dist/lib/memoize.d.ts +9 -0
- package/dist/lib/memoize.d.ts.map +1 -0
- package/dist/lib/memoize.js +24 -0
- package/dist/lib/memoize.js.map +1 -0
- package/dist/lib/pkc-address.d.ts +2 -0
- package/dist/lib/pkc-address.d.ts.map +1 -0
- package/dist/lib/pkc-address.js +16 -0
- package/dist/lib/pkc-address.js.map +1 -0
- package/dist/lib/pkc-compat.js +1 -1
- package/dist/lib/pkc-compat.js.map +1 -1
- package/dist/lib/pkc-js/index.d.ts.map +1 -1
- package/dist/lib/pkc-js/index.js +23 -12
- package/dist/lib/pkc-js/index.js.map +1 -1
- package/dist/lib/pkc-js/pkc-js-mock-content.js +1 -1
- package/dist/lib/pkc-js/pkc-js-mock-content.js.map +1 -1
- package/dist/lib/protocol-compat.js +1 -1
- package/dist/lib/protocol-compat.js.map +1 -1
- package/dist/lib/utils/utils.js +1 -1
- package/dist/lib/utils/utils.js.map +1 -1
- package/dist/lib/validate-comment.d.ts +11 -0
- package/dist/lib/validate-comment.d.ts.map +1 -0
- package/dist/lib/validate-comment.js +133 -0
- package/dist/lib/validate-comment.js.map +1 -0
- package/dist/lib/validator.js +1 -1
- package/dist/lib/validator.js.map +1 -1
- package/dist/stores/accounts/accounts-actions-internal.js +2 -2
- package/dist/stores/accounts/accounts-actions-internal.js.map +1 -1
- package/dist/stores/accounts/accounts-actions.js +2 -2
- package/dist/stores/accounts/accounts-actions.js.map +1 -1
- package/dist/stores/accounts/accounts-database.js +2 -2
- package/dist/stores/accounts/accounts-database.js.map +1 -1
- package/dist/stores/accounts/accounts-store.js +1 -1
- package/dist/stores/accounts/accounts-store.js.map +1 -1
- package/dist/stores/accounts/utils.js +1 -1
- package/dist/stores/accounts/utils.js.map +1 -1
- package/dist/stores/authors-comments/authors-comments-store.js +1 -1
- package/dist/stores/authors-comments/authors-comments-store.js.map +1 -1
- package/dist/stores/authors-comments/utils.js.map +1 -1
- package/dist/stores/communities/communities-store.d.ts.map +1 -1
- package/dist/stores/communities/communities-store.js +53 -11
- package/dist/stores/communities/communities-store.js.map +1 -1
- package/dist/stores/communities-pages/communities-pages-store.js +1 -1
- package/dist/stores/communities-pages/communities-pages-store.js.map +1 -1
- package/dist/stores/feeds/feeds-store.js +1 -1
- package/dist/stores/feeds/feeds-store.js.map +1 -1
- package/dist/stores/feeds/utils.js.map +1 -1
- package/dist/stores/replies/replies-store.js +1 -1
- package/dist/stores/replies/replies-store.js.map +1 -1
- package/dist/stores/replies/utils.js.map +1 -1
- package/dist/stores/replies-pages/replies-pages-store.js +1 -1
- package/dist/stores/replies-pages/replies-pages-store.js.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/stores/accounts/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAaA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAC5D,OAAO,aAAa,MAAM,aAAa,CAAC;AACxC,OAAO,iBAAiB,MAAM,kBAAkB,CAAC;AACjD,OAAO,qBAAqB,MAAM,sBAAsB,CAAC;AACzD,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAErF,MAAM,oCAAoC,GAAG,CAAC,aAAqB,EAAE,WAAwB,EAAE,EAAE;;IAC/F,MAAM,KA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BAAqB,GAAG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC;YACxD,OAAO,EAAE,OAAO,CAAC,gBAAgB;SAClC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;IACd,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,qBAAQ,OAAO,CAAC,MAAM,CAAE,CAAC;QACvC,OAAO,CAAC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC;YACtD,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;SAChC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;IACd,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG;IACZ,qBAAqB;IACrB,gCAAgC;IAChC,uBAAuB;IACvB,0BAA0B;IAC1B,8BAA8B;IAC9B,4BAA4B;IAC5B,6BAA6B;IAC7B,uBAAuB;IACvB,0BAA0B;IAC1B,8BAA8B;IAC9B,sBAAsB;IACtB,wBAAwB;IACxB,iCAAiC;IACjC,UAAU;CACX,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import {\n Account,\n Role,\n Communities,\n AccountComment,\n AccountsComments,\n AccountsCommentsIndexes,\n AccountCommentsIndex,\n CommentCidsToAccountsComments,\n Comment,\n AccountEdit,\n AccountEditsSummary,\n} from \"../../types\";\nimport assert from \"assert\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\nimport commentsStore from \"../comments\";\nimport repliesPagesStore from \"../replies-pages\";\nimport communitiesPagesStore from \"../communities-pages\";\nimport repliesCommentsStore from \"../replies/replies-comments-store\";\nimport PkcJs from \"../../lib/pkc-js\";\nimport { getCommentVoteCountsVersion } from \"../../lib/utils/optimistic-vote-counts\";\n\nconst getAuthorAddressRolesFromCommunities = (authorAddress: string, communities: Communities) => {\n const roles: { [communityAddress: string]: Role } = {};\n for (const communityAddress in communities) {\n const role = communities[communityAddress]?.roles?.[authorAddress];\n if (role) {\n roles[communityAddress] = role;\n }\n }\n return roles;\n};\n\nexport const getAccountCommunities = (account: Account, communities: Communities) => {\n assert(\n account?.author?.address && typeof account?.author?.address === \"string\",\n `accountsStore utils getAccountCommunities invalid account.author.address '${account?.author?.address}'`,\n );\n assert(\n communities && typeof communities === \"object\",\n `accountsStore utils getAccountCommunities invalid communities '${communities}'`,\n );\n\n const roles = getAuthorAddressRolesFromCommunities(account.author.address, communities);\n const accountCommunities = { ...account.communities };\n for (const communityAddress in roles) {\n accountCommunities[communityAddress] = { ...accountCommunities[communityAddress] };\n accountCommunities[communityAddress].role = roles[communityAddress];\n }\n return accountCommunities;\n};\n\nexport const getCommentCidsToAccountsComments = (accountsComments: AccountsComments) => {\n const commentCidsToAccountsComments: CommentCidsToAccountsComments = {};\n for (const accountId in accountsComments) {\n for (const accountComment of accountsComments[accountId]) {\n if (accountComment.cid) {\n commentCidsToAccountsComments[accountComment.cid] = {\n accountId,\n accountCommentIndex: accountComment.index,\n };\n }\n }\n }\n return commentCidsToAccountsComments;\n};\n\nconst cloneWithoutFunctions = (value: any): any => {\n if (Array.isArray(value)) {\n return value\n .map((entry) => cloneWithoutFunctions(entry))\n .filter((entry) => entry !== undefined);\n }\n if (!value || typeof value !== \"object\") {\n return typeof value === \"function\" ? undefined : value;\n }\n\n const clonedValue: Record<string, any> = {};\n for (const key in value) {\n if (typeof value[key] === \"function\") {\n continue;\n }\n const clonedChild = cloneWithoutFunctions(value[key]);\n if (clonedChild !== undefined) {\n clonedValue[key] = clonedChild;\n }\n }\n return clonedValue;\n};\n\nconst compactStoredCommentAuthor = (author: any) => {\n if (!author || typeof author !== \"object\") {\n return undefined;\n }\n\n const compactAuthor = cloneWithoutFunctions({\n address: author.address,\n shortAddress: author.shortAddress,\n displayName: author.displayName,\n avatar: author.avatar,\n flair: author.flair,\n });\n\n return compactAuthor && Object.keys(compactAuthor).length > 0 ? compactAuthor : undefined;\n};\n\nconst compactStoredOriginalComment = (originalComment: any) => {\n if (!originalComment || typeof originalComment !== \"object\") {\n return undefined;\n }\n\n const compactOriginalComment = cloneWithoutFunctions({\n cid: originalComment.cid,\n content: originalComment.content,\n title: originalComment.title,\n link: originalComment.link,\n linkWidth: originalComment.linkWidth,\n linkHeight: originalComment.linkHeight,\n linkHtmlTagName: originalComment.linkHtmlTagName,\n thumbnailUrl: originalComment.thumbnailUrl,\n media: originalComment.media,\n spoiler: originalComment.spoiler,\n nsfw: originalComment.nsfw,\n deleted: originalComment.deleted,\n removed: originalComment.removed,\n reason: originalComment.reason,\n quotedCids: originalComment.quotedCids,\n parentCid: originalComment.parentCid,\n postCid: originalComment.postCid,\n communityAddress: originalComment.communityAddress,\n timestamp: originalComment.timestamp,\n author: compactStoredCommentAuthor(originalComment.author),\n });\n\n return compactOriginalComment && Object.keys(compactOriginalComment).length > 0\n ? compactOriginalComment\n : undefined;\n};\n\nconst compactStoredReplies = (replies: any) => {\n if (!replies || typeof replies !== \"object\") {\n return undefined;\n }\n\n const compactReplies = cloneWithoutFunctions(\n Object.fromEntries(\n Object.entries(replies).filter(\n ([replyKey]) => replyKey !== \"pages\" && replyKey !== \"clients\",\n ),\n ),\n );\n\n return compactReplies && Object.keys(compactReplies).length > 0 ? compactReplies : undefined;\n};\n\nexport const sanitizeAccountCommentForState = (comment: Comment) => {\n const sanitizedComment = cloneWithoutFunctions({\n ...comment,\n signer: undefined,\n raw: undefined,\n replies: comment?.replies\n ? Object.fromEntries(\n Object.entries(comment.replies).filter(([replyKey]) => replyKey !== \"pages\"),\n )\n : comment?.replies,\n });\n\n if (!sanitizedComment || typeof sanitizedComment !== \"object\") {\n return sanitizedComment;\n }\n if (sanitizedComment?.replies?.pages) {\n sanitizedComment.replies = { ...sanitizedComment.replies };\n delete sanitizedComment.replies.pages;\n }\n if (sanitizedComment?.replies && Object.keys(sanitizedComment.replies).length === 0) {\n delete sanitizedComment.replies;\n }\n return sanitizedComment;\n};\n\nexport const sanitizeStoredAccountComment = (comment: Comment) => {\n const preprocessedComment = {\n ...comment,\n signer: undefined,\n clients: undefined,\n raw: undefined,\n replies: compactStoredReplies(comment?.replies),\n original: comment?.edit ? compactStoredOriginalComment(comment.original) : undefined,\n };\n const sanitizedComment = cloneWithoutFunctions(preprocessedComment);\n if (!sanitizedComment || typeof sanitizedComment !== \"object\") {\n return sanitizedComment;\n }\n if (sanitizedComment?.replies && Object.keys(sanitizedComment.replies).length === 0) {\n delete sanitizedComment.replies;\n }\n if (sanitizedComment?.original && Object.keys(sanitizedComment.original).length === 0) {\n delete sanitizedComment.original;\n }\n return sanitizedComment;\n};\n\nexport const getAccountCommentsIndex = (\n accountComments: AccountComment[] | undefined,\n): AccountCommentsIndex => {\n const index: AccountCommentsIndex = {\n byCommunityAddress: {},\n byParentCid: {},\n };\n for (const accountComment of accountComments || []) {\n if (accountComment.communityAddress) {\n if (!index.byCommunityAddress[accountComment.communityAddress]) {\n index.byCommunityAddress[accountComment.communityAddress] = [];\n }\n index.byCommunityAddress[accountComment.communityAddress].push(accountComment.index);\n }\n if (accountComment.parentCid) {\n if (!index.byParentCid[accountComment.parentCid]) {\n index.byParentCid[accountComment.parentCid] = [];\n }\n index.byParentCid[accountComment.parentCid].push(accountComment.index);\n }\n }\n return index;\n};\n\nexport const getAccountsCommentsIndexes = (accountsComments: AccountsComments) => {\n const indexes: AccountsCommentsIndexes = {};\n for (const accountId in accountsComments) {\n indexes[accountId] = getAccountCommentsIndex(accountsComments[accountId]);\n }\n return indexes;\n};\n\nconst accountEditNonPropertyNames = new Set([\n \"author\",\n \"signer\",\n \"clientId\",\n \"commentCid\",\n \"communityAddress\",\n \"communityAddress\",\n \"timestamp\",\n]);\n\nexport const COMMENT_MODERATION_AUTHOR_SUMMARY_KEY = \"commentModeration.author\";\n\nconst normalizeAccountEditForSummary = (accountEdit: AccountEdit) => {\n const normalizedAccountEdit = { ...accountEdit };\n const commentModeration = normalizedAccountEdit.commentModeration;\n if (commentModeration && typeof commentModeration === \"object\") {\n const { author, ...commentModerationProperties } = commentModeration;\n Object.assign(normalizedAccountEdit, commentModerationProperties);\n if (Object.prototype.hasOwnProperty.call(commentModeration, \"author\")) {\n normalizedAccountEdit[COMMENT_MODERATION_AUTHOR_SUMMARY_KEY] = author;\n }\n delete normalizedAccountEdit.commentModeration;\n }\n const communityEdit = normalizedAccountEdit.communityEdit ?? normalizedAccountEdit.communityEdit;\n if (communityEdit && typeof communityEdit === \"object\") {\n Object.assign(normalizedAccountEdit, communityEdit);\n }\n delete normalizedAccountEdit.communityEdit;\n delete normalizedAccountEdit.communityEdit;\n return normalizedAccountEdit;\n};\n\nexport const getAccountEditPropertySummary = (accountEdits: AccountEdit[] | undefined) => {\n const accountEditPropertySummary: AccountEditsSummary[string] = {};\n for (const accountEdit of accountEdits || []) {\n const normalizedAccountEdit = normalizeAccountEditForSummary(accountEdit);\n for (const propertyName in normalizedAccountEdit) {\n if (\n (normalizedAccountEdit[propertyName] === undefined &&\n propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) ||\n accountEditNonPropertyNames.has(propertyName)\n ) {\n continue;\n }\n const previousTimestamp = accountEditPropertySummary[propertyName]?.timestamp || 0;\n if ((normalizedAccountEdit.timestamp || 0) >= previousTimestamp) {\n accountEditPropertySummary[propertyName] = {\n timestamp: normalizedAccountEdit.timestamp,\n value: normalizedAccountEdit[propertyName],\n };\n }\n }\n }\n return accountEditPropertySummary;\n};\n\nexport const getAccountsEditsSummary = (accountEdits: {\n [commentCidOrCommunityAddress: string]: AccountEdit[];\n}) => {\n const summary: AccountEditsSummary = {};\n for (const target in accountEdits || {}) {\n summary[target] = getAccountEditPropertySummary(accountEdits[target]);\n }\n return summary;\n};\n\ninterface CommentLinkDimensions {\n linkWidth?: number;\n linkHeight?: number;\n linkHtmlTagName?: \"img\" | \"video\" | \"audio\";\n}\n\n// polyfill Promise.any, exported for test coverage of empty-array branch\nconst promiseAny = <T>(promises: Promise<T>[]): Promise<T> =>\n new Promise((res, rej) => {\n let count = promises.length;\n if (count === 0) return rej(Error(\"all promises rejected\"));\n promises.forEach((p) =>\n Promise.resolve(p)\n .then(res)\n .catch((e) => {\n if (--count === 0) rej(Error(\"all promises rejected\"));\n }),\n );\n });\n\nexport const fetchCommentLinkDimensions = async (link: string): Promise<CommentLinkDimensions> => {\n if (!link) {\n return {};\n }\n\n const fetchImageDimensions = (url: string) =>\n new Promise<CommentLinkDimensions>((resolve, reject) => {\n const image = new Image();\n image.onload = () => {\n // don't accept 0px value\n if (!image.width || !image.height) {\n return reject(Error(`failed fetching image dimensions for url '${url}'`));\n }\n resolve({\n linkWidth: image.width,\n linkHeight: image.height,\n linkHtmlTagName: \"img\",\n });\n\n // remove image from memory\n try {\n image.src = \"\";\n } catch (e) {}\n };\n image.onerror = (error) => {\n reject(Error(`failed fetching image dimensions for url '${url}'`));\n };\n\n // max loading time\n const timeout = 10000;\n setTimeout(\n () =>\n reject(Error(`failed fetching image dimensions for url '${url}' timeout '${timeout}'`)),\n timeout,\n );\n\n // start loading\n image.src = url;\n });\n\n const fetchVideoDimensions = (url: string) =>\n new Promise<CommentLinkDimensions>((resolve, reject) => {\n const video = document.createElement(\"video\");\n video.muted = true;\n video.loop = false;\n video.addEventListener(\"loadeddata\", () => {\n // don't accept 0px value\n if (!video.videoWidth || !video.videoHeight) {\n return reject(Error(`failed fetching video dimensions for url '${url}'`));\n }\n resolve({\n linkWidth: video.videoWidth,\n linkHeight: video.videoHeight,\n linkHtmlTagName: \"video\",\n });\n // prevent video from playing\n try {\n video.pause();\n } catch (e) {}\n // prevent video from loading\n try {\n video.src = \"\";\n } catch (e) {}\n });\n video.addEventListener(\"error\", (error) => {\n reject(Error(`failed fetching video dimensions for url '${url}'`));\n });\n\n // max loading time\n const timeout = 30000;\n setTimeout(\n () =>\n reject(Error(`failed fetching video dimensions for url '${url}' timeout '${timeout}'`)),\n timeout,\n );\n\n // start loading\n video.src = url;\n });\n\n const fetchAudio = (url: string) =>\n new Promise<CommentLinkDimensions>((resolve, reject) => {\n const audio = document.createElement(\"audio\");\n audio.addEventListener(\"loadeddata\", () => {\n resolve({\n linkHtmlTagName: \"audio\",\n });\n try {\n audio.pause();\n } catch {}\n try {\n audio.src = \"\";\n } catch {}\n });\n audio.addEventListener(\"error\", () =>\n reject(Error(`failed fetching audio html tag name for url '${url}'`)),\n );\n\n const timeout = 20000;\n setTimeout(\n () =>\n reject(\n Error(`failed fetching audio html tag name for url '${url}' timeout '${timeout}'`),\n ),\n timeout,\n );\n\n audio.src = url;\n });\n\n try {\n if (new URL(link).protocol !== \"https:\") {\n throw Error(`failed fetching comment.link dimensions for link '${link}' not https protocol`);\n }\n const dimensions = await promiseAny([\n fetchImageDimensions(link),\n fetchVideoDimensions(link),\n fetchAudio(link),\n ]);\n return dimensions;\n } catch (error: any) {\n log.error(\"fetchCommentLinkDimensions error\", { error, link });\n return {};\n }\n};\n\nexport const getInitAccountCommentsToUpdate = (accountsComments: AccountsComments) => {\n const accountCommentsToUpdate: { accountComment: AccountComment; accountId: string }[] = [];\n for (const accountId in accountsComments) {\n for (const accountComment of accountsComments[accountId]) {\n accountCommentsToUpdate.push({ accountComment, accountId });\n }\n }\n\n // update newer comments first, more likely to have notifications\n accountCommentsToUpdate.sort((a, b) => b.accountComment.timestamp - a.accountComment.timestamp);\n\n // updating too many comments during init slows down fetching comments/subs\n if (accountCommentsToUpdate.length > 10) {\n accountCommentsToUpdate.length = 10;\n }\n\n // TODO: add some algo to fetch all notifications (even old), but not on init\n // during downtimes when we're not fetching anything else\n return accountCommentsToUpdate;\n};\n\nexport const getAccountCommentDepth = (comment: Comment) => {\n if (!comment.parentCid) {\n return 0;\n }\n let parentCommentDepth = commentsStore.getState().comments[comment.parentCid]?.depth;\n if (typeof parentCommentDepth === \"number\") {\n return parentCommentDepth + 1;\n }\n parentCommentDepth = repliesPagesStore.getState().comments[comment.parentCid]?.depth;\n if (typeof parentCommentDepth === \"number\") {\n return parentCommentDepth + 1;\n }\n parentCommentDepth = communitiesPagesStore.getState().comments[comment.parentCid]?.depth;\n if (typeof parentCommentDepth === \"number\") {\n return parentCommentDepth + 1;\n }\n // if can't find the parent comment depth anywhere, don't include it with the account comment\n // it will be added automatically when challenge verification is received\n};\n\nexport const getFreshestLoadedComment = (\n commentCid: string,\n ...additionalCandidates: (Comment | undefined)[]\n): Comment | undefined => {\n const candidates = [\n commentsStore.getState().comments[commentCid],\n repliesPagesStore.getState().comments[commentCid],\n communitiesPagesStore.getState().comments[commentCid],\n repliesCommentsStore.getState().comments[commentCid],\n ...additionalCandidates,\n ];\n return candidates.reduce<Comment | undefined>(\n (freshest, candidate) =>\n getCommentVoteCountsVersion(candidate) > getCommentVoteCountsVersion(freshest)\n ? candidate\n : freshest,\n undefined,\n );\n};\n\nexport const addShortAddressesToAccountComment = (comment: Comment) => {\n comment = { ...comment };\n try {\n comment.shortCommunityAddress = PkcJs.PKC.getShortAddress({\n address: comment.communityAddress,\n });\n } catch (e) {}\n try {\n comment.author = { ...comment.author };\n comment.author.shortAddress = PkcJs.PKC.getShortAddress({\n address: comment.author.address,\n });\n } catch (e) {}\n return comment;\n};\n\nconst utils = {\n getAccountCommunities,\n getCommentCidsToAccountsComments,\n getAccountCommentsIndex,\n getAccountsCommentsIndexes,\n sanitizeAccountCommentForState,\n sanitizeStoredAccountComment,\n getAccountEditPropertySummary,\n getAccountsEditsSummary,\n fetchCommentLinkDimensions,\n getInitAccountCommentsToUpdate,\n getAccountCommentDepth,\n getFreshestLoadedComment,\n addShortAddressesToAccountComment,\n promiseAny,\n};\n\nexport default utils;\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/stores/accounts/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAaA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CA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MAAM,CACtB,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,CACtB,2BAA2B,CAAC,SAAS,CAAC,GAAG,2BAA2B,CAAC,QAAQ,CAAC;QAC5E,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,QAAQ,EACd,SAAS,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,OAAgB,EAAE,EAAE;IACpE,OAAO,qBAAQ,OAAO,CAAE,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,CAAC,qBAAqB,GAAG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC;YACxD,OAAO,EAAE,OAAO,CAAC,gBAAgB;SAClC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;IACd,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,qBAAQ,OAAO,CAAC,MAAM,CAAE,CAAC;QACvC,OAAO,CAAC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC;YACtD,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;SAChC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;IACd,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG;IACZ,qBAAqB;IACrB,gCAAgC;IAChC,uBAAuB;IACvB,0BAA0B;IAC1B,8BAA8B;IAC9B,4BAA4B;IAC5B,6BAA6B;IAC7B,uBAAuB;IACvB,0BAA0B;IAC1B,8BAA8B;IAC9B,sBAAsB;IACtB,wBAAwB;IACxB,iCAAiC;IACjC,UAAU;CACX,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import {\n Account,\n Role,\n Communities,\n AccountComment,\n AccountsComments,\n AccountsCommentsIndexes,\n AccountCommentsIndex,\n CommentCidsToAccountsComments,\n Comment,\n AccountEdit,\n AccountEditsSummary,\n} from \"../../types\";\nimport assert from \"../../lib/assert\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\nimport commentsStore from \"../comments\";\nimport repliesPagesStore from \"../replies-pages\";\nimport communitiesPagesStore from \"../communities-pages\";\nimport repliesCommentsStore from \"../replies/replies-comments-store\";\nimport PkcJs from \"../../lib/pkc-js\";\nimport { getCommentVoteCountsVersion } from \"../../lib/utils/optimistic-vote-counts\";\n\nconst getAuthorAddressRolesFromCommunities = (authorAddress: string, communities: Communities) => {\n const roles: { [communityAddress: string]: Role } = {};\n for (const communityAddress in communities) {\n const role = communities[communityAddress]?.roles?.[authorAddress];\n if (role) {\n roles[communityAddress] = role;\n }\n }\n return roles;\n};\n\nexport const getAccountCommunities = (account: Account, communities: Communities) => {\n assert(\n account?.author?.address && typeof account?.author?.address === \"string\",\n `accountsStore utils getAccountCommunities invalid account.author.address '${account?.author?.address}'`,\n );\n assert(\n communities && typeof communities === \"object\",\n `accountsStore utils getAccountCommunities invalid communities '${communities}'`,\n );\n\n const roles = getAuthorAddressRolesFromCommunities(account.author.address, communities);\n const accountCommunities = { ...account.communities };\n for (const communityAddress in roles) {\n accountCommunities[communityAddress] = { ...accountCommunities[communityAddress] };\n accountCommunities[communityAddress].role = roles[communityAddress];\n }\n return accountCommunities;\n};\n\nexport const getCommentCidsToAccountsComments = (accountsComments: AccountsComments) => {\n const commentCidsToAccountsComments: CommentCidsToAccountsComments = {};\n for (const accountId in accountsComments) {\n for (const accountComment of accountsComments[accountId]) {\n if (accountComment.cid) {\n commentCidsToAccountsComments[accountComment.cid] = {\n accountId,\n accountCommentIndex: accountComment.index,\n };\n }\n }\n }\n return commentCidsToAccountsComments;\n};\n\nconst cloneWithoutFunctions = (value: any): any => {\n if (Array.isArray(value)) {\n return value\n .map((entry) => cloneWithoutFunctions(entry))\n .filter((entry) => entry !== undefined);\n }\n if (!value || typeof value !== \"object\") {\n return typeof value === \"function\" ? undefined : value;\n }\n\n const clonedValue: Record<string, any> = {};\n for (const key in value) {\n if (typeof value[key] === \"function\") {\n continue;\n }\n const clonedChild = cloneWithoutFunctions(value[key]);\n if (clonedChild !== undefined) {\n clonedValue[key] = clonedChild;\n }\n }\n return clonedValue;\n};\n\nconst compactStoredCommentAuthor = (author: any) => {\n if (!author || typeof author !== \"object\") {\n return undefined;\n }\n\n const compactAuthor = cloneWithoutFunctions({\n address: author.address,\n shortAddress: author.shortAddress,\n displayName: author.displayName,\n avatar: author.avatar,\n flair: author.flair,\n });\n\n return compactAuthor && Object.keys(compactAuthor).length > 0 ? compactAuthor : undefined;\n};\n\nconst compactStoredOriginalComment = (originalComment: any) => {\n if (!originalComment || typeof originalComment !== \"object\") {\n return undefined;\n }\n\n const compactOriginalComment = cloneWithoutFunctions({\n cid: originalComment.cid,\n content: originalComment.content,\n title: originalComment.title,\n link: originalComment.link,\n linkWidth: originalComment.linkWidth,\n linkHeight: originalComment.linkHeight,\n linkHtmlTagName: originalComment.linkHtmlTagName,\n thumbnailUrl: originalComment.thumbnailUrl,\n media: originalComment.media,\n spoiler: originalComment.spoiler,\n nsfw: originalComment.nsfw,\n deleted: originalComment.deleted,\n removed: originalComment.removed,\n reason: originalComment.reason,\n quotedCids: originalComment.quotedCids,\n parentCid: originalComment.parentCid,\n postCid: originalComment.postCid,\n communityAddress: originalComment.communityAddress,\n timestamp: originalComment.timestamp,\n author: compactStoredCommentAuthor(originalComment.author),\n });\n\n return compactOriginalComment && Object.keys(compactOriginalComment).length > 0\n ? compactOriginalComment\n : undefined;\n};\n\nconst compactStoredReplies = (replies: any) => {\n if (!replies || typeof replies !== \"object\") {\n return undefined;\n }\n\n const compactReplies = cloneWithoutFunctions(\n Object.fromEntries(\n Object.entries(replies).filter(\n ([replyKey]) => replyKey !== \"pages\" && replyKey !== \"clients\",\n ),\n ),\n );\n\n return compactReplies && Object.keys(compactReplies).length > 0 ? compactReplies : undefined;\n};\n\nexport const sanitizeAccountCommentForState = (comment: Comment) => {\n const sanitizedComment = cloneWithoutFunctions({\n ...comment,\n signer: undefined,\n raw: undefined,\n replies: comment?.replies\n ? Object.fromEntries(\n Object.entries(comment.replies).filter(([replyKey]) => replyKey !== \"pages\"),\n )\n : comment?.replies,\n });\n\n if (!sanitizedComment || typeof sanitizedComment !== \"object\") {\n return sanitizedComment;\n }\n if (sanitizedComment?.replies?.pages) {\n sanitizedComment.replies = { ...sanitizedComment.replies };\n delete sanitizedComment.replies.pages;\n }\n if (sanitizedComment?.replies && Object.keys(sanitizedComment.replies).length === 0) {\n delete sanitizedComment.replies;\n }\n return sanitizedComment;\n};\n\nexport const sanitizeStoredAccountComment = (comment: Comment) => {\n const preprocessedComment = {\n ...comment,\n signer: undefined,\n clients: undefined,\n raw: undefined,\n replies: compactStoredReplies(comment?.replies),\n original: comment?.edit ? compactStoredOriginalComment(comment.original) : undefined,\n };\n const sanitizedComment = cloneWithoutFunctions(preprocessedComment);\n if (!sanitizedComment || typeof sanitizedComment !== \"object\") {\n return sanitizedComment;\n }\n if (sanitizedComment?.replies && Object.keys(sanitizedComment.replies).length === 0) {\n delete sanitizedComment.replies;\n }\n if (sanitizedComment?.original && Object.keys(sanitizedComment.original).length === 0) {\n delete sanitizedComment.original;\n }\n return sanitizedComment;\n};\n\nexport const getAccountCommentsIndex = (\n accountComments: AccountComment[] | undefined,\n): AccountCommentsIndex => {\n const index: AccountCommentsIndex = {\n byCommunityAddress: {},\n byParentCid: {},\n };\n for (const accountComment of accountComments || []) {\n if (accountComment.communityAddress) {\n if (!index.byCommunityAddress[accountComment.communityAddress]) {\n index.byCommunityAddress[accountComment.communityAddress] = [];\n }\n index.byCommunityAddress[accountComment.communityAddress].push(accountComment.index);\n }\n if (accountComment.parentCid) {\n if (!index.byParentCid[accountComment.parentCid]) {\n index.byParentCid[accountComment.parentCid] = [];\n }\n index.byParentCid[accountComment.parentCid].push(accountComment.index);\n }\n }\n return index;\n};\n\nexport const getAccountsCommentsIndexes = (accountsComments: AccountsComments) => {\n const indexes: AccountsCommentsIndexes = {};\n for (const accountId in accountsComments) {\n indexes[accountId] = getAccountCommentsIndex(accountsComments[accountId]);\n }\n return indexes;\n};\n\nconst accountEditNonPropertyNames = new Set([\n \"author\",\n \"signer\",\n \"clientId\",\n \"commentCid\",\n \"communityAddress\",\n \"communityAddress\",\n \"timestamp\",\n]);\n\nexport const COMMENT_MODERATION_AUTHOR_SUMMARY_KEY = \"commentModeration.author\";\n\nconst normalizeAccountEditForSummary = (accountEdit: AccountEdit) => {\n const normalizedAccountEdit = { ...accountEdit };\n const commentModeration = normalizedAccountEdit.commentModeration;\n if (commentModeration && typeof commentModeration === \"object\") {\n const { author, ...commentModerationProperties } = commentModeration;\n Object.assign(normalizedAccountEdit, commentModerationProperties);\n if (Object.prototype.hasOwnProperty.call(commentModeration, \"author\")) {\n normalizedAccountEdit[COMMENT_MODERATION_AUTHOR_SUMMARY_KEY] = author;\n }\n delete normalizedAccountEdit.commentModeration;\n }\n const communityEdit = normalizedAccountEdit.communityEdit ?? normalizedAccountEdit.communityEdit;\n if (communityEdit && typeof communityEdit === \"object\") {\n Object.assign(normalizedAccountEdit, communityEdit);\n }\n delete normalizedAccountEdit.communityEdit;\n delete normalizedAccountEdit.communityEdit;\n return normalizedAccountEdit;\n};\n\nexport const getAccountEditPropertySummary = (accountEdits: AccountEdit[] | undefined) => {\n const accountEditPropertySummary: AccountEditsSummary[string] = {};\n for (const accountEdit of accountEdits || []) {\n const normalizedAccountEdit = normalizeAccountEditForSummary(accountEdit);\n for (const propertyName in normalizedAccountEdit) {\n if (\n (normalizedAccountEdit[propertyName] === undefined &&\n propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) ||\n accountEditNonPropertyNames.has(propertyName)\n ) {\n continue;\n }\n const previousTimestamp = accountEditPropertySummary[propertyName]?.timestamp || 0;\n if ((normalizedAccountEdit.timestamp || 0) >= previousTimestamp) {\n accountEditPropertySummary[propertyName] = {\n timestamp: normalizedAccountEdit.timestamp,\n value: normalizedAccountEdit[propertyName],\n };\n }\n }\n }\n return accountEditPropertySummary;\n};\n\nexport const getAccountsEditsSummary = (accountEdits: {\n [commentCidOrCommunityAddress: string]: AccountEdit[];\n}) => {\n const summary: AccountEditsSummary = {};\n for (const target in accountEdits || {}) {\n summary[target] = getAccountEditPropertySummary(accountEdits[target]);\n }\n return summary;\n};\n\ninterface CommentLinkDimensions {\n linkWidth?: number;\n linkHeight?: number;\n linkHtmlTagName?: \"img\" | \"video\" | \"audio\";\n}\n\n// polyfill Promise.any, exported for test coverage of empty-array branch\nconst promiseAny = <T>(promises: Promise<T>[]): Promise<T> =>\n new Promise((res, rej) => {\n let count = promises.length;\n if (count === 0) return rej(Error(\"all promises rejected\"));\n promises.forEach((p) =>\n Promise.resolve(p)\n .then(res)\n .catch((e) => {\n if (--count === 0) rej(Error(\"all promises rejected\"));\n }),\n );\n });\n\nexport const fetchCommentLinkDimensions = async (link: string): Promise<CommentLinkDimensions> => {\n if (!link) {\n return {};\n }\n\n const fetchImageDimensions = (url: string) =>\n new Promise<CommentLinkDimensions>((resolve, reject) => {\n const image = new Image();\n image.onload = () => {\n // don't accept 0px value\n if (!image.width || !image.height) {\n return reject(Error(`failed fetching image dimensions for url '${url}'`));\n }\n resolve({\n linkWidth: image.width,\n linkHeight: image.height,\n linkHtmlTagName: \"img\",\n });\n\n // remove image from memory\n try {\n image.src = \"\";\n } catch (e) {}\n };\n image.onerror = (error) => {\n reject(Error(`failed fetching image dimensions for url '${url}'`));\n };\n\n // max loading time\n const timeout = 10000;\n setTimeout(\n () =>\n reject(Error(`failed fetching image dimensions for url '${url}' timeout '${timeout}'`)),\n timeout,\n );\n\n // start loading\n image.src = url;\n });\n\n const fetchVideoDimensions = (url: string) =>\n new Promise<CommentLinkDimensions>((resolve, reject) => {\n const video = document.createElement(\"video\");\n video.muted = true;\n video.loop = false;\n video.addEventListener(\"loadeddata\", () => {\n // don't accept 0px value\n if (!video.videoWidth || !video.videoHeight) {\n return reject(Error(`failed fetching video dimensions for url '${url}'`));\n }\n resolve({\n linkWidth: video.videoWidth,\n linkHeight: video.videoHeight,\n linkHtmlTagName: \"video\",\n });\n // prevent video from playing\n try {\n video.pause();\n } catch (e) {}\n // prevent video from loading\n try {\n video.src = \"\";\n } catch (e) {}\n });\n video.addEventListener(\"error\", (error) => {\n reject(Error(`failed fetching video dimensions for url '${url}'`));\n });\n\n // max loading time\n const timeout = 30000;\n setTimeout(\n () =>\n reject(Error(`failed fetching video dimensions for url '${url}' timeout '${timeout}'`)),\n timeout,\n );\n\n // start loading\n video.src = url;\n });\n\n const fetchAudio = (url: string) =>\n new Promise<CommentLinkDimensions>((resolve, reject) => {\n const audio = document.createElement(\"audio\");\n audio.addEventListener(\"loadeddata\", () => {\n resolve({\n linkHtmlTagName: \"audio\",\n });\n try {\n audio.pause();\n } catch {}\n try {\n audio.src = \"\";\n } catch {}\n });\n audio.addEventListener(\"error\", () =>\n reject(Error(`failed fetching audio html tag name for url '${url}'`)),\n );\n\n const timeout = 20000;\n setTimeout(\n () =>\n reject(\n Error(`failed fetching audio html tag name for url '${url}' timeout '${timeout}'`),\n ),\n timeout,\n );\n\n audio.src = url;\n });\n\n try {\n if (new URL(link).protocol !== \"https:\") {\n throw Error(`failed fetching comment.link dimensions for link '${link}' not https protocol`);\n }\n const dimensions = await promiseAny([\n fetchImageDimensions(link),\n fetchVideoDimensions(link),\n fetchAudio(link),\n ]);\n return dimensions;\n } catch (error: any) {\n log.error(\"fetchCommentLinkDimensions error\", { error, link });\n return {};\n }\n};\n\nexport const getInitAccountCommentsToUpdate = (accountsComments: AccountsComments) => {\n const accountCommentsToUpdate: { accountComment: AccountComment; accountId: string }[] = [];\n for (const accountId in accountsComments) {\n for (const accountComment of accountsComments[accountId]) {\n accountCommentsToUpdate.push({ accountComment, accountId });\n }\n }\n\n // update newer comments first, more likely to have notifications\n accountCommentsToUpdate.sort((a, b) => b.accountComment.timestamp - a.accountComment.timestamp);\n\n // updating too many comments during init slows down fetching comments/subs\n if (accountCommentsToUpdate.length > 10) {\n accountCommentsToUpdate.length = 10;\n }\n\n // TODO: add some algo to fetch all notifications (even old), but not on init\n // during downtimes when we're not fetching anything else\n return accountCommentsToUpdate;\n};\n\nexport const getAccountCommentDepth = (comment: Comment) => {\n if (!comment.parentCid) {\n return 0;\n }\n let parentCommentDepth = commentsStore.getState().comments[comment.parentCid]?.depth;\n if (typeof parentCommentDepth === \"number\") {\n return parentCommentDepth + 1;\n }\n parentCommentDepth = repliesPagesStore.getState().comments[comment.parentCid]?.depth;\n if (typeof parentCommentDepth === \"number\") {\n return parentCommentDepth + 1;\n }\n parentCommentDepth = communitiesPagesStore.getState().comments[comment.parentCid]?.depth;\n if (typeof parentCommentDepth === \"number\") {\n return parentCommentDepth + 1;\n }\n // if can't find the parent comment depth anywhere, don't include it with the account comment\n // it will be added automatically when challenge verification is received\n};\n\nexport const getFreshestLoadedComment = (\n commentCid: string,\n ...additionalCandidates: (Comment | undefined)[]\n): Comment | undefined => {\n const candidates = [\n commentsStore.getState().comments[commentCid],\n repliesPagesStore.getState().comments[commentCid],\n communitiesPagesStore.getState().comments[commentCid],\n repliesCommentsStore.getState().comments[commentCid],\n ...additionalCandidates,\n ];\n return candidates.reduce<Comment | undefined>(\n (freshest, candidate) =>\n getCommentVoteCountsVersion(candidate) > getCommentVoteCountsVersion(freshest)\n ? candidate\n : freshest,\n undefined,\n );\n};\n\nexport const addShortAddressesToAccountComment = (comment: Comment) => {\n comment = { ...comment };\n try {\n comment.shortCommunityAddress = PkcJs.PKC.getShortAddress({\n address: comment.communityAddress,\n });\n } catch (e) {}\n try {\n comment.author = { ...comment.author };\n comment.author.shortAddress = PkcJs.PKC.getShortAddress({\n address: comment.author.address,\n });\n } catch (e) {}\n return comment;\n};\n\nconst utils = {\n getAccountCommunities,\n getCommentCidsToAccountsComments,\n getAccountCommentsIndex,\n getAccountsCommentsIndexes,\n sanitizeAccountCommentForState,\n sanitizeStoredAccountComment,\n getAccountEditPropertySummary,\n getAccountsEditsSummary,\n fetchCommentLinkDimensions,\n getInitAccountCommentsToUpdate,\n getAccountCommentDepth,\n getFreshestLoadedComment,\n addShortAddressesToAccountComment,\n promiseAny,\n};\n\nexport default utils;\n"]}
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import Logger from "@pkcprotocol/pkc-logger";
|
|
11
11
|
const log = Logger("bitsocial-react-hooks:authors:stores");
|
|
12
12
|
import createStore from "zustand";
|
|
13
|
-
import assert from "assert";
|
|
13
|
+
import assert from "../../lib/assert.js";
|
|
14
14
|
import commentsStore from "../comments/index.js";
|
|
15
15
|
import QuickLru from "quick-lru";
|
|
16
16
|
import { getUpdatedLoadedAndBufferedComments, getNextCommentCidToFetchNotFetched, } from "./utils.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authors-comments-store.js","sourceRoot":"","sources":["../../../src/stores/authors-comments/authors-comments-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAC3D,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAQ5B,OAAO,aAAgC,MAAM,aAAa,CAAC;AAC3D,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAEL,mCAAmC,EACnC,kCAAkC,GACnC,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,aAAa,CAAC;AAExC,wEAAwE;AACxE,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,kDAAkD;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAmBpC,MAAM,oBAAoB,GAAG,WAAW,CACtC,CAAC,QAAkB,EAAE,QAAkB,EAAE,EAAE,CAAC,CAAC;IAC3C,OAAO,EAAE,EAAE;IACX,cAAc,EAAE,EAAE;IA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UAAU,CAAC,CAAC;IACrD,yCAAyC;IACzC,oBAAoB,EAAE,CAAC;IACvB,+FAA+F;IAC/F,IAAI,MAAA,OAAO,CAAC,MAAM,0CAAE,kBAAkB,EAAE,CAAC;QACvC,yBAAyB,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC;AAEJ,+BAA+B;AAC/B,MAAM,aAAa,GAAG,oBAAoB,CAAC,QAAQ,EAAE,CAAC;AACtD,qDAAqD;AACrD,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAS,EAAE;IAClD,gCAAgC,GAAG,EAAE,CAAC;IACtC,gBAAgB,GAAG,IAAI,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,yBAAyB,GAAG,EAAE,CAAC;IAC/B,oBAAoB,GAAG,IAAI,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAExD,mDAAmD;IACnD,oBAAoB,CAAC,OAAO,EAAE,CAAC;IAC/B,yBAAyB;IACzB,oBAAoB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC/C,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,oCAAoC,GAAG,GAAS,EAAE;IAC7D,MAAM,yBAAyB,EAAE,CAAC;AACpC,CAAC,CAAA,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["import Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:authors:stores\");\nimport createStore from \"zustand\";\nimport assert from \"assert\";\nimport {\n CommentsFilter,\n AuthorCommentsOptions,\n AuthorsComments,\n Account,\n Comment,\n} from \"../../types\";\nimport commentsStore, { CommentsState } from \"../comments\";\nimport QuickLru from \"quick-lru\";\nimport {\n toSizes,\n getUpdatedLoadedAndBufferedComments,\n getNextCommentCidToFetchNotFetched,\n} from \"./utils\";\nimport accountsStore from \"../accounts\";\n\n// reddit loads approximately 25 posts per page while infinite scrolling\nexport const commentsPerPage = 25;\n// keep large buffer because fetching cids is slow\nexport const commentBufferSize = 50;\n\ntype AuthorsCommentsState = {\n // authorCommentsName is a string used a key to represent authorAddress + filter + accountId\n options: { [authorCommentsName: string]: AuthorCommentsOptions };\n loadedComments: { [authorCommentsName: string]: Comment[] };\n hasMoreBufferedComments: { [authorCommentsName: string]: boolean };\n bufferedCommentCids: { [authorAddress: string]: Set<string> };\n nextCommentCidsToFetch: { [authorAddress: string]: string | undefined };\n shouldFetchNextComment: { [authorAddress: string]: boolean };\n lastCommentCids: { [authorAddress: string]: string | undefined };\n addAuthorCommentsToStore: Function;\n setNextCommentCidsToFetch: Function;\n incrementPageNumber: Function;\n addBufferedCommentCid: Function;\n updateLoadedComments: Function;\n setLastCommentCid: Function;\n};\n\nconst authorsCommentsStore = createStore<AuthorsCommentsState>(\n (setState: Function, getState: Function) => ({\n options: {},\n loadedComments: {},\n hasMoreBufferedComments: {},\n bufferedCommentCids: {},\n lastCommentCids: {},\n nextCommentCidsToFetch: {},\n shouldFetchNextComment: {},\n\n addAuthorCommentsToStore: (\n authorCommentsName: string,\n authorAddress: string,\n commentCid: string,\n filter: CommentsFilter | undefined,\n account: Account,\n ) => {\n assert(\n authorCommentsName && typeof authorCommentsName === \"string\",\n `addAuthorCommentsToStore.incrementPageNumber invalid argument authorCommentsName '${authorCommentsName}'`,\n );\n assert(\n authorAddress && typeof authorAddress === \"string\",\n `authorsCommentsStore.addAuthorCommentsToStore invalid argument authorAddress '${authorAddress}'`,\n );\n assert(\n commentCid && typeof commentCid === \"string\",\n `authorsCommentsStore.addAuthorCommentsToStore invalid argument commentCid '${commentCid}'`,\n );\n assert(\n !filter || typeof filter?.filter === \"function\",\n `authorsCommentsStore.addAuthorCommentsToStore invalid argument filter.filter '${filter?.filter}'`,\n );\n assert(\n !filter || typeof filter?.key === \"string\",\n `authorsCommentsStore.addAuthorCommentsToStore invalid argument filter.key '${filter?.key}'`,\n );\n assert(\n typeof account?.pkc?.getComment === \"function\",\n `authorsCommentsStore.addAuthorCommentsToStore account '${account}' invalid`,\n );\n\n const { options, updateLoadedComments } = getState();\n // in store already, do nothing\n if (options[authorCommentsName]) {\n return;\n }\n const authorCommentsOptions = { authorAddress, pageNumber: 1, filter, accountId: account.id };\n\n // subscribe to nextCommentCidsToFetch and shouldFetchNextComment to fetch the comments\n authorsCommentsStore.subscribe(\n fetchCommentOnShouldFetchOrNextCidChange(authorCommentsOptions),\n );\n\n log(\"authorsCommentsActions.addAuthorCommentsToStore\", {\n authorCommentsName,\n authorCommentsOptions,\n commentCid,\n previousAuthorsCommentsOptions: options,\n });\n setState((state: AuthorsCommentsState) => ({\n options: { ...state.options, [authorCommentsName]: authorCommentsOptions },\n loadedComments: { ...state.loadedComments, [authorCommentsName]: [] },\n hasMoreBufferedComments: { ...state.hasMoreBufferedComments, [authorCommentsName]: true },\n bufferedCommentCids: {\n ...state.bufferedCommentCids,\n [authorAddress]: state.bufferedCommentCids[authorAddress] || new Set(),\n },\n lastCommentCids: {\n ...state.lastCommentCids,\n [authorAddress]: state.lastCommentCids[authorAddress] || undefined,\n },\n nextCommentCidsToFetch: {\n ...state.nextCommentCidsToFetch,\n [authorAddress]: state.nextCommentCidsToFetch[authorAddress] || commentCid,\n },\n shouldFetchNextComment: {\n ...state.shouldFetchNextComment,\n [authorAddress]: state.shouldFetchNextComment[authorAddress] || true,\n },\n }));\n\n // update loadedComments in case the author already has bufferedCommentCids\n updateLoadedComments();\n },\n\n setNextCommentCidsToFetch: (authorAddress: string, authorComment: Comment) => {\n assert(\n authorAddress && typeof authorAddress === \"string\",\n `authorsCommentsActions.setNextCommentCidsToFetch invalid argument authorAddress '${authorAddress}'`,\n );\n assert(\n typeof authorComment?.timestamp === \"number\",\n `authorsCommentsActions.setNextCommentCidsToFetch invalid argument authorComment '${authorComment}'`,\n );\n const { nextCommentCidsToFetch, shouldFetchNextComment, lastCommentCids } = getState();\n if (typeof shouldFetchNextComment[authorAddress] !== \"boolean\") {\n throw Error(\n `authorsCommentsActions.setNextCommentCidsToFetch can't set nextCommentCidToFetch '${authorAddress}' not in store`,\n );\n }\n const nextCommentCidToFetch = authorComment?.author?.previousCommentCid;\n if (nextCommentCidToFetch === nextCommentCidsToFetch[authorAddress]) {\n throw Error(\n `authorsCommentsActions.setNextCommentCidsToFetch can't set nextCommentCidToFetch '${authorAddress}' to '${nextCommentCidToFetch}' same value`,\n );\n }\n const nextCommentCidToFetchNotFetched =\n getNextCommentCidToFetchNotFetched(nextCommentCidToFetch);\n\n // log.trace('authorsCommentsActions.setNextCommentCidsToFetch', {\n // authorAddress,\n // authorComment,\n // previousNextCommentCidToFetch: nextCommentCidsToFetch[authorAddress],\n // nextCommentCidToFetch,\n // nextCommentCidToFetchNotFetched,\n // lastCommentCid: lastCommentCids[authorAddress],\n // shouldFetchNextComment: shouldFetchNextComment[authorAddress],\n // })\n setState((state: AuthorsCommentsState) => ({\n nextCommentCidsToFetch: {\n ...state.nextCommentCidsToFetch,\n [authorAddress]: nextCommentCidToFetchNotFetched,\n },\n }));\n },\n\n incrementPageNumber: (authorCommentsName: string) => {\n assert(\n authorCommentsName && typeof authorCommentsName === \"string\",\n `authorsCommentsActions.incrementPageNumber invalid argument authorCommentsName '${authorCommentsName}'`,\n );\n const { options, updateLoadedComments, loadedComments, nextCommentCidsToFetch } = getState();\n if (!options[authorCommentsName]) {\n throw Error(\n `authorsCommentsActions.incrementPageNumber can't increment page number of options '${authorCommentsName}' not in store`,\n );\n }\n assert(\n options[authorCommentsName].pageNumber * commentsPerPage <=\n loadedComments[authorCommentsName].length,\n `authorsCommentsActions.incrementPageNumber cannot increment page number before current page has loaded`,\n );\n\n log(\"authorsCommentsActions.incrementPageNumber\", {\n authorCommentsName,\n pageNumber: options[authorCommentsName].pageNumber + 1,\n nextCommentCidsToFetch: nextCommentCidsToFetch[options[authorCommentsName].authorAddress],\n });\n setState(({ options }: AuthorsCommentsState) => {\n const authorCommentOptions = { ...options[authorCommentsName] };\n authorCommentOptions.pageNumber++;\n return { options: { ...options, [authorCommentsName]: authorCommentOptions } };\n });\n\n // must update loadedComments to reflect the new added page\n updateLoadedComments();\n },\n\n addBufferedCommentCid: (authorAddress: string, commentCid: string) => {\n assert(\n authorAddress && typeof authorAddress === \"string\",\n `authorsCommentsActions.addBufferedCommentCid invalid argument authorAddress '${authorAddress}'`,\n );\n assert(\n commentCid && typeof commentCid === \"string\",\n `authorsCommentsActions.addBufferedCommentCid invalid argument commentCid '${commentCid}'`,\n );\n\n const { bufferedCommentCids } = getState();\n if (!bufferedCommentCids[authorAddress]) {\n throw Error(\n `authorsCommentsActions.addBufferedCommentCid can't add commentCid '${authorAddress}' not in store`,\n );\n }\n if (bufferedCommentCids[authorAddress].has(commentCid)) {\n throw Error(\n `authorsCommentsActions.addBufferedCommentCid can't add commentCid '${authorAddress}' '${commentCid}' already added`,\n );\n }\n\n // log.trace('authorsCommentsActions.addBufferedCommentCid', {authorAddress, commentCid, previousBufferedCommentCidsSize: bufferedCommentCids[authorAddress].size})\n setState((state: AuthorsCommentsState) => ({\n bufferedCommentCids: {\n ...state.bufferedCommentCids,\n [authorAddress]: new Set([...bufferedCommentCids[authorAddress], commentCid]),\n },\n }));\n },\n\n updateLoadedComments() {\n const { comments } = commentsStore.getState();\n let {\n loadedComments: previousAuthorsLoadedComments,\n bufferedCommentCids,\n options,\n nextCommentCidsToFetch,\n lastCommentCids,\n } = getState();\n\n const newAuthorsLoadedComments: AuthorsComments = {};\n const newShouldFetchNextComment: { [authorAddress: string]: boolean } = {};\n const newHasMoreBufferedComments: { [authorCommentsName: string]: boolean } = {};\n const authorCommentsNames = Object.keys(options);\n for (const name of authorCommentsNames) {\n const { authorAddress, pageNumber, filter } = options[name];\n const previousLoadedComments = previousAuthorsLoadedComments[name];\n const unfilteredBufferedComments: Comment[] = [...bufferedCommentCids[authorAddress]].map(\n (commentCid: string) => comments[commentCid],\n );\n\n const { loadedComments, bufferedComments: filteredBufferedComments } =\n getUpdatedLoadedAndBufferedComments(\n previousLoadedComments,\n unfilteredBufferedComments,\n pageNumber,\n filter,\n comments,\n );\n newAuthorsLoadedComments[name] = loadedComments;\n newHasMoreBufferedComments[name] = filteredBufferedComments.length > loadedComments.length;\n\n // if another authorCommentOptions should fetch, don't change it\n if (newShouldFetchNextComment[authorAddress] !== true) {\n // fetch if less comments than full page + buffer size\n newShouldFetchNextComment[authorAddress] =\n filteredBufferedComments.length < pageNumber * commentsPerPage + commentBufferSize;\n }\n }\n\n // log.trace('authorsCommentsActions.updateLoadedComments', {\n // bufferedCommentCids,\n // bufferedCommentCidsSizes: toSizes(bufferedCommentCids),\n // previousAuthorsLoadedComments,\n // newAuthorsLoadedComments,\n // previousAuthorsLoadedCommentsSizes: toSizes(previousAuthorsLoadedComments),\n // newAuthorsLoadedCommentsSizes: toSizes(newAuthorsLoadedComments),\n // newShouldFetchNextComment,\n // lastCommentCids\n // })\n setState(() => ({\n loadedComments: newAuthorsLoadedComments,\n shouldFetchNextComment: newShouldFetchNextComment,\n hasMoreBufferedComments: newHasMoreBufferedComments,\n }));\n },\n\n setLastCommentCid: (authorAddress: string, lastCommentCid: string) => {\n assert(\n authorAddress && typeof authorAddress === \"string\",\n `authorsCommentsActions.setLastCommentCid invalid argument authorAddress '${authorAddress}'`,\n );\n assert(\n lastCommentCid && typeof lastCommentCid === \"string\",\n `authorsCommentsActions.setLastCommentCid invalid argument lastCommentCid '${lastCommentCid}'`,\n );\n const { lastCommentCids, shouldFetchNextComment, nextCommentCidsToFetch } = getState();\n if (typeof shouldFetchNextComment[authorAddress] !== \"boolean\") {\n throw Error(\n `authorsCommentsActions.setLastCommentCid can't set lastCommentCid '${authorAddress}' not in store`,\n );\n }\n if (lastCommentCid === lastCommentCids[authorAddress]) {\n throw Error(\n `authorsCommentsActions.setLastCommentCid can't set setLastCommentCid '${authorAddress}' to '${lastCommentCid}' same value`,\n );\n }\n\n log(\"authorsCommentsActions.setLastCommentCid\", {\n authorAddress,\n lastCommentCid,\n previousLastCommentCid: lastCommentCids[authorAddress],\n shouldFetchNextComment: shouldFetchNextComment[authorAddress],\n nextCommentCidsToFetch: nextCommentCidsToFetch[authorAddress],\n });\n setState((state: AuthorsCommentsState) => ({\n lastCommentCids: { ...state.lastCommentCids, [authorAddress]: lastCommentCid },\n }));\n },\n }),\n);\n\n// if nextCommentCidsToFetch or shouldFetchNextComment changed, fetch the next comment\nconst fetchCommentOnShouldFetchOrNextCidChange =\n (options: AuthorCommentsOptions) => (state: AuthorsCommentsState) => {\n const nextCommentCidToFetch = state.nextCommentCidsToFetch[options.authorAddress];\n if (!nextCommentCidToFetch) {\n return;\n }\n\n // the buffered comments are already full, not need to fetch next comment\n const shouldFetchNextComment = state.shouldFetchNextComment[options.authorAddress];\n if (!shouldFetchNextComment) {\n return;\n }\n\n // when comment has fetched, update loadedComments, bufferedComments and shouldFetchNextComment\n if (!authorCommentCidsFetching[nextCommentCidToFetch]) {\n authorCommentCidsFetching[nextCommentCidToFetch] = true;\n commentsStore.subscribe(updateCommentsOnCommentsChange(options, nextCommentCidToFetch));\n }\n\n // start fetching comment\n const account = accountsStore.getState().accounts[options.accountId];\n const addCommentToStore = commentsStore.getState().addCommentToStore;\n addCommentToStore(nextCommentCidToFetch, account).catch((error: unknown) =>\n log.error(\n \"authorsCommentsStore fetchCommentOnShouldFetchOrNextCidChange addCommentToStore error\",\n { error, nextCommentCidToFetch, account },\n ),\n );\n };\n\n// if commentStore changed, update loadedComments, bufferedCommentCids, shouldFetchNextComment and nextCommentCidsToFetch\nlet previousComments = new QuickLru({ maxSize: 10000 });\nlet authorCommentCidsFetching: { [commentCid: string]: boolean } = {};\nlet communityLastCommentCidsFetching: { [commentCid: string]: boolean } = {};\nconst updateCommentsOnCommentsChange =\n (options: AuthorCommentsOptions, commentCid: string) => (state: CommentsState) => {\n // not a next cid, do nothing\n if (!authorCommentCidsFetching[commentCid]) {\n return;\n }\n const comment = state.comments[commentCid];\n // comment hasn't changed, do nothing\n if (!comment?.timestamp || comment === previousComments.get(commentCid)) {\n return;\n }\n // comment author address is incorrect, do nothing\n if (comment.author?.address !== options.authorAddress) {\n return;\n }\n previousComments.set(commentCid, comment);\n\n const {\n addBufferedCommentCid,\n bufferedCommentCids,\n updateLoadedComments,\n setNextCommentCidsToFetch,\n nextCommentCidsToFetch,\n } = authorsCommentsStore.getState();\n\n // the comment is a new comment, add it to buffered comment cids\n if (!bufferedCommentCids[options.authorAddress].has(commentCid)) {\n addBufferedCommentCid(options.authorAddress, commentCid);\n }\n\n // the comment was the last cid to fetch, set the next cid to fetch as the author previous cid\n const nextCidToFetch = nextCommentCidsToFetch[options.authorAddress];\n if (commentCid === nextCidToFetch) {\n setNextCommentCidsToFetch(options.authorAddress, comment);\n }\n\n // one of the comment changed, must update loaded comments\n updateLoadedComments();\n\n // the changed comment might have a new author.community.lastCommentCid, try to fetch it\n const communityLastCommentCid = comment.author?.community?.lastCommentCid;\n if (communityLastCommentCid) {\n // when last comment has fetched, update lastCommentCid\n if (!communityLastCommentCidsFetching[communityLastCommentCid]) {\n communityLastCommentCidsFetching[communityLastCommentCid] = true;\n commentsStore.subscribe(\n setLastCommentCidOnCommentsChange(options, communityLastCommentCid),\n );\n }\n\n // start fetching lastCommentCid\n const account = accountsStore.getState().accounts[options.accountId];\n state.addCommentToStore(communityLastCommentCid, account).catch((error: unknown) =>\n log.error(\"authorsCommentsStore updateCommentsOnCommentsChange addCommentToStore error\", {\n error,\n communityLastCommentCid,\n account,\n }),\n );\n }\n };\n\nlet previousLastComments = new QuickLru({ maxSize: 10000 });\nconst setLastCommentCidOnCommentsChange =\n (options: AuthorCommentsOptions, commentCid: string) => (state: CommentsState) => {\n // not a last cid candidate, do nothing\n if (!communityLastCommentCidsFetching[commentCid]) {\n return;\n }\n const { comments } = state;\n\n const comment = comments[commentCid];\n // comment hasn't changed, do nothing\n if (!comment?.timestamp || comment === previousLastComments.get(commentCid)) {\n return;\n }\n // comment author address is incorrect, do nothing\n if (comment.author?.address !== options.authorAddress) {\n return;\n }\n previousLastComments.set(commentCid, comment);\n\n const {\n addBufferedCommentCid,\n lastCommentCids,\n bufferedCommentCids,\n setLastCommentCid,\n setNextCommentCidsToFetch,\n updateLoadedComments,\n } = authorsCommentsStore.getState();\n\n // if the comment is a new comment, add it to buffered comment cids\n if (!bufferedCommentCids[options.authorAddress].has(commentCid)) {\n addBufferedCommentCid(options.authorAddress, commentCid);\n }\n\n // already last comment cid, no need to set it\n if (commentCid === lastCommentCids[options.authorAddress]) {\n return;\n }\n\n // if comment is newer than current lastCommentCid and all bufferedComments, is lastCommentCid\n const currentLastCommentCid = lastCommentCids[options.authorAddress];\n const currentLastComment = comments[currentLastCommentCid || \"\"];\n // comment is older or equal to current lastCommentCid, do nothing\n if (comment.timestamp <= (currentLastComment?.timestamp || 0)) {\n log.trace(\n `authorsCommentsStore setLastCommentCidOnCommentsChange don't set lastCommentCid older than current lastCommentCid`,\n { comment, currentLastComment },\n );\n return;\n }\n\n // make sure lastComment is newer than all comments already in bufferedComments\n const bufferedComments: Comment[] = [...bufferedCommentCids[options.authorAddress]].map(\n (commentCid: string) => comments[commentCid],\n );\n for (const bufferedComment of bufferedComments) {\n const bufferedTs =\n bufferedComment == null || bufferedComment.timestamp == null\n ? 0\n : bufferedComment.timestamp;\n if (bufferedTs > comment.timestamp) {\n log.trace(\n `authorsCommentsStore setLastCommentCidOnCommentsChange don't set lastCommentCid older than buffered comments`,\n {\n comment,\n currentLastComment,\n bufferedComments,\n },\n );\n return;\n }\n }\n\n // is last comment cid, set it\n log(`authorsCommentsStore setLastCommentCidOnCommentsChange`, {\n lastCommentCid: comment.cid,\n lastComment: comment,\n currentLastComment,\n bufferedComments,\n });\n setLastCommentCid(options.authorAddress, commentCid);\n // add the last comment to loadedComments\n updateLoadedComments();\n // start a new linked list of comments to fetch using the lastComment.author.previousCommentCid\n if (comment.author?.previousCommentCid) {\n setNextCommentCidsToFetch(options.authorAddress, comment);\n }\n };\n\n// reset store in between tests\nconst originalState = authorsCommentsStore.getState();\n// async function because some stores have async init\nexport const resetAuthorsCommentsStore = async () => {\n communityLastCommentCidsFetching = {};\n previousComments = new QuickLru({ maxSize: 10000 });\n authorCommentCidsFetching = {};\n previousLastComments = new QuickLru({ maxSize: 10000 });\n\n // destroy all component subscriptions to the store\n authorsCommentsStore.destroy();\n // restore original state\n authorsCommentsStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetAuthorsCommentsDatabaseAndStore = async () => {\n await resetAuthorsCommentsStore();\n};\n\nexport default authorsCommentsStore;\n"]}
|
|
1
|
+
{"version":3,"file":"authors-comments-store.js","sourceRoot":"","sources":["../../../src/stores/authors-comments/authors-comments-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAC3D,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAQtC,OAAO,aAAgC,MAAM,aAAa,CAAC;AAC3D,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAEL,mCAAmC,EACnC,kCAAkC,GACnC,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,aAAa,CAAC;AAExC,wEAAwE;AACxE,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,kDAAkD;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAmBpC,MAAM,oBAAoB,GAAG,WAAW,CACtC,CAAC,QAAkB,EAAE,QAAkB,EAAE,EAAE,CAAC,CAAC;IAC3C,OAAO,EAAE,EAAE;IACX,cAAc,EAAE,EAAE;IAClB,uBAAuB,EAAE,EAAE;IAC3B,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,EAAE;IACnB,sBAAsB,EAAE,EAAE;IAC1B,sBAAsB,EAAE,EAAE;IAE1B,wBAAwB,EAAE,CACxB,kBAA0B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CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC;AAEJ,+BAA+B;AAC/B,MAAM,aAAa,GAAG,oBAAoB,CAAC,QAAQ,EAAE,CAAC;AACtD,qDAAqD;AACrD,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAS,EAAE;IAClD,gCAAgC,GAAG,EAAE,CAAC;IACtC,gBAAgB,GAAG,IAAI,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,yBAAyB,GAAG,EAAE,CAAC;IAC/B,oBAAoB,GAAG,IAAI,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAExD,mDAAmD;IACnD,oBAAoB,CAAC,OAAO,EAAE,CAAC;IAC/B,yBAAyB;IACzB,oBAAoB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC/C,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,oCAAoC,GAAG,GAAS,EAAE;IAC7D,MAAM,yBAAyB,EAAE,CAAC;AACpC,CAAC,CAAA,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["import Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:authors:stores\");\nimport createStore from \"zustand\";\nimport assert from \"../../lib/assert\";\nimport {\n CommentsFilter,\n AuthorCommentsOptions,\n AuthorsComments,\n Account,\n Comment,\n} from \"../../types\";\nimport commentsStore, { CommentsState } from \"../comments\";\nimport QuickLru from \"quick-lru\";\nimport {\n toSizes,\n getUpdatedLoadedAndBufferedComments,\n getNextCommentCidToFetchNotFetched,\n} from \"./utils\";\nimport accountsStore from \"../accounts\";\n\n// reddit loads approximately 25 posts per page while infinite scrolling\nexport const commentsPerPage = 25;\n// keep large buffer because fetching cids is slow\nexport const commentBufferSize = 50;\n\ntype AuthorsCommentsState = {\n // authorCommentsName is a string used a key to represent authorAddress + filter + accountId\n options: { [authorCommentsName: string]: AuthorCommentsOptions };\n loadedComments: { [authorCommentsName: string]: Comment[] };\n hasMoreBufferedComments: { [authorCommentsName: string]: boolean };\n bufferedCommentCids: { [authorAddress: string]: Set<string> };\n nextCommentCidsToFetch: { [authorAddress: string]: string | undefined };\n shouldFetchNextComment: { [authorAddress: string]: boolean };\n lastCommentCids: { [authorAddress: string]: string | undefined };\n addAuthorCommentsToStore: Function;\n setNextCommentCidsToFetch: Function;\n incrementPageNumber: Function;\n addBufferedCommentCid: Function;\n updateLoadedComments: Function;\n setLastCommentCid: Function;\n};\n\nconst authorsCommentsStore = createStore<AuthorsCommentsState>(\n (setState: Function, getState: Function) => ({\n options: {},\n loadedComments: {},\n hasMoreBufferedComments: {},\n bufferedCommentCids: {},\n lastCommentCids: {},\n nextCommentCidsToFetch: {},\n shouldFetchNextComment: {},\n\n addAuthorCommentsToStore: (\n authorCommentsName: string,\n authorAddress: string,\n commentCid: string,\n filter: CommentsFilter | undefined,\n account: Account,\n ) => {\n assert(\n authorCommentsName && typeof authorCommentsName === \"string\",\n `addAuthorCommentsToStore.incrementPageNumber invalid argument authorCommentsName '${authorCommentsName}'`,\n );\n assert(\n authorAddress && typeof authorAddress === \"string\",\n `authorsCommentsStore.addAuthorCommentsToStore invalid argument authorAddress '${authorAddress}'`,\n );\n assert(\n commentCid && typeof commentCid === \"string\",\n `authorsCommentsStore.addAuthorCommentsToStore invalid argument commentCid '${commentCid}'`,\n );\n assert(\n !filter || typeof filter?.filter === \"function\",\n `authorsCommentsStore.addAuthorCommentsToStore invalid argument filter.filter '${filter?.filter}'`,\n );\n assert(\n !filter || typeof filter?.key === \"string\",\n `authorsCommentsStore.addAuthorCommentsToStore invalid argument filter.key '${filter?.key}'`,\n );\n assert(\n typeof account?.pkc?.getComment === \"function\",\n `authorsCommentsStore.addAuthorCommentsToStore account '${account}' invalid`,\n );\n\n const { options, updateLoadedComments } = getState();\n // in store already, do nothing\n if (options[authorCommentsName]) {\n return;\n }\n const authorCommentsOptions = { authorAddress, pageNumber: 1, filter, accountId: account.id };\n\n // subscribe to nextCommentCidsToFetch and shouldFetchNextComment to fetch the comments\n authorsCommentsStore.subscribe(\n fetchCommentOnShouldFetchOrNextCidChange(authorCommentsOptions),\n );\n\n log(\"authorsCommentsActions.addAuthorCommentsToStore\", {\n authorCommentsName,\n authorCommentsOptions,\n commentCid,\n previousAuthorsCommentsOptions: options,\n });\n setState((state: AuthorsCommentsState) => ({\n options: { ...state.options, [authorCommentsName]: authorCommentsOptions },\n loadedComments: { ...state.loadedComments, [authorCommentsName]: [] },\n hasMoreBufferedComments: { ...state.hasMoreBufferedComments, [authorCommentsName]: true },\n bufferedCommentCids: {\n ...state.bufferedCommentCids,\n [authorAddress]: state.bufferedCommentCids[authorAddress] || new Set(),\n },\n lastCommentCids: {\n ...state.lastCommentCids,\n [authorAddress]: state.lastCommentCids[authorAddress] || undefined,\n },\n nextCommentCidsToFetch: {\n ...state.nextCommentCidsToFetch,\n [authorAddress]: state.nextCommentCidsToFetch[authorAddress] || commentCid,\n },\n shouldFetchNextComment: {\n ...state.shouldFetchNextComment,\n [authorAddress]: state.shouldFetchNextComment[authorAddress] || true,\n },\n }));\n\n // update loadedComments in case the author already has bufferedCommentCids\n updateLoadedComments();\n },\n\n setNextCommentCidsToFetch: (authorAddress: string, authorComment: Comment) => {\n assert(\n authorAddress && typeof authorAddress === \"string\",\n `authorsCommentsActions.setNextCommentCidsToFetch invalid argument authorAddress '${authorAddress}'`,\n );\n assert(\n typeof authorComment?.timestamp === \"number\",\n `authorsCommentsActions.setNextCommentCidsToFetch invalid argument authorComment '${authorComment}'`,\n );\n const { nextCommentCidsToFetch, shouldFetchNextComment, lastCommentCids } = getState();\n if (typeof shouldFetchNextComment[authorAddress] !== \"boolean\") {\n throw Error(\n `authorsCommentsActions.setNextCommentCidsToFetch can't set nextCommentCidToFetch '${authorAddress}' not in store`,\n );\n }\n const nextCommentCidToFetch = authorComment?.author?.previousCommentCid;\n if (nextCommentCidToFetch === nextCommentCidsToFetch[authorAddress]) {\n throw Error(\n `authorsCommentsActions.setNextCommentCidsToFetch can't set nextCommentCidToFetch '${authorAddress}' to '${nextCommentCidToFetch}' same value`,\n );\n }\n const nextCommentCidToFetchNotFetched =\n getNextCommentCidToFetchNotFetched(nextCommentCidToFetch);\n\n // log.trace('authorsCommentsActions.setNextCommentCidsToFetch', {\n // authorAddress,\n // authorComment,\n // previousNextCommentCidToFetch: nextCommentCidsToFetch[authorAddress],\n // nextCommentCidToFetch,\n // nextCommentCidToFetchNotFetched,\n // lastCommentCid: lastCommentCids[authorAddress],\n // shouldFetchNextComment: shouldFetchNextComment[authorAddress],\n // })\n setState((state: AuthorsCommentsState) => ({\n nextCommentCidsToFetch: {\n ...state.nextCommentCidsToFetch,\n [authorAddress]: nextCommentCidToFetchNotFetched,\n },\n }));\n },\n\n incrementPageNumber: (authorCommentsName: string) => {\n assert(\n authorCommentsName && typeof authorCommentsName === \"string\",\n `authorsCommentsActions.incrementPageNumber invalid argument authorCommentsName '${authorCommentsName}'`,\n );\n const { options, updateLoadedComments, loadedComments, nextCommentCidsToFetch } = getState();\n if (!options[authorCommentsName]) {\n throw Error(\n `authorsCommentsActions.incrementPageNumber can't increment page number of options '${authorCommentsName}' not in store`,\n );\n }\n assert(\n options[authorCommentsName].pageNumber * commentsPerPage <=\n loadedComments[authorCommentsName].length,\n `authorsCommentsActions.incrementPageNumber cannot increment page number before current page has loaded`,\n );\n\n log(\"authorsCommentsActions.incrementPageNumber\", {\n authorCommentsName,\n pageNumber: options[authorCommentsName].pageNumber + 1,\n nextCommentCidsToFetch: nextCommentCidsToFetch[options[authorCommentsName].authorAddress],\n });\n setState(({ options }: AuthorsCommentsState) => {\n const authorCommentOptions = { ...options[authorCommentsName] };\n authorCommentOptions.pageNumber++;\n return { options: { ...options, [authorCommentsName]: authorCommentOptions } };\n });\n\n // must update loadedComments to reflect the new added page\n updateLoadedComments();\n },\n\n addBufferedCommentCid: (authorAddress: string, commentCid: string) => {\n assert(\n authorAddress && typeof authorAddress === \"string\",\n `authorsCommentsActions.addBufferedCommentCid invalid argument authorAddress '${authorAddress}'`,\n );\n assert(\n commentCid && typeof commentCid === \"string\",\n `authorsCommentsActions.addBufferedCommentCid invalid argument commentCid '${commentCid}'`,\n );\n\n const { bufferedCommentCids } = getState();\n if (!bufferedCommentCids[authorAddress]) {\n throw Error(\n `authorsCommentsActions.addBufferedCommentCid can't add commentCid '${authorAddress}' not in store`,\n );\n }\n if (bufferedCommentCids[authorAddress].has(commentCid)) {\n throw Error(\n `authorsCommentsActions.addBufferedCommentCid can't add commentCid '${authorAddress}' '${commentCid}' already added`,\n );\n }\n\n // log.trace('authorsCommentsActions.addBufferedCommentCid', {authorAddress, commentCid, previousBufferedCommentCidsSize: bufferedCommentCids[authorAddress].size})\n setState((state: AuthorsCommentsState) => ({\n bufferedCommentCids: {\n ...state.bufferedCommentCids,\n [authorAddress]: new Set([...bufferedCommentCids[authorAddress], commentCid]),\n },\n }));\n },\n\n updateLoadedComments() {\n const { comments } = commentsStore.getState();\n let {\n loadedComments: previousAuthorsLoadedComments,\n bufferedCommentCids,\n options,\n nextCommentCidsToFetch,\n lastCommentCids,\n } = getState();\n\n const newAuthorsLoadedComments: AuthorsComments = {};\n const newShouldFetchNextComment: { [authorAddress: string]: boolean } = {};\n const newHasMoreBufferedComments: { [authorCommentsName: string]: boolean } = {};\n const authorCommentsNames = Object.keys(options);\n for (const name of authorCommentsNames) {\n const { authorAddress, pageNumber, filter } = options[name];\n const previousLoadedComments = previousAuthorsLoadedComments[name];\n const unfilteredBufferedComments: Comment[] = [...bufferedCommentCids[authorAddress]].map(\n (commentCid: string) => comments[commentCid],\n );\n\n const { loadedComments, bufferedComments: filteredBufferedComments } =\n getUpdatedLoadedAndBufferedComments(\n previousLoadedComments,\n unfilteredBufferedComments,\n pageNumber,\n filter,\n comments,\n );\n newAuthorsLoadedComments[name] = loadedComments;\n newHasMoreBufferedComments[name] = filteredBufferedComments.length > loadedComments.length;\n\n // if another authorCommentOptions should fetch, don't change it\n if (newShouldFetchNextComment[authorAddress] !== true) {\n // fetch if less comments than full page + buffer size\n newShouldFetchNextComment[authorAddress] =\n filteredBufferedComments.length < pageNumber * commentsPerPage + commentBufferSize;\n }\n }\n\n // log.trace('authorsCommentsActions.updateLoadedComments', {\n // bufferedCommentCids,\n // bufferedCommentCidsSizes: toSizes(bufferedCommentCids),\n // previousAuthorsLoadedComments,\n // newAuthorsLoadedComments,\n // previousAuthorsLoadedCommentsSizes: toSizes(previousAuthorsLoadedComments),\n // newAuthorsLoadedCommentsSizes: toSizes(newAuthorsLoadedComments),\n // newShouldFetchNextComment,\n // lastCommentCids\n // })\n setState(() => ({\n loadedComments: newAuthorsLoadedComments,\n shouldFetchNextComment: newShouldFetchNextComment,\n hasMoreBufferedComments: newHasMoreBufferedComments,\n }));\n },\n\n setLastCommentCid: (authorAddress: string, lastCommentCid: string) => {\n assert(\n authorAddress && typeof authorAddress === \"string\",\n `authorsCommentsActions.setLastCommentCid invalid argument authorAddress '${authorAddress}'`,\n );\n assert(\n lastCommentCid && typeof lastCommentCid === \"string\",\n `authorsCommentsActions.setLastCommentCid invalid argument lastCommentCid '${lastCommentCid}'`,\n );\n const { lastCommentCids, shouldFetchNextComment, nextCommentCidsToFetch } = getState();\n if (typeof shouldFetchNextComment[authorAddress] !== \"boolean\") {\n throw Error(\n `authorsCommentsActions.setLastCommentCid can't set lastCommentCid '${authorAddress}' not in store`,\n );\n }\n if (lastCommentCid === lastCommentCids[authorAddress]) {\n throw Error(\n `authorsCommentsActions.setLastCommentCid can't set setLastCommentCid '${authorAddress}' to '${lastCommentCid}' same value`,\n );\n }\n\n log(\"authorsCommentsActions.setLastCommentCid\", {\n authorAddress,\n lastCommentCid,\n previousLastCommentCid: lastCommentCids[authorAddress],\n shouldFetchNextComment: shouldFetchNextComment[authorAddress],\n nextCommentCidsToFetch: nextCommentCidsToFetch[authorAddress],\n });\n setState((state: AuthorsCommentsState) => ({\n lastCommentCids: { ...state.lastCommentCids, [authorAddress]: lastCommentCid },\n }));\n },\n }),\n);\n\n// if nextCommentCidsToFetch or shouldFetchNextComment changed, fetch the next comment\nconst fetchCommentOnShouldFetchOrNextCidChange =\n (options: AuthorCommentsOptions) => (state: AuthorsCommentsState) => {\n const nextCommentCidToFetch = state.nextCommentCidsToFetch[options.authorAddress];\n if (!nextCommentCidToFetch) {\n return;\n }\n\n // the buffered comments are already full, not need to fetch next comment\n const shouldFetchNextComment = state.shouldFetchNextComment[options.authorAddress];\n if (!shouldFetchNextComment) {\n return;\n }\n\n // when comment has fetched, update loadedComments, bufferedComments and shouldFetchNextComment\n if (!authorCommentCidsFetching[nextCommentCidToFetch]) {\n authorCommentCidsFetching[nextCommentCidToFetch] = true;\n commentsStore.subscribe(updateCommentsOnCommentsChange(options, nextCommentCidToFetch));\n }\n\n // start fetching comment\n const account = accountsStore.getState().accounts[options.accountId];\n const addCommentToStore = commentsStore.getState().addCommentToStore;\n addCommentToStore(nextCommentCidToFetch, account).catch((error: unknown) =>\n log.error(\n \"authorsCommentsStore fetchCommentOnShouldFetchOrNextCidChange addCommentToStore error\",\n { error, nextCommentCidToFetch, account },\n ),\n );\n };\n\n// if commentStore changed, update loadedComments, bufferedCommentCids, shouldFetchNextComment and nextCommentCidsToFetch\nlet previousComments = new QuickLru({ maxSize: 10000 });\nlet authorCommentCidsFetching: { [commentCid: string]: boolean } = {};\nlet communityLastCommentCidsFetching: { [commentCid: string]: boolean } = {};\nconst updateCommentsOnCommentsChange =\n (options: AuthorCommentsOptions, commentCid: string) => (state: CommentsState) => {\n // not a next cid, do nothing\n if (!authorCommentCidsFetching[commentCid]) {\n return;\n }\n const comment = state.comments[commentCid];\n // comment hasn't changed, do nothing\n if (!comment?.timestamp || comment === previousComments.get(commentCid)) {\n return;\n }\n // comment author address is incorrect, do nothing\n if (comment.author?.address !== options.authorAddress) {\n return;\n }\n previousComments.set(commentCid, comment);\n\n const {\n addBufferedCommentCid,\n bufferedCommentCids,\n updateLoadedComments,\n setNextCommentCidsToFetch,\n nextCommentCidsToFetch,\n } = authorsCommentsStore.getState();\n\n // the comment is a new comment, add it to buffered comment cids\n if (!bufferedCommentCids[options.authorAddress].has(commentCid)) {\n addBufferedCommentCid(options.authorAddress, commentCid);\n }\n\n // the comment was the last cid to fetch, set the next cid to fetch as the author previous cid\n const nextCidToFetch = nextCommentCidsToFetch[options.authorAddress];\n if (commentCid === nextCidToFetch) {\n setNextCommentCidsToFetch(options.authorAddress, comment);\n }\n\n // one of the comment changed, must update loaded comments\n updateLoadedComments();\n\n // the changed comment might have a new author.community.lastCommentCid, try to fetch it\n const communityLastCommentCid = comment.author?.community?.lastCommentCid;\n if (communityLastCommentCid) {\n // when last comment has fetched, update lastCommentCid\n if (!communityLastCommentCidsFetching[communityLastCommentCid]) {\n communityLastCommentCidsFetching[communityLastCommentCid] = true;\n commentsStore.subscribe(\n setLastCommentCidOnCommentsChange(options, communityLastCommentCid),\n );\n }\n\n // start fetching lastCommentCid\n const account = accountsStore.getState().accounts[options.accountId];\n state.addCommentToStore(communityLastCommentCid, account).catch((error: unknown) =>\n log.error(\"authorsCommentsStore updateCommentsOnCommentsChange addCommentToStore error\", {\n error,\n communityLastCommentCid,\n account,\n }),\n );\n }\n };\n\nlet previousLastComments = new QuickLru({ maxSize: 10000 });\nconst setLastCommentCidOnCommentsChange =\n (options: AuthorCommentsOptions, commentCid: string) => (state: CommentsState) => {\n // not a last cid candidate, do nothing\n if (!communityLastCommentCidsFetching[commentCid]) {\n return;\n }\n const { comments } = state;\n\n const comment = comments[commentCid];\n // comment hasn't changed, do nothing\n if (!comment?.timestamp || comment === previousLastComments.get(commentCid)) {\n return;\n }\n // comment author address is incorrect, do nothing\n if (comment.author?.address !== options.authorAddress) {\n return;\n }\n previousLastComments.set(commentCid, comment);\n\n const {\n addBufferedCommentCid,\n lastCommentCids,\n bufferedCommentCids,\n setLastCommentCid,\n setNextCommentCidsToFetch,\n updateLoadedComments,\n } = authorsCommentsStore.getState();\n\n // if the comment is a new comment, add it to buffered comment cids\n if (!bufferedCommentCids[options.authorAddress].has(commentCid)) {\n addBufferedCommentCid(options.authorAddress, commentCid);\n }\n\n // already last comment cid, no need to set it\n if (commentCid === lastCommentCids[options.authorAddress]) {\n return;\n }\n\n // if comment is newer than current lastCommentCid and all bufferedComments, is lastCommentCid\n const currentLastCommentCid = lastCommentCids[options.authorAddress];\n const currentLastComment = comments[currentLastCommentCid || \"\"];\n // comment is older or equal to current lastCommentCid, do nothing\n if (comment.timestamp <= (currentLastComment?.timestamp || 0)) {\n log.trace(\n `authorsCommentsStore setLastCommentCidOnCommentsChange don't set lastCommentCid older than current lastCommentCid`,\n { comment, currentLastComment },\n );\n return;\n }\n\n // make sure lastComment is newer than all comments already in bufferedComments\n const bufferedComments: Comment[] = [...bufferedCommentCids[options.authorAddress]].map(\n (commentCid: string) => comments[commentCid],\n );\n for (const bufferedComment of bufferedComments) {\n const bufferedTs =\n bufferedComment == null || bufferedComment.timestamp == null\n ? 0\n : bufferedComment.timestamp;\n if (bufferedTs > comment.timestamp) {\n log.trace(\n `authorsCommentsStore setLastCommentCidOnCommentsChange don't set lastCommentCid older than buffered comments`,\n {\n comment,\n currentLastComment,\n bufferedComments,\n },\n );\n return;\n }\n }\n\n // is last comment cid, set it\n log(`authorsCommentsStore setLastCommentCidOnCommentsChange`, {\n lastCommentCid: comment.cid,\n lastComment: comment,\n currentLastComment,\n bufferedComments,\n });\n setLastCommentCid(options.authorAddress, commentCid);\n // add the last comment to loadedComments\n updateLoadedComments();\n // start a new linked list of comments to fetch using the lastComment.author.previousCommentCid\n if (comment.author?.previousCommentCid) {\n setNextCommentCidsToFetch(options.authorAddress, comment);\n }\n };\n\n// reset store in between tests\nconst originalState = authorsCommentsStore.getState();\n// async function because some stores have async init\nexport const resetAuthorsCommentsStore = async () => {\n communityLastCommentCidsFetching = {};\n previousComments = new QuickLru({ maxSize: 10000 });\n authorCommentCidsFetching = {};\n previousLastComments = new QuickLru({ maxSize: 10000 });\n\n // destroy all component subscriptions to the store\n authorsCommentsStore.destroy();\n // restore original state\n authorsCommentsStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetAuthorsCommentsDatabaseAndStore = async () => {\n await resetAuthorsCommentsStore();\n};\n\nexport default authorsCommentsStore;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/stores/authors-comments/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,aAAa,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,mCAAmC,GAAG,CACjD,cAAyB,EACzB,gBAA2B,EAC3B,UAAkB,EAClB,MAAkC,EAClC,QAAkB,EAClB,EAAE;IACF,MAAM,mBAAmB,GAAG,0BAA0B,CACpD,cAAc,EACd,gBAAgB,EAChB,MAAM,EACN,QAAQ,CACT,CAAC;IAEF,yEAAyE;IACzE,IAAI,iBAAiB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,eAAe,CAAC,CAAC;IAEnF,uCAAuC;IACvC,oEAAoE;IACpE,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,iBAAiB,CAAC,EAAE,CAAC;QAC5D,iBAAiB,GAAG,cAAc,CAAC;IACrC,CAAC;IAED,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAAC;AACtF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,cAAyB,EACzB,gBAA2B,EAC3B,MAAkC,EAClC,QAAkB,EAClB,EAAE;IACF,mCAAmC;IACnC,MAAM,yBAAyB,GAAsC,EAAE,CAAC;IACxE,KAAK,MAAM,OAAO,IAAI,cAAc,EAAE,CAAC;QACrC,yBAAyB,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAChD,CAAC;IAED,4CAA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,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAChD,qBAAyC,EACzC,iBAA0B,EAC1B,EAAE;;IACF,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC;IAC9C,IAAI,+BAA+B,GAAG,qBAAqB,CAAC;IAC5D,+FAA+F;IAC/F,IAAI,UAAU,GAAG,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,QAAQ,CAAC;IAC/C,OAAO,IAAI,EAAE,CAAC;QACZ,yEAAyE;QACzE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YAClB,MAAM,KAAK,CAAC,uCAAuC,qBAAqB,iBAAiB,CAAC,CAAC;QAC7F,CAAC;QACD,MAAM,OAAO,GAAG,QAAQ,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA,EAAE,CAAC;YACxB,MAAM;QACR,CAAC;QACD,+BAA+B,GAAG,MAAA,OAAO,CAAC,MAAM,0CAAE,kBAAkB,CAAC;IACvE,CAAC;IACD,OAAO,+BAA+B,CAAC;AACzC,CAAC,CAAC;AAEF,oDAAoD;AACpD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAA2B,EAAE,EAAE;;IACrD,MAAM,MAAM,GAA8B,EAAE,CAAC;IAC7C,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAA,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,mCAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { Comment, Comments, CommentsFilter } from \"../../types\";\nimport { commentsPerPage } from \"./authors-comments-store\";\nimport assert from \"assert\";\nimport commentsStore from \"../comments\";\n\nexport const getUpdatedLoadedAndBufferedComments = (\n loadedComments: Comment[],\n bufferedComments: Comment[],\n pageNumber: number,\n filter: CommentsFilter | undefined,\n comments: Comments,\n) => {\n const newBufferedComments = getUpdatedBufferedComments(\n loadedComments,\n bufferedComments,\n filter,\n comments,\n );\n\n // create new loaded comments using the page number and buffered comments\n let newLoadedComments = newBufferedComments.slice(0, pageNumber * commentsPerPage);\n\n // check if loadedComments have changed\n // don't return a new object if there's no change, to avoid rerender\n if (!commentsHaveChanged(loadedComments, newLoadedComments)) {\n newLoadedComments = loadedComments;\n }\n\n return { loadedComments: newLoadedComments, bufferedComments: newBufferedComments };\n};\n\nexport const getUpdatedBufferedComments = (\n loadedComments: Comment[],\n bufferedComments: Comment[],\n filter: CommentsFilter | undefined,\n comments: Comments,\n) => {\n // get previous loaded comment cids\n const previousLoadedCommentCids: { [commentCid: string]: boolean } = {};\n for (const comment of loadedComments) {\n previousLoadedCommentCids[comment.cid] = true;\n }\n\n // get buffered comments without loaded cids\n let newBufferedComments = bufferedComments.filter(\n (comment) => !previousLoadedCommentCids[comment.cid],\n );\n\n // filter buffered comments\n if (filter) {\n newBufferedComments = newBufferedComments.filter(filter.filter);\n }\n\n // sort buffered comments by timestamp (newest first)\n newBufferedComments.sort((a, b) => b.timestamp - a.timestamp);\n\n // append the (new updated) loaded comments to buffered comments\n for (const comment of [...loadedComments].reverse()) {\n const updatedComment = comments[comment.cid];\n newBufferedComments.unshift(updatedComment);\n }\n\n // no need to check if comments have changed because getUpdatedBufferedComments\n // is not used anywhere outside of tests\n\n return newBufferedComments;\n};\n\nexport const commentsHaveChanged = (comments1: Comment[], comments2: Comment[]) => {\n if (comments1 === comments2) {\n return false;\n }\n if (comments1.length !== comments2.length) {\n return true;\n }\n for (const i in comments1) {\n if (comments1[i] !== comments2[i]) {\n return true;\n }\n }\n return false;\n};\n\n// if comment already exist, find the actual nextCidToFetch\n// can happen if a more recent lastCommentCid becomes nextCommentCidToFetch\nexport const getNextCommentCidToFetchNotFetched = (\n nextCommentCidToFetch: string | undefined,\n maxAttemptForTest?: number,\n) => {\n const { comments } = commentsStore.getState();\n let nextCommentCidToFetchNotFetched = nextCommentCidToFetch;\n // scroll through comments until the comment doesn't exist, which means hasn't been fetched yet\n let maxAttempt = maxAttemptForTest ?? 99999999;\n while (true) {\n // can't happen in production because of hashing, but can happen in tests\n if (!maxAttempt--) {\n throw Error(`getNextCommentCidToFetchNotFetched '${nextCommentCidToFetch}' infinite loop`);\n }\n const comment = comments[nextCommentCidToFetchNotFetched || \"\"];\n if (!comment?.timestamp) {\n break;\n }\n nextCommentCidToFetchNotFetched = comment.author?.previousCommentCid;\n }\n return nextCommentCidToFetchNotFetched;\n};\n\n// util for debugging sizes of object of arrays/sets\nexport const toSizes = (obj: { [key: string]: any }) => {\n const newObj: { [key: string]: number } = {};\n for (const i in obj) {\n newObj[i] = obj[i].length ?? obj[i].size;\n }\n return newObj;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/stores/authors-comments/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,aAAa,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,mCAAmC,GAAG,CACjD,cAAyB,EACzB,gBAA2B,EAC3B,UAAkB,EAClB,MAAkC,EAClC,QAAkB,EAClB,EAAE;IACF,MAAM,mBAAmB,GAAG,0BAA0B,CACpD,cAAc,EACd,gBAAgB,EAChB,MAAM,EACN,QAAQ,CACT,CAAC;IAEF,yEAAyE;IACzE,IAAI,iBAAiB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,eAAe,CAAC,CAAC;IAEnF,uCAAuC;IACvC,oEAAoE;IACpE,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,iBAAiB,CAAC,EAAE,CAAC;QAC5D,iBAAiB,GAAG,cAAc,CAAC;IACrC,CAAC;IAED,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE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AAI,GAAG,EAAE,CAAC;QACpB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAA,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,mCAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { Comment, Comments, CommentsFilter } from \"../../types\";\nimport { commentsPerPage } from \"./authors-comments-store\";\nimport assert from \"../../lib/assert\";\nimport commentsStore from \"../comments\";\n\nexport const getUpdatedLoadedAndBufferedComments = (\n loadedComments: Comment[],\n bufferedComments: Comment[],\n pageNumber: number,\n filter: CommentsFilter | undefined,\n comments: Comments,\n) => {\n const newBufferedComments = getUpdatedBufferedComments(\n loadedComments,\n bufferedComments,\n filter,\n comments,\n );\n\n // create new loaded comments using the page number and buffered comments\n let newLoadedComments = newBufferedComments.slice(0, pageNumber * commentsPerPage);\n\n // check if loadedComments have changed\n // don't return a new object if there's no change, to avoid rerender\n if (!commentsHaveChanged(loadedComments, newLoadedComments)) {\n newLoadedComments = loadedComments;\n }\n\n return { loadedComments: newLoadedComments, bufferedComments: newBufferedComments };\n};\n\nexport const getUpdatedBufferedComments = (\n loadedComments: Comment[],\n bufferedComments: Comment[],\n filter: CommentsFilter | undefined,\n comments: Comments,\n) => {\n // get previous loaded comment cids\n const previousLoadedCommentCids: { [commentCid: string]: boolean } = {};\n for (const comment of loadedComments) {\n previousLoadedCommentCids[comment.cid] = true;\n }\n\n // get buffered comments without loaded cids\n let newBufferedComments = bufferedComments.filter(\n (comment) => !previousLoadedCommentCids[comment.cid],\n );\n\n // filter buffered comments\n if (filter) {\n newBufferedComments = newBufferedComments.filter(filter.filter);\n }\n\n // sort buffered comments by timestamp (newest first)\n newBufferedComments.sort((a, b) => b.timestamp - a.timestamp);\n\n // append the (new updated) loaded comments to buffered comments\n for (const comment of [...loadedComments].reverse()) {\n const updatedComment = comments[comment.cid];\n newBufferedComments.unshift(updatedComment);\n }\n\n // no need to check if comments have changed because getUpdatedBufferedComments\n // is not used anywhere outside of tests\n\n return newBufferedComments;\n};\n\nexport const commentsHaveChanged = (comments1: Comment[], comments2: Comment[]) => {\n if (comments1 === comments2) {\n return false;\n }\n if (comments1.length !== comments2.length) {\n return true;\n }\n for (const i in comments1) {\n if (comments1[i] !== comments2[i]) {\n return true;\n }\n }\n return false;\n};\n\n// if comment already exist, find the actual nextCidToFetch\n// can happen if a more recent lastCommentCid becomes nextCommentCidToFetch\nexport const getNextCommentCidToFetchNotFetched = (\n nextCommentCidToFetch: string | undefined,\n maxAttemptForTest?: number,\n) => {\n const { comments } = commentsStore.getState();\n let nextCommentCidToFetchNotFetched = nextCommentCidToFetch;\n // scroll through comments until the comment doesn't exist, which means hasn't been fetched yet\n let maxAttempt = maxAttemptForTest ?? 99999999;\n while (true) {\n // can't happen in production because of hashing, but can happen in tests\n if (!maxAttempt--) {\n throw Error(`getNextCommentCidToFetchNotFetched '${nextCommentCidToFetch}' infinite loop`);\n }\n const comment = comments[nextCommentCidToFetchNotFetched || \"\"];\n if (!comment?.timestamp) {\n break;\n }\n nextCommentCidToFetchNotFetched = comment.author?.previousCommentCid;\n }\n return nextCommentCidToFetchNotFetched;\n};\n\n// util for debugging sizes of object of arrays/sets\nexport const toSizes = (obj: { [key: string]: any }) => {\n const newObj: { [key: string]: number } = {};\n for (const i in obj) {\n newObj[i] = obj[i].length ?? obj[i].size;\n }\n return newObj;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communities-store.d.ts","sourceRoot":"","sources":["../../../src/stores/communities/communities-store.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,WAAW,EAGX,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAcrB,eAAO,MAAM,4BAA4B,QAAiB,CAAC;AAmB3D,UAAU,mBAAmB;IAC3B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;
|
|
1
|
+
{"version":3,"file":"communities-store.d.ts","sourceRoot":"","sources":["../../../src/stores/communities/communities-store.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,WAAW,EAGX,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAcrB,eAAO,MAAM,4BAA4B,QAAiB,CAAC;AAmB3D,UAAU,mBAAmB;IAC3B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAyID,eAAO,MAAM,6BAA6B,GAAI,OAAO,KAAK,YAQzD,CAAC;AAoCF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE;QAAE,CAAC,gBAAgB,EAAE,MAAM,GAAG,KAAK,EAAE,CAAA;KAAE,CAAC;IAChD,YAAY,EAAE;QAAE,CAAC,gBAAgB,EAAE,MAAM,GAAG,mBAAmB,CAAA;KAAE,CAAC;IAClE,mBAAmB,EAAE,QAAQ,CAAC;IAC9B,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,aAAa,EAAE,QAAQ,CAAC;IACxB,eAAe,EAAE,QAAQ,CAAC;IAC1B,eAAe,EAAE,QAAQ,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAM,gBAAgB,+EA+ZrB,CAAC;AAKF,eAAO,MAAM,qBAAqB,qBAWjC,CAAC;AAGF,eAAO,MAAM,gCAAgC,qBAG5C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import assert from "assert";
|
|
10
|
+
import assert from "../../lib/assert.js";
|
|
11
11
|
import localForageLru from "../../lib/localforage-lru/index.js";
|
|
12
12
|
const communitiesDatabase = localForageLru.createInstance({
|
|
13
13
|
name: "bitsocialReactHooks-communities",
|
|
@@ -39,13 +39,23 @@ const normalizeCommunitySyncState = (updatingState) => {
|
|
|
39
39
|
}
|
|
40
40
|
return "loading";
|
|
41
41
|
};
|
|
42
|
+
const getNextSyncStatuses = (state, communityKey, syncState) => {
|
|
43
|
+
const previousStatus = state.syncStatuses[communityKey];
|
|
44
|
+
const timestamp = getNowSeconds();
|
|
45
|
+
const shouldRecordAttempt = syncState === "loading" && (previousStatus === null || previousStatus === void 0 ? void 0 : previousStatus.syncState) !== "loading";
|
|
46
|
+
return Object.assign(Object.assign({}, state.syncStatuses), { [communityKey]: Object.assign(Object.assign(Object.assign(Object.assign({}, previousStatus), { syncState }), (shouldRecordAttempt ? { lastFetchAttemptAt: timestamp } : undefined)), (syncState === "succeeded" ? { lastSuccessfulFetchAt: timestamp } : undefined)) });
|
|
47
|
+
};
|
|
42
48
|
const updateCommunitySyncStatus = (setState, communityKey, syncState) => {
|
|
43
|
-
setState((state) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
setState((state) => (Object.assign(Object.assign({}, state), { syncStatuses: getNextSyncStatuses(state, communityKey, syncState) })));
|
|
50
|
+
};
|
|
51
|
+
// identifies a signed community record, to recognize pkc-js re-emitting a record already in the store
|
|
52
|
+
const getCommunityRecordId = (community) => {
|
|
53
|
+
var _a;
|
|
54
|
+
const signature = (_a = community === null || community === void 0 ? void 0 : community.signature) === null || _a === void 0 ? void 0 : _a.signature;
|
|
55
|
+
if (typeof signature !== "string" || typeof (community === null || community === void 0 ? void 0 : community.updatedAt) !== "number") {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
return `${community.updatedAt}:${signature}`;
|
|
49
59
|
};
|
|
50
60
|
const createCommunityWithLookupFallback = (pkc, communityLookupOptions, communityKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
61
|
const supportsAddressLookup = "address" in communityLookupOptions;
|
|
@@ -98,6 +108,9 @@ const clearStoredCommunityErrors = (state, communityKey) => {
|
|
|
98
108
|
delete nextErrors[communityKey];
|
|
99
109
|
return nextErrors;
|
|
100
110
|
};
|
|
111
|
+
// returning the same state skips notifying subscribers when there is nothing to clear
|
|
112
|
+
const clearStoredCommunityErrorsState = (state, communityKey) => state.errors[communityKey]
|
|
113
|
+
? Object.assign(Object.assign({}, state), { errors: clearStoredCommunityErrors(state, communityKey) }) : state;
|
|
101
114
|
export const isRetriableCommunityLoadError = (error) => {
|
|
102
115
|
const details = error.details;
|
|
103
116
|
return Boolean(details &&
|
|
@@ -167,6 +180,7 @@ const communitiesStore = createStore((setState, getState) => ({
|
|
|
167
180
|
}
|
|
168
181
|
// try to find community in database
|
|
169
182
|
let fetchedAt;
|
|
183
|
+
let isFromCache = false;
|
|
170
184
|
if (!community) {
|
|
171
185
|
const communityData = yield communitiesDatabase.getItem(communityKey);
|
|
172
186
|
const lookupName = "name" in communityLookupOptions ? communityLookupOptions.name : undefined;
|
|
@@ -189,6 +203,7 @@ const communitiesStore = createStore((setState, getState) => ({
|
|
|
189
203
|
delete communityData.fetchedAt; // not part of pkc-js schema
|
|
190
204
|
try {
|
|
191
205
|
community = yield createPkcCommunity(account.pkc, communityData);
|
|
206
|
+
isFromCache = Boolean(community);
|
|
192
207
|
}
|
|
193
208
|
catch (e) {
|
|
194
209
|
fetchedAt = undefined;
|
|
@@ -227,7 +242,11 @@ const communitiesStore = createStore((setState, getState) => ({
|
|
|
227
242
|
}
|
|
228
243
|
// success getting community
|
|
229
244
|
const firstCommunityState = utils.clone(Object.assign(Object.assign({}, community), (fetchedAt !== undefined ? { fetchedAt } : undefined)));
|
|
230
|
-
|
|
245
|
+
// a cache hit already is the database entry, rewriting it would only delay the store
|
|
246
|
+
// update behind an IndexedDB write of the whole record
|
|
247
|
+
if (!isFromCache) {
|
|
248
|
+
yield communitiesDatabase.setItem(communityKey, firstCommunityState);
|
|
249
|
+
}
|
|
231
250
|
log("communitiesStore.addCommunityToStore", {
|
|
232
251
|
communityAddressOrRef,
|
|
233
252
|
communityKey,
|
|
@@ -237,10 +256,33 @@ const communitiesStore = createStore((setState, getState) => ({
|
|
|
237
256
|
setState((state) => ({
|
|
238
257
|
communities: Object.assign(Object.assign({}, state.communities), { [communityKey]: firstCommunityState }),
|
|
239
258
|
}));
|
|
259
|
+
// pkc-js re-emits the record a community was created with when update() starts
|
|
260
|
+
let cachedRecordId = isFromCache ? getCommunityRecordId(firstCommunityState) : undefined;
|
|
240
261
|
// the community has published new posts
|
|
241
262
|
community.on("update", (updatedCommunity) => __awaiter(this, void 0, void 0, function* () {
|
|
242
263
|
clearPendingCommunityErrors(communityKey);
|
|
243
|
-
setState((state) => (
|
|
264
|
+
setState((state) => clearStoredCommunityErrorsState(state, communityKey));
|
|
265
|
+
const isCachedRecordReplay = cachedRecordId !== undefined &&
|
|
266
|
+
getCommunityRecordId(updatedCommunity) === cachedRecordId;
|
|
267
|
+
cachedRecordId = undefined;
|
|
268
|
+
if (isCachedRecordReplay) {
|
|
269
|
+
// the replayed record is already in the store and the database, only refresh fetchedAt
|
|
270
|
+
// like a fetched update would, without cloning and rewriting the whole record
|
|
271
|
+
setState((state) => {
|
|
272
|
+
const storedCommunity = state.communities[communityKey];
|
|
273
|
+
if (!storedCommunity) {
|
|
274
|
+
return state;
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
communities: Object.assign(Object.assign({}, state.communities), { [communityKey]: Object.assign(Object.assign({}, storedCommunity), { fetchedAt: getNowSeconds() }) }),
|
|
278
|
+
};
|
|
279
|
+
});
|
|
280
|
+
// pass the cloned record, account state keeps references to its roles
|
|
281
|
+
accountsStore
|
|
282
|
+
.getState()
|
|
283
|
+
.accountsActionsInternal.addCommunityRoleToAccountsCommunities(firstCommunityState);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
244
286
|
updatedCommunity = utils.clone(updatedCommunity);
|
|
245
287
|
// add fetchedAt to be able to expire the cache
|
|
246
288
|
// NOTE: fetchedAt is undefined on owner communities because never stale
|
|
@@ -261,8 +303,8 @@ const communitiesStore = createStore((setState, getState) => ({
|
|
|
261
303
|
communitiesPagesStore.getState().addCommunityPageCommentsToStore(updatedCommunity);
|
|
262
304
|
}));
|
|
263
305
|
community.on("updatingstatechange", (updatingState) => {
|
|
264
|
-
updateCommunitySyncStatus(setState, communityKey, normalizeCommunitySyncState(updatingState));
|
|
265
306
|
setState((state) => ({
|
|
307
|
+
syncStatuses: getNextSyncStatuses(state, communityKey, normalizeCommunitySyncState(updatingState)),
|
|
266
308
|
communities: Object.assign(Object.assign({}, state.communities), { [communityKey]: Object.assign(Object.assign({}, state.communities[communityKey]), { updatingState }) }),
|
|
267
309
|
}));
|
|
268
310
|
});
|
|
@@ -275,7 +317,7 @@ const communitiesStore = createStore((setState, getState) => ({
|
|
|
275
317
|
var _a;
|
|
276
318
|
// make sure not undefined, sometimes happens in e2e tests
|
|
277
319
|
if (!state.communities[communityKey]) {
|
|
278
|
-
return
|
|
320
|
+
return state;
|
|
279
321
|
}
|
|
280
322
|
const clients = Object.assign({}, (_a = state.communities[communityKey]) === null || _a === void 0 ? void 0 : _a.clients);
|
|
281
323
|
const client = { state: clientState };
|