@bitsocial/bitsocial-react-hooks 0.1.30 → 0.1.32

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +24 -7
  3. package/dist/hooks/comments.d.ts.map +1 -1
  4. package/dist/hooks/comments.js +5 -1
  5. package/dist/hooks/comments.js.map +1 -1
  6. package/dist/hooks/communities.d.ts.map +1 -1
  7. package/dist/hooks/communities.js +2 -1
  8. package/dist/hooks/communities.js.map +1 -1
  9. package/dist/hooks/replies.d.ts.map +1 -1
  10. package/dist/hooks/replies.js +6 -3
  11. package/dist/hooks/replies.js.map +1 -1
  12. package/dist/lib/utils/optimistic-vote-counts.d.ts +11 -0
  13. package/dist/lib/utils/optimistic-vote-counts.d.ts.map +1 -0
  14. package/dist/lib/utils/optimistic-vote-counts.js +70 -0
  15. package/dist/lib/utils/optimistic-vote-counts.js.map +1 -0
  16. package/dist/stores/accounts/accounts-actions.d.ts.map +1 -1
  17. package/dist/stores/accounts/accounts-actions.js +9 -2
  18. package/dist/stores/accounts/accounts-actions.js.map +1 -1
  19. package/dist/stores/accounts/utils.d.ts +2 -0
  20. package/dist/stores/accounts/utils.d.ts.map +1 -1
  21. package/dist/stores/accounts/utils.js +15 -0
  22. package/dist/stores/accounts/utils.js.map +1 -1
  23. package/dist/stores/communities/communities-store.d.ts +9 -1
  24. package/dist/stores/communities/communities-store.d.ts.map +1 -1
  25. package/dist/stores/communities/communities-store.js +36 -3
  26. package/dist/stores/communities/communities-store.js.map +1 -1
  27. package/dist/stores/replies/replies-store.d.ts.map +1 -1
  28. package/dist/stores/replies/replies-store.js +12 -8
  29. package/dist/stores/replies/replies-store.js.map +1 -1
  30. package/dist/stores/replies/utils.d.ts.map +1 -1
  31. package/dist/stores/replies/utils.js +6 -13
  32. package/dist/stores/replies/utils.js.map +1 -1
  33. package/dist/types.d.ts +5 -0
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/types.js.map +1 -1
  36. package/package.json +22 -11
@@ -23,6 +23,7 @@ export declare const getInitAccountCommentsToUpdate: (accountsComments: Accounts
23
23
  accountId: string;
24
24
  }[];
25
25
  export declare const getAccountCommentDepth: (comment: Comment) => number | undefined;
26
+ export declare const getFreshestLoadedComment: (commentCid: string, ...additionalCandidates: (Comment | undefined)[]) => Comment | undefined;
26
27
  export declare const addShortAddressesToAccountComment: (comment: Comment) => Comment;
27
28
  declare const utils: {
28
29
  getAccountCommunities: (account: Account, communities: Communities) => any;
@@ -43,6 +44,7 @@ declare const utils: {
43
44
  accountId: string;
44
45
  }[];
45
46
  getAccountCommentDepth: (comment: Comment) => number | undefined;
47
+ getFreshestLoadedComment: (commentCid: string, ...additionalCandidates: (Comment | undefined)[]) => Comment | undefined;
46
48
  addShortAddressesToAccountComment: (comment: Comment) => Comment;
47
49
  promiseAny: <T>(promises: Promise<T>[]) => Promise<T>;
48
50
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,EAC7B,OAAO,EACP,WAAW,EACX,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAoBrB,eAAO,MAAM,qBAAqB,GAAI,SAAS,OAAO,EAAE,aAAa,WAAW,QAiB/E,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAAI,kBAAkB,gBAAgB,kCAalF,CAAC;AA0FF,eAAO,MAAM,8BAA8B,GAAI,SAAS,OAAO,QAuB9D,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,SAAS,OAAO,QAoB5D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,iBAAiB,cAAc,EAAE,GAAG,SAAS,KAC5C,oBAoBF,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,kBAA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AAEF,eAAO,MAAM,sBAAsB,GAAI,SAAS,OAAO,uBAkBtD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,YAAY,MAAM,EAClB,GAAG,sBAAsB,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,KAC/C,OAAO,GAAG,SAeZ,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAAI,SAAS,OAAO,YAcjE,CAAC;AAEF,QAAA,MAAM,KAAK;qCA1eoC,OAAO,eAAe,WAAW;yDAmBb,gBAAgB;+CAuJhE,cAAc,EAAE,GAAG,SAAS,KAC5C,oBAAoB;mDAsBsC,gBAAgB;8CAvErB,OAAO;4CAyBT,OAAO;kDAsFD,WAAW,EAAE,GAAG,SAAS;;;4CAwB/B;QACpD,CAAC,4BAA4B,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;KACvD;uCA4BsD,MAAM,KAAG,OAAO,CAAC,qBAAqB,CAAC;uDA8H7B,gBAAgB;wBAC9B,cAAc;mBAAa,MAAM;;sCAoBpC,OAAO;2CAqBzC,MAAM,2BACO,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,KAC/C,OAAO,GAAG,SAAS;iDAiBqC,OAAO;iBAxM9C,CAAC,YAAY,OAAO,CAAC,CAAC,CAAC,EAAE,KAAG,OAAO,CAAC,CAAC,CAAC;CAuOzD,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -24,7 +24,9 @@ const log = Logger("bitsocial-react-hooks:accounts:stores");
24
24
  import commentsStore from "../comments/index.js";
25
25
  import repliesPagesStore from "../replies-pages/index.js";
26
26
  import communitiesPagesStore from "../communities-pages/index.js";
27
+ import repliesCommentsStore from "../replies/replies-comments-store.js";
27
28
  import PkcJs from "../../lib/pkc-js/index.js";
29
+ import { getCommentVoteCountsVersion } from "../../lib/utils/optimistic-vote-counts.js";
28
30
  const getAuthorAddressRolesFromCommunities = (authorAddress, communities) => {
29
31
  var _a, _b;
30
32
  const roles = {};
@@ -401,6 +403,18 @@ export const getAccountCommentDepth = (comment) => {
401
403
  // if can't find the parent comment depth anywhere, don't include it with the account comment
402
404
  // it will be added automatically when challenge verification is received
403
405
  };
406
+ export const getFreshestLoadedComment = (commentCid, ...additionalCandidates) => {
407
+ const candidates = [
408
+ commentsStore.getState().comments[commentCid],
409
+ repliesPagesStore.getState().comments[commentCid],
410
+ communitiesPagesStore.getState().comments[commentCid],
411
+ repliesCommentsStore.getState().comments[commentCid],
412
+ ...additionalCandidates,
413
+ ];
414
+ return candidates.reduce((freshest, candidate) => getCommentVoteCountsVersion(candidate) > getCommentVoteCountsVersion(freshest)
415
+ ? candidate
416
+ : freshest, undefined);
417
+ };
404
418
  export const addShortAddressesToAccountComment = (comment) => {
405
419
  comment = Object.assign({}, comment);
406
420
  try {
@@ -430,6 +444,7 @@ const utils = {
430
444
  fetchCommentLinkDimensions,
431
445
  getInitAccountCommentsToUpdate,
432
446
  getAccountCommentDepth,
447
+ getFreshestLoadedComment,
433
448
  addShortAddressesToAccountComment,
434
449
  promiseAny,
435
450
  };
@@ -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,KAAK,MAAM,kBAAkB,CAAC;AAErC,MAAM,oCAAoC,GAAG,CAAC,aAAqB,EAAE,WAAwB,EAAE,EAAE;;IAC/F,MAAM,KAAK,GAAyC,EAAE,CAAC;IACvD,KAAK,MAAM,gBAAgB,IAAI,WAAW,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAA,MAAA,WAAW,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\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 PkcJs from \"../../lib/pkc-js\";\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 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 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,QAAQ,CAAC;AAC5B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,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KACxB,CAAC;IACF,OAAO,UAAU,CAAC,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 \"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,10 +1,18 @@
1
- import { Communities } from "../../types.js";
1
+ import { Communities, CommunitySyncState } from "../../types.js";
2
2
  export declare const COMMUNITY_UPDATE_INTERVAL_MS: number;
3
+ interface CommunitySyncStatus {
4
+ syncState: CommunitySyncState;
5
+ lastFetchAttemptAt?: number;
6
+ lastSuccessfulFetchAt?: number;
7
+ }
3
8
  export type CommunitiesState = {
4
9
  communities: Communities;
5
10
  errors: {
6
11
  [communityAddress: string]: Error[];
7
12
  };
13
+ syncStatuses: {
14
+ [communityAddress: string]: CommunitySyncStatus;
15
+ };
8
16
  addCommunityToStore: Function;
9
17
  refreshCommunity: Function;
10
18
  editCommunity: Function;
@@ -1 +1 @@
1
- {"version":3,"file":"communities-store.d.ts","sourceRoot":"","sources":["../../../src/stores/communities/communities-store.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,WAAW,EAIZ,MAAM,aAAa,CAAC;AAcrB,eAAO,MAAM,4BAA4B,QAAiB,CAAC;AA6I3D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE;QAAE,CAAC,gBAAgB,EAAE,MAAM,GAAG,KAAK,EAAE,CAAA;KAAE,CAAC;IAChD,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,+EA0WrB,CAAC;AAKF,eAAO,MAAM,qBAAqB,qBAWjC,CAAC;AAGF,eAAO,MAAM,gCAAgC,qBAG5C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
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;AAgKD,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,+EA4XrB,CAAC;AAKF,eAAO,MAAM,qBAAqB,qBAWjC,CAAC;AAGF,eAAO,MAAM,gCAAgC,qBAG5C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -29,6 +29,24 @@ const communityUpdatePollers = {};
29
29
  const listeners = [];
30
30
  const COMMUNITY_ERROR_UPDATE_GRACE_MS = 1000;
31
31
  const pendingCommunityErrorTimers = {};
32
+ const getNowSeconds = () => Math.floor(Date.now() / 1000);
33
+ const normalizeCommunitySyncState = (updatingState) => {
34
+ if (updatingState === "waiting-retry") {
35
+ return "retrying";
36
+ }
37
+ if (updatingState === "succeeded" || updatingState === "failed" || updatingState === "stopped") {
38
+ return updatingState;
39
+ }
40
+ return "loading";
41
+ };
42
+ const updateCommunitySyncStatus = (setState, communityKey, syncState) => {
43
+ setState((state) => {
44
+ const previousStatus = state.syncStatuses[communityKey];
45
+ const timestamp = getNowSeconds();
46
+ const shouldRecordAttempt = syncState === "loading" && (previousStatus === null || previousStatus === void 0 ? void 0 : previousStatus.syncState) !== "loading";
47
+ return Object.assign(Object.assign({}, state), { syncStatuses: 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)) }) });
48
+ });
49
+ };
32
50
  const createCommunityWithLookupFallback = (pkc, communityLookupOptions, communityKey) => __awaiter(void 0, void 0, void 0, function* () {
33
51
  const supportsAddressLookup = "address" in communityLookupOptions;
34
52
  const community = yield createPkcCommunity(pkc, communityLookupOptions);
@@ -116,6 +134,7 @@ const scheduleCommunityError = (setState, communityKey, error) => {
116
134
  const communitiesStore = createStore((setState, getState) => ({
117
135
  communities: {},
118
136
  errors: {},
137
+ syncStatuses: {},
119
138
  addCommunityToStore(communityAddressOrRef, account) {
120
139
  return __awaiter(this, void 0, void 0, function* () {
121
140
  var _a, _b;
@@ -134,6 +153,7 @@ const communitiesStore = createStore((setState, getState) => ({
134
153
  }
135
154
  // start trying to get community
136
155
  pkcGetCommunityPending[pendingKey] = true;
156
+ updateCommunitySyncStatus(setState, communityKey, "initializing");
137
157
  let errorGettingCommunity;
138
158
  try {
139
159
  // try to find community in owner communities
@@ -241,6 +261,7 @@ const communitiesStore = createStore((setState, getState) => ({
241
261
  communitiesPagesStore.getState().addCommunityPageCommentsToStore(updatedCommunity);
242
262
  }));
243
263
  community.on("updatingstatechange", (updatingState) => {
264
+ updateCommunitySyncStatus(setState, communityKey, normalizeCommunitySyncState(updatingState));
244
265
  setState((state) => ({
245
266
  communities: Object.assign(Object.assign({}, state.communities), { [communityKey]: Object.assign(Object.assign({}, state.communities[communityKey]), { updatingState }) }),
246
267
  }));
@@ -273,6 +294,10 @@ const communitiesStore = createStore((setState, getState) => ({
273
294
  listeners.push(community);
274
295
  startCommunityUpdatePolling(community, { communityAddressOrRef, communityKey });
275
296
  }
297
+ catch (error) {
298
+ updateCommunitySyncStatus(setState, communityKey, "failed");
299
+ throw error;
300
+ }
276
301
  finally {
277
302
  pkcGetCommunityPending[pendingKey] = false;
278
303
  }
@@ -369,9 +394,17 @@ const communitiesStore = createStore((setState, getState) => ({
369
394
  stopCommunityUpdatePolling(communityAddress);
370
395
  yield communitiesDatabase.removeItem(communityAddress);
371
396
  log("communitiesStore.deleteCommunity", { communityAddress, community, account });
372
- setState((state) => ({
373
- communities: Object.assign(Object.assign({}, state.communities), { [communityAddress]: undefined }),
374
- }));
397
+ setState((state) => {
398
+ const syncStatuses = Object.assign({}, state.syncStatuses);
399
+ delete syncStatuses[communityAddress];
400
+ const errors = Object.assign({}, state.errors);
401
+ delete errors[communityAddress];
402
+ return {
403
+ communities: Object.assign(Object.assign({}, state.communities), { [communityAddress]: undefined }),
404
+ errors,
405
+ syncStatuses,
406
+ };
407
+ });
375
408
  });
376
409
  },
377
410
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"communities-store.js","sourceRoot":"","sources":["../../../src/stores/communities/communities-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,MAAM,mBAAmB,GAAG,cAAc,CAAC,cAAc,CAAC;IACxD,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE,GAAG;CACV,CAAC,CAAC;AACH,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,0CAA0C,CAAC,CAAC;AAQ/D,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,aAAa,MAAM,aAAa,CAAC;AAC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AC,gBAAgB,CAAC,EAAE,SAAS,GAAE;aACrE,CAAC,CAAC,CAAC;QACN,CAAC;KAAA;CACF,CAAC,CACH,CAAC;AAEF,+BAA+B;AAC/B,MAAM,aAAa,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC;AAClD,qDAAqD;AACrD,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAS,EAAE;IAC9C,sBAAsB,GAAG,EAAE,CAAC;IAC5B,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC9E,6BAA6B;IAC7B,SAAS,CAAC,OAAO,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACpE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACxE,mDAAmD;IACnD,gBAAgB,CAAC,OAAO,EAAE,CAAC;IAC3B,yBAAyB;IACzB,gBAAgB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC3C,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAS,EAAE;IACzD,MAAM,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,iCAAiC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IACzF,MAAM,qBAAqB,EAAE,CAAC;AAChC,CAAC,CAAA,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import assert from \"assert\";\nimport localForageLru from \"../../lib/localforage-lru\";\nconst communitiesDatabase = localForageLru.createInstance({\n name: \"bitsocialReactHooks-communities\",\n size: 500,\n});\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:communities:stores\");\nimport {\n Community,\n Communities,\n Account,\n CommunityIdentifier,\n CreateCommunityOptions,\n} from \"../../types\";\nimport utils from \"../../lib/utils\";\nimport createStore from \"zustand\";\nimport accountsStore from \"../accounts\";\nimport communitiesPagesStore from \"../communities-pages\";\nimport { getCommunityLookupOptions, getCommunityRefKey } from \"../../lib/community-ref\";\nimport {\n createPkcCommunity,\n getPkcCommunity,\n getPkcCommunityAddresses,\n getPkcCreateCommunity,\n getPkcGetCommunity,\n} from \"../../lib/pkc-compat\";\n\nexport const COMMUNITY_UPDATE_INTERVAL_MS = 15 * 60 * 1000;\n\nlet pkcGetCommunityPending: { [key: string]: boolean } = {};\n// Key pollers by community so delete/reset can stop the matching live instance.\nconst communityUpdatePollers: {\n [communityKey: string]: {\n community: any;\n updateInterval: ReturnType<typeof setInterval>;\n };\n} = {};\n\n// reset all event listeners in between tests\nconst listeners: any = [];\n\nconst COMMUNITY_ERROR_UPDATE_GRACE_MS = 1000;\nconst pendingCommunityErrorTimers: {\n [communityKey: string]: ReturnType<typeof setTimeout>[];\n} = {};\n\nconst createCommunityWithLookupFallback = async (\n pkc: any,\n communityLookupOptions: { address?: string; name?: string; publicKey?: string },\n communityKey: string,\n) => {\n const supportsAddressLookup = \"address\" in communityLookupOptions;\n const community = await createPkcCommunity(pkc, communityLookupOptions);\n if (community?.address || supportsAddressLookup) {\n return community;\n }\n throw Error(`communitiesStore.addCommunityToStore failed getting community '${communityKey}'`);\n};\n\nconst updateCommunity = (\n community: Community,\n {\n communityAddressOrRef,\n communityKey,\n }: { communityAddressOrRef: string | CommunityIdentifier; communityKey: string },\n) => {\n community.update().catch((error: unknown) =>\n log.trace(\"community.update error\", {\n communityAddressOrRef,\n communityKey,\n community,\n error,\n }),\n );\n};\n\nconst startCommunityUpdatePolling = (\n community: Community,\n {\n communityAddressOrRef,\n communityKey,\n }: { communityAddressOrRef: string | CommunityIdentifier; communityKey: string },\n) => {\n stopCommunityUpdatePolling(communityKey);\n updateCommunity(community, { communityAddressOrRef, communityKey });\n communityUpdatePollers[communityKey] = {\n community,\n updateInterval: setInterval(\n () => updateCommunity(community, { communityAddressOrRef, communityKey }),\n COMMUNITY_UPDATE_INTERVAL_MS,\n ),\n };\n};\n\nconst stopCommunityUpdatePolling = (communityKey: string) => {\n const polling = communityUpdatePollers[communityKey];\n if (!polling) {\n return;\n }\n\n clearPendingCommunityErrors(communityKey);\n clearInterval(polling.updateInterval);\n polling.community.removeAllListeners();\n const listenerIndex = listeners.indexOf(polling.community);\n if (listenerIndex >= 0) {\n listeners.splice(listenerIndex, 1);\n }\n delete communityUpdatePollers[communityKey];\n};\n\nconst clearPendingCommunityErrors = (communityKey: string) => {\n pendingCommunityErrorTimers[communityKey]?.forEach((timeout) => clearTimeout(timeout));\n delete pendingCommunityErrorTimers[communityKey];\n};\n\nconst clearStoredCommunityErrors = (state: CommunitiesState, communityKey: string) => {\n if (!state.errors[communityKey]) {\n return state.errors;\n }\n const nextErrors = { ...state.errors };\n delete nextErrors[communityKey];\n return nextErrors;\n};\n\nconst isRetriableCommunityLoadError = (error: Error) => {\n const details = (error as Error & { details?: unknown }).details;\n return Boolean(\n details &&\n typeof details === \"object\" &&\n \"retriableError\" in details &&\n (details as { retriableError?: unknown }).retriableError === true,\n );\n};\n\nconst scheduleCommunityError = (setState: Function, communityKey: string, error: Error) => {\n if (isRetriableCommunityLoadError(error)) {\n return;\n }\n\n const timeout = setTimeout(() => {\n const pendingTimeouts = pendingCommunityErrorTimers[communityKey];\n if (!pendingTimeouts?.includes(timeout)) {\n return;\n }\n\n const remainingTimeouts = pendingTimeouts.filter(\n (pendingTimeout) => pendingTimeout !== timeout,\n );\n if (remainingTimeouts.length === 0) {\n delete pendingCommunityErrorTimers[communityKey];\n } else {\n pendingCommunityErrorTimers[communityKey] = remainingTimeouts;\n }\n setState((state: CommunitiesState) => {\n const communityErrors = state.errors[communityKey] || [];\n return {\n ...state,\n errors: { ...state.errors, [communityKey]: [...communityErrors, error] },\n };\n });\n }, COMMUNITY_ERROR_UPDATE_GRACE_MS);\n\n pendingCommunityErrorTimers[communityKey] = [\n ...(pendingCommunityErrorTimers[communityKey] || []),\n timeout,\n ];\n};\n\nexport type CommunitiesState = {\n communities: Communities;\n errors: { [communityAddress: string]: Error[] };\n addCommunityToStore: Function;\n refreshCommunity: Function;\n editCommunity: Function;\n createCommunity: Function;\n deleteCommunity: Function;\n};\n\nconst communitiesStore = createStore<CommunitiesState>(\n (setState: Function, getState: Function) => ({\n communities: {},\n errors: {},\n\n async addCommunityToStore(\n communityAddressOrRef: string | CommunityIdentifier,\n account: Account,\n ) {\n const communityLookupOptions = getCommunityLookupOptions(communityAddressOrRef);\n const communityKey =\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.addCommunityToStore invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.addCommunityToStore invalid account argument '${account}'`,\n );\n\n // community is in store already, do nothing\n const { communities } = getState();\n let community: Community | undefined = communities[communityKey];\n const pendingKey = communityKey + account.id;\n if (community || pkcGetCommunityPending[pendingKey]) {\n return;\n }\n\n // start trying to get community\n pkcGetCommunityPending[pendingKey] = true;\n let errorGettingCommunity: any;\n try {\n // try to find community in owner communities\n if (getPkcCommunityAddresses(account.pkc).includes(communityKey)) {\n try {\n community = await createCommunityWithLookupFallback(\n account.pkc,\n communityLookupOptions,\n communityKey,\n );\n } catch (e) {\n errorGettingCommunity = e;\n }\n }\n\n // try to find community in database\n let fetchedAt: number | undefined;\n if (!community) {\n const communityData: any = await communitiesDatabase.getItem(communityKey);\n const lookupName =\n \"name\" in communityLookupOptions ? communityLookupOptions.name : undefined;\n const lookupPublicKey =\n \"publicKey\" in communityLookupOptions ? communityLookupOptions.publicKey : undefined;\n const lookupAddress =\n \"address\" in communityLookupOptions ? communityLookupOptions.address : undefined;\n const hasCachedPosts =\n Object.keys(communityData?.posts?.pageCids || {}).length > 0 ||\n Object.keys(communityData?.posts?.pages || {}).length > 0;\n const isUnresolvedNameCache =\n communityData &&\n lookupName &&\n !lookupPublicKey &&\n !lookupAddress &&\n !communityData.publicKey &&\n !communityData.updatedAt &&\n !communityData.updateCid &&\n !communityData.title &&\n !communityData.description &&\n !hasCachedPosts;\n if (communityData && !isUnresolvedNameCache) {\n fetchedAt = communityData.fetchedAt;\n delete communityData.fetchedAt; // not part of pkc-js schema\n try {\n community = await createPkcCommunity(account.pkc, communityData);\n } catch (e) {\n fetchedAt = undefined;\n // need to log this always or it could silently fail in production and cache never be used\n console.error(\"failed pkc.createCommunity(cachedCommunity)\", {\n cachedCommunity: communityData,\n error: e,\n });\n }\n }\n if (community) {\n // add page comments to communitiesPagesStore so they can be used in useComment\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(community);\n }\n }\n\n // community not in database, try to fetch from pkc-js\n if (!community) {\n try {\n community = await createCommunityWithLookupFallback(\n account.pkc,\n communityLookupOptions,\n communityKey,\n );\n } catch (e) {\n errorGettingCommunity = e;\n }\n }\n\n // failure getting community\n if (!community) {\n if (errorGettingCommunity) {\n setState((state: CommunitiesState) => {\n let communityErrors = state.errors[communityKey] || [];\n communityErrors = [...communityErrors, errorGettingCommunity];\n return { ...state, errors: { ...state.errors, [communityKey]: communityErrors } };\n });\n }\n\n throw (\n errorGettingCommunity ||\n Error(`communitiesStore.addCommunityToStore failed getting community '${communityKey}'`)\n );\n }\n\n // success getting community\n const firstCommunityState = utils.clone({\n ...community,\n ...(fetchedAt !== undefined ? { fetchedAt } : undefined),\n });\n await communitiesDatabase.setItem(communityKey, firstCommunityState);\n log(\"communitiesStore.addCommunityToStore\", {\n communityAddressOrRef,\n communityKey,\n community,\n account,\n });\n setState((state: any) => ({\n communities: { ...state.communities, [communityKey]: firstCommunityState },\n }));\n\n // the community has published new posts\n community.on(\"update\", async (updatedCommunity: Community) => {\n clearPendingCommunityErrors(communityKey);\n setState((state: CommunitiesState) => ({\n ...state,\n errors: clearStoredCommunityErrors(state, communityKey),\n }));\n updatedCommunity = utils.clone(updatedCommunity);\n\n // add fetchedAt to be able to expire the cache\n // NOTE: fetchedAt is undefined on owner communities because never stale\n updatedCommunity.fetchedAt = Math.floor(Date.now() / 1000);\n\n await communitiesDatabase.setItem(communityKey, updatedCommunity);\n log(\"communitiesStore community update\", {\n communityAddressOrRef,\n communityKey,\n updatedCommunity,\n account,\n });\n setState((state: any) => ({\n ...state,\n communities: { ...state.communities, [communityKey]: updatedCommunity },\n }));\n\n // if a community has a role with an account's address add it to the account.communities\n accountsStore\n .getState()\n .accountsActionsInternal.addCommunityRoleToAccountsCommunities(updatedCommunity);\n\n // add page comments to communitiesPagesStore so they can be used in useComment\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(updatedCommunity);\n });\n\n community.on(\"updatingstatechange\", (updatingState: string) => {\n setState((state: CommunitiesState) => ({\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], updatingState },\n },\n }));\n });\n\n community.on(\"error\", (error: Error) => {\n scheduleCommunityError(setState, communityKey, error);\n });\n\n // set clients on community so the frontend can display it, dont persist in db because a reload cancels updating\n utils.clientsOnStateChange(\n community?.clients,\n (clientState: string, clientType: string, clientUrl: string, chainTicker?: string) => {\n setState((state: CommunitiesState) => {\n // make sure not undefined, sometimes happens in e2e tests\n if (!state.communities[communityKey]) {\n return {};\n }\n const clients = { ...state.communities[communityKey]?.clients };\n const client = { state: clientState };\n if (chainTicker) {\n const chainProviders = { ...clients[clientType][chainTicker], [clientUrl]: client };\n clients[clientType] = { ...clients[clientType], [chainTicker]: chainProviders };\n } else {\n clients[clientType] = { ...clients[clientType], [clientUrl]: client };\n }\n return {\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], clients },\n },\n };\n });\n },\n );\n\n listeners.push(community);\n startCommunityUpdatePolling(community, { communityAddressOrRef, communityKey });\n } finally {\n pkcGetCommunityPending[pendingKey] = false;\n }\n },\n\n async refreshCommunity(communityAddressOrRef: string | CommunityIdentifier, account: Account) {\n const communityLookupOptions = getCommunityLookupOptions(communityAddressOrRef);\n const communityKey =\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.refreshCommunity invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n typeof getPkcGetCommunity(account?.pkc) === \"function\",\n `communitiesStore.refreshCommunity invalid account argument '${account}'`,\n );\n\n const refreshedCommunity = utils.clone(\n await getPkcCommunity(account.pkc, communityLookupOptions),\n );\n refreshedCommunity.fetchedAt = Math.floor(Date.now() / 1000);\n\n await communitiesDatabase.setItem(communityKey, refreshedCommunity);\n log(\"communitiesStore.refreshCommunity\", {\n communityAddressOrRef,\n communityKey,\n refreshedCommunity,\n account,\n });\n setState((state: any) => ({\n communities: { ...state.communities, [communityKey]: refreshedCommunity },\n }));\n\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(refreshedCommunity);\n\n return refreshedCommunity;\n },\n\n // user is the owner of the community and can edit it locally\n async editCommunity(communityAddress: string, communityEditOptions: any, account: Account) {\n assert(\n communityAddress !== \"\" && typeof communityAddress === \"string\",\n `communitiesStore.editCommunity invalid communityAddress argument '${communityAddress}'`,\n );\n assert(\n communityEditOptions && typeof communityEditOptions === \"object\",\n `communitiesStore.editCommunity invalid communityEditOptions argument '${communityEditOptions}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.editCommunity invalid account argument '${account}'`,\n );\n\n // if not added to store first, community.update() is never called\n await getState().addCommunityToStore(communityAddress, account);\n\n // `communityAddress` is different from `communityEditOptions.address` when editing the community address\n const community = await createPkcCommunity(account.pkc, {\n address: communityAddress,\n });\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n await community.edit(communityEditOptions);\n\n const updatedCommunity = utils.clone(community);\n // edit db of both old and new community address to not break the UI\n await communitiesDatabase.setItem(communityAddress, updatedCommunity);\n await communitiesDatabase.setItem(community.address, updatedCommunity);\n log(\"communitiesStore.editCommunity\", {\n communityAddress,\n communityEditOptions,\n community,\n account,\n });\n setState((state: any) => ({\n communities: {\n ...state.communities,\n // edit react state of both old and new community address to not break the UI\n [communityAddress]: updatedCommunity,\n [community.address]: updatedCommunity,\n },\n }));\n },\n\n // internal action called by accountsActions.createCommunity\n async createCommunity(createCommunityOptions: CreateCommunityOptions, account: Account) {\n assert(\n !createCommunityOptions || typeof createCommunityOptions === \"object\",\n `communitiesStore.createCommunity invalid createCommunityOptions argument '${createCommunityOptions}'`,\n );\n if (!createCommunityOptions?.signer) {\n assert(\n !createCommunityOptions?.address,\n `communitiesStore.createCommunity createCommunityOptions.address '${createCommunityOptions?.address}' must be undefined to create a community`,\n );\n }\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.createCommunity invalid account argument '${account}'`,\n );\n\n const community = await createPkcCommunity(account.pkc, createCommunityOptions);\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n // if not added to store first, community.update() is never called\n await getState().addCommunityToStore(community.address, account);\n\n await communitiesDatabase.setItem(community.address, utils.clone(community));\n log(\"communitiesStore.createCommunity\", { createCommunityOptions, community, account });\n setState((state: any) => ({\n communities: { ...state.communities, [community.address]: utils.clone(community) },\n }));\n return community;\n },\n\n // internal action called by accountsActions.deleteCommunity\n async deleteCommunity(communityAddress: string, account: Account) {\n assert(\n communityAddress && typeof communityAddress === \"string\",\n `communitiesStore.deleteCommunity invalid communityAddress argument '${communityAddress}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.deleteCommunity invalid account argument '${account}'`,\n );\n\n const community = await createPkcCommunity(account.pkc, {\n address: communityAddress,\n });\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n await community.delete();\n stopCommunityUpdatePolling(communityAddress);\n await communitiesDatabase.removeItem(communityAddress);\n log(\"communitiesStore.deleteCommunity\", { communityAddress, community, account });\n setState((state: any) => ({\n communities: { ...state.communities, [communityAddress]: undefined },\n }));\n },\n }),\n);\n\n// reset store in between tests\nconst originalState = communitiesStore.getState();\n// async function because some stores have async init\nexport const resetCommunitiesStore = async () => {\n pkcGetCommunityPending = {};\n Object.keys(pendingCommunityErrorTimers).forEach(clearPendingCommunityErrors);\n // remove all event listeners\n listeners.forEach((listener: any) => listener.removeAllListeners());\n listeners.length = 0;\n Object.keys(communityUpdatePollers).forEach(stopCommunityUpdatePolling);\n // destroy all component subscriptions to the store\n communitiesStore.destroy();\n // restore original state\n communitiesStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetCommunitiesDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-communities\" }).clear();\n await resetCommunitiesStore();\n};\n\nexport default communitiesStore;\n"]}
1
+ {"version":3,"file":"communities-store.js","sourceRoot":"","sources":["../../../src/stores/communities/communities-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,MAAM,mBAAmB,GAAG,cAAc,CAAC,cAAc,CAAC;IACxD,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE,GAAG;CACV,CAAC,CAAC;AACH,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,0CAA0C,CAAC,CAAC;AAS/D,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,aAAa,MAAM,aAAa,CAAC;AACxC,OAAO,qBAAqB,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,4BAA4B,GAA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\";\nconst communitiesDatabase = localForageLru.createInstance({\n name: \"bitsocialReactHooks-communities\",\n size: 500,\n});\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:communities:stores\");\nimport {\n Community,\n Communities,\n Account,\n CommunityIdentifier,\n CommunitySyncState,\n CreateCommunityOptions,\n} from \"../../types\";\nimport utils from \"../../lib/utils\";\nimport createStore from \"zustand\";\nimport accountsStore from \"../accounts\";\nimport communitiesPagesStore from \"../communities-pages\";\nimport { getCommunityLookupOptions, getCommunityRefKey } from \"../../lib/community-ref\";\nimport {\n createPkcCommunity,\n getPkcCommunity,\n getPkcCommunityAddresses,\n getPkcCreateCommunity,\n getPkcGetCommunity,\n} from \"../../lib/pkc-compat\";\n\nexport const COMMUNITY_UPDATE_INTERVAL_MS = 15 * 60 * 1000;\n\nlet pkcGetCommunityPending: { [key: string]: boolean } = {};\n// Key pollers by community so delete/reset can stop the matching live instance.\nconst communityUpdatePollers: {\n [communityKey: string]: {\n community: any;\n updateInterval: ReturnType<typeof setInterval>;\n };\n} = {};\n\n// reset all event listeners in between tests\nconst listeners: any = [];\n\nconst COMMUNITY_ERROR_UPDATE_GRACE_MS = 1000;\nconst pendingCommunityErrorTimers: {\n [communityKey: string]: ReturnType<typeof setTimeout>[];\n} = {};\n\ninterface CommunitySyncStatus {\n syncState: CommunitySyncState;\n lastFetchAttemptAt?: number;\n lastSuccessfulFetchAt?: number;\n}\n\nconst getNowSeconds = () => Math.floor(Date.now() / 1000);\n\nconst normalizeCommunitySyncState = (updatingState: string): CommunitySyncState => {\n if (updatingState === \"waiting-retry\") {\n return \"retrying\";\n }\n if (updatingState === \"succeeded\" || updatingState === \"failed\" || updatingState === \"stopped\") {\n return updatingState;\n }\n return \"loading\";\n};\n\nconst updateCommunitySyncStatus = (\n setState: Function,\n communityKey: string,\n syncState: CommunitySyncState,\n) => {\n setState((state: CommunitiesState) => {\n const previousStatus = state.syncStatuses[communityKey];\n const timestamp = getNowSeconds();\n const shouldRecordAttempt = syncState === \"loading\" && previousStatus?.syncState !== \"loading\";\n return {\n ...state,\n syncStatuses: {\n ...state.syncStatuses,\n [communityKey]: {\n ...previousStatus,\n syncState,\n ...(shouldRecordAttempt ? { lastFetchAttemptAt: timestamp } : undefined),\n ...(syncState === \"succeeded\" ? { lastSuccessfulFetchAt: timestamp } : undefined),\n },\n },\n };\n });\n};\n\nconst createCommunityWithLookupFallback = async (\n pkc: any,\n communityLookupOptions: { address?: string; name?: string; publicKey?: string },\n communityKey: string,\n) => {\n const supportsAddressLookup = \"address\" in communityLookupOptions;\n const community = await createPkcCommunity(pkc, communityLookupOptions);\n if (community?.address || supportsAddressLookup) {\n return community;\n }\n throw Error(`communitiesStore.addCommunityToStore failed getting community '${communityKey}'`);\n};\n\nconst updateCommunity = (\n community: Community,\n {\n communityAddressOrRef,\n communityKey,\n }: { communityAddressOrRef: string | CommunityIdentifier; communityKey: string },\n) => {\n community.update().catch((error: unknown) =>\n log.trace(\"community.update error\", {\n communityAddressOrRef,\n communityKey,\n community,\n error,\n }),\n );\n};\n\nconst startCommunityUpdatePolling = (\n community: Community,\n {\n communityAddressOrRef,\n communityKey,\n }: { communityAddressOrRef: string | CommunityIdentifier; communityKey: string },\n) => {\n stopCommunityUpdatePolling(communityKey);\n updateCommunity(community, { communityAddressOrRef, communityKey });\n communityUpdatePollers[communityKey] = {\n community,\n updateInterval: setInterval(\n () => updateCommunity(community, { communityAddressOrRef, communityKey }),\n COMMUNITY_UPDATE_INTERVAL_MS,\n ),\n };\n};\n\nconst stopCommunityUpdatePolling = (communityKey: string) => {\n const polling = communityUpdatePollers[communityKey];\n if (!polling) {\n return;\n }\n\n clearPendingCommunityErrors(communityKey);\n clearInterval(polling.updateInterval);\n polling.community.removeAllListeners();\n const listenerIndex = listeners.indexOf(polling.community);\n if (listenerIndex >= 0) {\n listeners.splice(listenerIndex, 1);\n }\n delete communityUpdatePollers[communityKey];\n};\n\nconst clearPendingCommunityErrors = (communityKey: string) => {\n pendingCommunityErrorTimers[communityKey]?.forEach((timeout) => clearTimeout(timeout));\n delete pendingCommunityErrorTimers[communityKey];\n};\n\nconst clearStoredCommunityErrors = (state: CommunitiesState, communityKey: string) => {\n if (!state.errors[communityKey]) {\n return state.errors;\n }\n const nextErrors = { ...state.errors };\n delete nextErrors[communityKey];\n return nextErrors;\n};\n\nconst isRetriableCommunityLoadError = (error: Error) => {\n const details = (error as Error & { details?: unknown }).details;\n return Boolean(\n details &&\n typeof details === \"object\" &&\n \"retriableError\" in details &&\n (details as { retriableError?: unknown }).retriableError === true,\n );\n};\n\nconst scheduleCommunityError = (setState: Function, communityKey: string, error: Error) => {\n if (isRetriableCommunityLoadError(error)) {\n return;\n }\n\n const timeout = setTimeout(() => {\n const pendingTimeouts = pendingCommunityErrorTimers[communityKey];\n if (!pendingTimeouts?.includes(timeout)) {\n return;\n }\n\n const remainingTimeouts = pendingTimeouts.filter(\n (pendingTimeout) => pendingTimeout !== timeout,\n );\n if (remainingTimeouts.length === 0) {\n delete pendingCommunityErrorTimers[communityKey];\n } else {\n pendingCommunityErrorTimers[communityKey] = remainingTimeouts;\n }\n setState((state: CommunitiesState) => {\n const communityErrors = state.errors[communityKey] || [];\n return {\n ...state,\n errors: { ...state.errors, [communityKey]: [...communityErrors, error] },\n };\n });\n }, COMMUNITY_ERROR_UPDATE_GRACE_MS);\n\n pendingCommunityErrorTimers[communityKey] = [\n ...(pendingCommunityErrorTimers[communityKey] || []),\n timeout,\n ];\n};\n\nexport type CommunitiesState = {\n communities: Communities;\n errors: { [communityAddress: string]: Error[] };\n syncStatuses: { [communityAddress: string]: CommunitySyncStatus };\n addCommunityToStore: Function;\n refreshCommunity: Function;\n editCommunity: Function;\n createCommunity: Function;\n deleteCommunity: Function;\n};\n\nconst communitiesStore = createStore<CommunitiesState>(\n (setState: Function, getState: Function) => ({\n communities: {},\n errors: {},\n syncStatuses: {},\n\n async addCommunityToStore(\n communityAddressOrRef: string | CommunityIdentifier,\n account: Account,\n ) {\n const communityLookupOptions = getCommunityLookupOptions(communityAddressOrRef);\n const communityKey =\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.addCommunityToStore invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.addCommunityToStore invalid account argument '${account}'`,\n );\n\n // community is in store already, do nothing\n const { communities } = getState();\n let community: Community | undefined = communities[communityKey];\n const pendingKey = communityKey + account.id;\n if (community || pkcGetCommunityPending[pendingKey]) {\n return;\n }\n\n // start trying to get community\n pkcGetCommunityPending[pendingKey] = true;\n updateCommunitySyncStatus(setState, communityKey, \"initializing\");\n let errorGettingCommunity: any;\n try {\n // try to find community in owner communities\n if (getPkcCommunityAddresses(account.pkc).includes(communityKey)) {\n try {\n community = await createCommunityWithLookupFallback(\n account.pkc,\n communityLookupOptions,\n communityKey,\n );\n } catch (e) {\n errorGettingCommunity = e;\n }\n }\n\n // try to find community in database\n let fetchedAt: number | undefined;\n if (!community) {\n const communityData: any = await communitiesDatabase.getItem(communityKey);\n const lookupName =\n \"name\" in communityLookupOptions ? communityLookupOptions.name : undefined;\n const lookupPublicKey =\n \"publicKey\" in communityLookupOptions ? communityLookupOptions.publicKey : undefined;\n const lookupAddress =\n \"address\" in communityLookupOptions ? communityLookupOptions.address : undefined;\n const hasCachedPosts =\n Object.keys(communityData?.posts?.pageCids || {}).length > 0 ||\n Object.keys(communityData?.posts?.pages || {}).length > 0;\n const isUnresolvedNameCache =\n communityData &&\n lookupName &&\n !lookupPublicKey &&\n !lookupAddress &&\n !communityData.publicKey &&\n !communityData.updatedAt &&\n !communityData.updateCid &&\n !communityData.title &&\n !communityData.description &&\n !hasCachedPosts;\n if (communityData && !isUnresolvedNameCache) {\n fetchedAt = communityData.fetchedAt;\n delete communityData.fetchedAt; // not part of pkc-js schema\n try {\n community = await createPkcCommunity(account.pkc, communityData);\n } catch (e) {\n fetchedAt = undefined;\n // need to log this always or it could silently fail in production and cache never be used\n console.error(\"failed pkc.createCommunity(cachedCommunity)\", {\n cachedCommunity: communityData,\n error: e,\n });\n }\n }\n if (community) {\n // add page comments to communitiesPagesStore so they can be used in useComment\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(community);\n }\n }\n\n // community not in database, try to fetch from pkc-js\n if (!community) {\n try {\n community = await createCommunityWithLookupFallback(\n account.pkc,\n communityLookupOptions,\n communityKey,\n );\n } catch (e) {\n errorGettingCommunity = e;\n }\n }\n\n // failure getting community\n if (!community) {\n if (errorGettingCommunity) {\n setState((state: CommunitiesState) => {\n let communityErrors = state.errors[communityKey] || [];\n communityErrors = [...communityErrors, errorGettingCommunity];\n return { ...state, errors: { ...state.errors, [communityKey]: communityErrors } };\n });\n }\n\n throw (\n errorGettingCommunity ||\n Error(`communitiesStore.addCommunityToStore failed getting community '${communityKey}'`)\n );\n }\n\n // success getting community\n const firstCommunityState = utils.clone({\n ...community,\n ...(fetchedAt !== undefined ? { fetchedAt } : undefined),\n });\n await communitiesDatabase.setItem(communityKey, firstCommunityState);\n log(\"communitiesStore.addCommunityToStore\", {\n communityAddressOrRef,\n communityKey,\n community,\n account,\n });\n setState((state: any) => ({\n communities: { ...state.communities, [communityKey]: firstCommunityState },\n }));\n\n // the community has published new posts\n community.on(\"update\", async (updatedCommunity: Community) => {\n clearPendingCommunityErrors(communityKey);\n setState((state: CommunitiesState) => ({\n ...state,\n errors: clearStoredCommunityErrors(state, communityKey),\n }));\n updatedCommunity = utils.clone(updatedCommunity);\n\n // add fetchedAt to be able to expire the cache\n // NOTE: fetchedAt is undefined on owner communities because never stale\n updatedCommunity.fetchedAt = Math.floor(Date.now() / 1000);\n\n await communitiesDatabase.setItem(communityKey, updatedCommunity);\n log(\"communitiesStore community update\", {\n communityAddressOrRef,\n communityKey,\n updatedCommunity,\n account,\n });\n setState((state: any) => ({\n ...state,\n communities: { ...state.communities, [communityKey]: updatedCommunity },\n }));\n\n // if a community has a role with an account's address add it to the account.communities\n accountsStore\n .getState()\n .accountsActionsInternal.addCommunityRoleToAccountsCommunities(updatedCommunity);\n\n // add page comments to communitiesPagesStore so they can be used in useComment\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(updatedCommunity);\n });\n\n community.on(\"updatingstatechange\", (updatingState: string) => {\n updateCommunitySyncStatus(\n setState,\n communityKey,\n normalizeCommunitySyncState(updatingState),\n );\n setState((state: CommunitiesState) => ({\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], updatingState },\n },\n }));\n });\n\n community.on(\"error\", (error: Error) => {\n scheduleCommunityError(setState, communityKey, error);\n });\n\n // set clients on community so the frontend can display it, dont persist in db because a reload cancels updating\n utils.clientsOnStateChange(\n community?.clients,\n (clientState: string, clientType: string, clientUrl: string, chainTicker?: string) => {\n setState((state: CommunitiesState) => {\n // make sure not undefined, sometimes happens in e2e tests\n if (!state.communities[communityKey]) {\n return {};\n }\n const clients = { ...state.communities[communityKey]?.clients };\n const client = { state: clientState };\n if (chainTicker) {\n const chainProviders = { ...clients[clientType][chainTicker], [clientUrl]: client };\n clients[clientType] = { ...clients[clientType], [chainTicker]: chainProviders };\n } else {\n clients[clientType] = { ...clients[clientType], [clientUrl]: client };\n }\n return {\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], clients },\n },\n };\n });\n },\n );\n\n listeners.push(community);\n startCommunityUpdatePolling(community, { communityAddressOrRef, communityKey });\n } catch (error) {\n updateCommunitySyncStatus(setState, communityKey, \"failed\");\n throw error;\n } finally {\n pkcGetCommunityPending[pendingKey] = false;\n }\n },\n\n async refreshCommunity(communityAddressOrRef: string | CommunityIdentifier, account: Account) {\n const communityLookupOptions = getCommunityLookupOptions(communityAddressOrRef);\n const communityKey =\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.refreshCommunity invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n typeof getPkcGetCommunity(account?.pkc) === \"function\",\n `communitiesStore.refreshCommunity invalid account argument '${account}'`,\n );\n\n const refreshedCommunity = utils.clone(\n await getPkcCommunity(account.pkc, communityLookupOptions),\n );\n refreshedCommunity.fetchedAt = Math.floor(Date.now() / 1000);\n\n await communitiesDatabase.setItem(communityKey, refreshedCommunity);\n log(\"communitiesStore.refreshCommunity\", {\n communityAddressOrRef,\n communityKey,\n refreshedCommunity,\n account,\n });\n setState((state: any) => ({\n communities: { ...state.communities, [communityKey]: refreshedCommunity },\n }));\n\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(refreshedCommunity);\n\n return refreshedCommunity;\n },\n\n // user is the owner of the community and can edit it locally\n async editCommunity(communityAddress: string, communityEditOptions: any, account: Account) {\n assert(\n communityAddress !== \"\" && typeof communityAddress === \"string\",\n `communitiesStore.editCommunity invalid communityAddress argument '${communityAddress}'`,\n );\n assert(\n communityEditOptions && typeof communityEditOptions === \"object\",\n `communitiesStore.editCommunity invalid communityEditOptions argument '${communityEditOptions}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.editCommunity invalid account argument '${account}'`,\n );\n\n // if not added to store first, community.update() is never called\n await getState().addCommunityToStore(communityAddress, account);\n\n // `communityAddress` is different from `communityEditOptions.address` when editing the community address\n const community = await createPkcCommunity(account.pkc, {\n address: communityAddress,\n });\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n await community.edit(communityEditOptions);\n\n const updatedCommunity = utils.clone(community);\n // edit db of both old and new community address to not break the UI\n await communitiesDatabase.setItem(communityAddress, updatedCommunity);\n await communitiesDatabase.setItem(community.address, updatedCommunity);\n log(\"communitiesStore.editCommunity\", {\n communityAddress,\n communityEditOptions,\n community,\n account,\n });\n setState((state: any) => ({\n communities: {\n ...state.communities,\n // edit react state of both old and new community address to not break the UI\n [communityAddress]: updatedCommunity,\n [community.address]: updatedCommunity,\n },\n }));\n },\n\n // internal action called by accountsActions.createCommunity\n async createCommunity(createCommunityOptions: CreateCommunityOptions, account: Account) {\n assert(\n !createCommunityOptions || typeof createCommunityOptions === \"object\",\n `communitiesStore.createCommunity invalid createCommunityOptions argument '${createCommunityOptions}'`,\n );\n if (!createCommunityOptions?.signer) {\n assert(\n !createCommunityOptions?.address,\n `communitiesStore.createCommunity createCommunityOptions.address '${createCommunityOptions?.address}' must be undefined to create a community`,\n );\n }\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.createCommunity invalid account argument '${account}'`,\n );\n\n const community = await createPkcCommunity(account.pkc, createCommunityOptions);\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n // if not added to store first, community.update() is never called\n await getState().addCommunityToStore(community.address, account);\n\n await communitiesDatabase.setItem(community.address, utils.clone(community));\n log(\"communitiesStore.createCommunity\", { createCommunityOptions, community, account });\n setState((state: any) => ({\n communities: { ...state.communities, [community.address]: utils.clone(community) },\n }));\n return community;\n },\n\n // internal action called by accountsActions.deleteCommunity\n async deleteCommunity(communityAddress: string, account: Account) {\n assert(\n communityAddress && typeof communityAddress === \"string\",\n `communitiesStore.deleteCommunity invalid communityAddress argument '${communityAddress}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.deleteCommunity invalid account argument '${account}'`,\n );\n\n const community = await createPkcCommunity(account.pkc, {\n address: communityAddress,\n });\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n await community.delete();\n stopCommunityUpdatePolling(communityAddress);\n await communitiesDatabase.removeItem(communityAddress);\n log(\"communitiesStore.deleteCommunity\", { communityAddress, community, account });\n setState((state: CommunitiesState) => {\n const syncStatuses = { ...state.syncStatuses };\n delete syncStatuses[communityAddress];\n const errors = { ...state.errors };\n delete errors[communityAddress];\n return {\n communities: { ...state.communities, [communityAddress]: undefined },\n errors,\n syncStatuses,\n };\n });\n },\n }),\n);\n\n// reset store in between tests\nconst originalState = communitiesStore.getState();\n// async function because some stores have async init\nexport const resetCommunitiesStore = async () => {\n pkcGetCommunityPending = {};\n Object.keys(pendingCommunityErrorTimers).forEach(clearPendingCommunityErrors);\n // remove all event listeners\n listeners.forEach((listener: any) => listener.removeAllListeners());\n listeners.length = 0;\n Object.keys(communityUpdatePollers).forEach(stopCommunityUpdatePolling);\n // destroy all component subscriptions to the store\n communitiesStore.destroy();\n // restore original state\n communitiesStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetCommunitiesDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-communities\" }).clear();\n await resetCommunitiesStore();\n};\n\nexport default communitiesStore;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"replies-store.d.ts","sourceRoot":"","sources":["../../../src/stores/replies/replies-store.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EAGP,kBAAkB,EAClB,mBAAmB,EAGpB,MAAM,aAAa,CAAC;AAwBrB,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAKxC,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,mBAAmB,CAAC;IAClC,aAAa,EAAE,KAAK,CAAC;IACrB,WAAW,EAAE,KAAK,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC;IACpB,wBAAwB,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACzD,aAAa,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC/C,eAAe,EAAE,QAAQ,CAAC;IAC1B,6BAA6B,EAAE,QAAQ,CAAC;IACxC,uBAAuB,EAAE,QAAQ,CAAC;IAClC,SAAS,EAAE,QAAQ,CAAC;IACpB,WAAW,EAAE,QAAQ,CAAC;CACvB,CAAC;AAgBF,eAAO,MAAM,qBAAqB,GAAI,aAAa,OAAO,CAAC,kBAAkB,CAAC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AmB7B,CAAC;AAGF,eAAO,MAAM,4BAA4B,qBAGxC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -362,19 +362,22 @@ const updateFeedsOnFeedsCommentsChange = (repliesCommentsStoreState) => {
362
362
  };
363
363
  let previousAccountsCommentsCount = 0;
364
364
  let previousAccountsCommentsCids = "";
365
+ let previousAccountsCommentsPurged = "";
365
366
  const updateFeedsOnAccountsCommentsChange = (accountsStoreState) => {
366
367
  const { accountsComments } = accountsStoreState;
367
- const accountsCommentsCount = Object.values(accountsComments).reduce((count, accountComments) => count + accountComments.length, 0);
368
+ const accountCommentsArrays = Object.values(accountsComments);
369
+ const accountsCommentsCount = accountCommentsArrays.reduce((count, accountComments) => count + accountComments.length, 0);
370
+ const accountsCommentsCids = accountCommentsArrays.reduce((cids, accountComments) => cids + String(accountComments.map((comment) => comment.cid || "")), "");
371
+ const accountsCommentsPurged = accountCommentsArrays.reduce((purged, accountComments) => purged + String(accountComments.map((comment) => comment.purged === true)), "");
368
372
  // no changes, do nothing
369
- if (accountsCommentsCount === previousAccountsCommentsCount) {
370
- // if cids haven't changed (account comments receive cids after pending), do nothing
371
- const accountsCommentsCids = Object.values(accountsComments).reduce((cids, accountComments) => cids + String(accountComments.map((comment) => comment.cid || "")), "");
372
- if (accountsCommentsCids === previousAccountsCommentsCids) {
373
- return;
374
- }
375
- previousAccountsCommentsCids = accountsCommentsCids;
373
+ if (accountsCommentsCount === previousAccountsCommentsCount &&
374
+ accountsCommentsCids === previousAccountsCommentsCids &&
375
+ accountsCommentsPurged === previousAccountsCommentsPurged) {
376
+ return;
376
377
  }
377
378
  previousAccountsCommentsCount = accountsCommentsCount;
379
+ previousAccountsCommentsCids = accountsCommentsCids;
380
+ previousAccountsCommentsPurged = accountsCommentsPurged;
378
381
  // TODO: only update the feeds that are relevant to the new accountComment.parentCid/postCid
379
382
  repliesStore.getState().updateFeeds();
380
383
  };
@@ -414,6 +417,7 @@ export const resetRepliesStore = () => __awaiter(void 0, void 0, void 0, functio
414
417
  previousRepliesPages = {};
415
418
  previousAccountsCommentsCount = 0;
416
419
  previousAccountsCommentsCids = "";
420
+ previousAccountsCommentsPurged = "";
417
421
  updateFeedsPending = false;
418
422
  // destroy all component subscriptions to the store
419
423
  repliesStore.destroy();