@bitsocial/bitsocial-react-hooks 0.1.45 → 0.1.47

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 (32) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +8 -1
  3. package/dist/hooks/feeds/feeds.d.ts +2 -1
  4. package/dist/hooks/feeds/feeds.d.ts.map +1 -1
  5. package/dist/hooks/feeds/feeds.js +2 -1
  6. package/dist/hooks/feeds/feeds.js.map +1 -1
  7. package/dist/index.d.ts +6 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +6 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/page-sorts.d.ts +4 -0
  12. package/dist/lib/page-sorts.d.ts.map +1 -1
  13. package/dist/lib/page-sorts.js +123 -15
  14. package/dist/lib/page-sorts.js.map +1 -1
  15. package/dist/stores/comments/comments-store.d.ts.map +1 -1
  16. package/dist/stores/comments/comments-store.js +21 -2
  17. package/dist/stores/comments/comments-store.js.map +1 -1
  18. package/dist/stores/communities-pages/communities-pages-store.js +7 -6
  19. package/dist/stores/communities-pages/communities-pages-store.js.map +1 -1
  20. package/dist/stores/feeds/utils.d.ts.map +1 -1
  21. package/dist/stores/feeds/utils.js +24 -6
  22. package/dist/stores/feeds/utils.js.map +1 -1
  23. package/dist/stores/replies/replies-store.d.ts.map +1 -1
  24. package/dist/stores/replies/replies-store.js +5 -1
  25. package/dist/stores/replies/replies-store.js.map +1 -1
  26. package/dist/stores/replies/utils.d.ts.map +1 -1
  27. package/dist/stores/replies/utils.js +14 -8
  28. package/dist/stores/replies/utils.js.map +1 -1
  29. package/dist/stores/replies-pages/replies-pages-store.d.ts.map +1 -1
  30. package/dist/stores/replies-pages/replies-pages-store.js +7 -6
  31. package/dist/stores/replies-pages/replies-pages-store.js.map +1 -1
  32. package/package.json +17 -11
@@ -13,7 +13,7 @@ import accountsStore from "../accounts/index.js";
13
13
  import { flattenCommentsPages, commentIsValid, removeInvalidComments } from "../../lib/utils/index.js";
14
14
  import { areEquivalentCommunityAddresses } from "../../lib/community-address.js";
15
15
  import Logger from "@pkcprotocol/pkc-logger";
16
- import { resolveReplySortType } from "../../lib/page-sorts.js";
16
+ import { getReplyPageSortType, isFlatSortType, resolveReplySortType } from "../../lib/page-sorts.js";
17
17
  const log = Logger("bitsocial-react-hooks:replies:stores");
18
18
  /**
19
19
  * Calculate the feeds from all the loaded replies pages, filter and sort them
@@ -28,10 +28,12 @@ export const getFilteredSortedFeeds = (feedsOptions, comments, repliesPages, acc
28
28
  const comment = comments[commentCid];
29
29
  const sortType = getSortTypeFromComment(comment, feedsOptions[feedName]);
30
30
  const requestedSortIsUnavailable = requestedSortType !== undefined && sortType === undefined;
31
+ // the page serving the sort, re-sorted client-side when the comment preloads all of its replies
32
+ const pageSortType = comment ? getReplyPageSortType(comment, sortType) : undefined;
31
33
  // comment has loaded and cache not expired
32
34
  if (comment && !requestedSortIsUnavailable) {
33
35
  // use comment preloaded replies if any
34
- const preloadedReplies = getPreloadedReplies(comment, sortType);
36
+ const preloadedReplies = getPreloadedReplies(comment, pageSortType);
35
37
  if (preloadedReplies) {
36
38
  for (const reply of preloadedReplies) {
37
39
  // replies are manually validated, could have fake communityAddress
@@ -55,7 +57,8 @@ export const getFilteredSortedFeeds = (feedsOptions, comments, repliesPages, acc
55
57
  }
56
58
  }
57
59
  }
58
- if (flat) {
60
+ // a flat sort served from a hierarchical page is flattened like the flat page pkc-js would publish
61
+ if (flat || (isFlatSortType(sortType) && pageSortType !== sortType)) {
59
62
  bufferedFeedReplies = flattenCommentsPages({ comments: bufferedFeedReplies });
60
63
  }
61
64
  // sort the feed before filtering to get more accurate results
@@ -74,13 +77,12 @@ export const getFilteredSortedFeeds = (feedsOptions, comments, repliesPages, acc
74
77
  }
75
78
  return feeds;
76
79
  };
77
- const getPreloadedReplies = (comment, sortType) => {
80
+ const getPreloadedReplies = (comment, pageSortType) => {
78
81
  var _a, _b, _c;
79
- const resolvedSortType = resolveReplySortType(comment, sortType);
80
- if (!resolvedSortType) {
82
+ if (!pageSortType) {
81
83
  return;
82
84
  }
83
- return (_c = (_b = (_a = comment.replies) === null || _a === void 0 ? void 0 : _a.pages) === null || _b === void 0 ? void 0 : _b[resolvedSortType]) === null || _c === void 0 ? void 0 : _c.comments;
85
+ return (_c = (_b = (_a = comment.replies) === null || _a === void 0 ? void 0 : _a.pages) === null || _b === void 0 ? void 0 : _b[pageSortType]) === null || _c === void 0 ? void 0 : _c.comments;
84
86
  };
85
87
  const previousPageNumbers = {};
86
88
  const pageNumberIncreased = (feedName, pageNumber, loadedFeed, bufferedFeed) => {
@@ -495,7 +497,7 @@ export const getFeedsCommentsFirstPageCids = (feedsComments) => {
495
497
  };
496
498
  // get all comments replies pages first reply updatedAts, use to check if a commentsStore change should trigger updateFeeds
497
499
  export const getFeedsCommentsRepliesPagesFirstUpdatedAts = (feedsComments) => {
498
- var _a, _b, _c;
500
+ var _a, _b, _c, _d;
499
501
  let feedsCommentsRepliesPagesFirstUpdatedAts = "";
500
502
  for (const comment of feedsComments.values()) {
501
503
  for (const page of Object.values(((_a = comment === null || comment === void 0 ? void 0 : comment.replies) === null || _a === void 0 ? void 0 : _a.pages) || {})) {
@@ -503,6 +505,10 @@ export const getFeedsCommentsRepliesPagesFirstUpdatedAts = (feedsComments) => {
503
505
  feedsCommentsRepliesPagesFirstUpdatedAts +=
504
506
  page.comments[0].cid + page.comments[0].updatedAt;
505
507
  }
508
+ // a reply added or removed past the first one changes a preloaded page without new page cids
509
+ if ((_d = page === null || page === void 0 ? void 0 : page.comments) === null || _d === void 0 ? void 0 : _d.length) {
510
+ feedsCommentsRepliesPagesFirstUpdatedAts += `:${page.comments.length};`;
511
+ }
506
512
  }
507
513
  }
508
514
  return feedsCommentsRepliesPagesFirstUpdatedAts;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/stores/replies/utils.ts"],"names":[],"mappings":";;;;;;;;;AAaA,OAAO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,EAAE,CAAC,EAAE,CAAC;YAC7E,IAAI,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,0CAAG,CAAC,CAAC,0CAAE,SAAS,EAAE,CAAC;gBACnC,wCAAwC;oBACtC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACtD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,wCAAwC,CAAC;AAClD,CAAC,CAAC;AAEF,+CAA+C;AAC/C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,aAAmC,EAAU,EAAE;IACzF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,OAAO,IAAI,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC;QAC7C,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE,CAAC;YACvB,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,qEAAqE;AACrE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAgB,EAAE,WAA+B,EAAE,EAAE,CAC1F,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC","sourcesContent":["import assert from \"assert\";\nimport {\n Feed,\n Feeds,\n RepliesFeedOptions,\n RepliesFeedsOptions,\n Comment,\n Comments,\n Account,\n Accounts,\n RepliesPage,\n RepliesPages,\n} from \"../../types\";\nimport { getRepliesPages, getRepliesFirstPageCid } from \"../replies-pages\";\nimport repliesSorter from \"../feeds/feed-sorter\";\nimport accountsStore from \"../accounts\";\nimport { flattenCommentsPages, commentIsValid, removeInvalidComments } from \"../../lib/utils\";\nimport { areEquivalentCommunityAddresses } from \"../../lib/community-address\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nimport { resolveReplySortType } from \"../../lib/page-sorts\";\nconst log = Logger(\"bitsocial-react-hooks:replies:stores\");\n\n/**\n * Calculate the feeds from all the loaded replies pages, filter and sort them\n */\nexport const getFilteredSortedFeeds = (\n feedsOptions: RepliesFeedsOptions,\n comments: Comments,\n repliesPages: RepliesPages,\n accounts: Accounts,\n) => {\n // calculate each feed\n let feeds: Feeds = {};\n for (const feedName in feedsOptions) {\n const {\n commentCid,\n sortType: requestedSortType,\n accountId,\n filter,\n flat,\n } = feedsOptions[feedName];\n\n // find all fetched replies\n let bufferedFeedReplies = [];\n const comment = comments[commentCid];\n\n const sortType = getSortTypeFromComment(comment, feedsOptions[feedName]);\n const requestedSortIsUnavailable = requestedSortType !== undefined && sortType === undefined;\n\n // comment has loaded and cache not expired\n if (comment && !requestedSortIsUnavailable) {\n // use comment preloaded replies if any\n const preloadedReplies = getPreloadedReplies(comment, sortType);\n if (preloadedReplies) {\n for (const reply of preloadedReplies) {\n // replies are manually validated, could have fake communityAddress\n if (!areEquivalentCommunityAddresses(reply.communityAddress, comment.communityAddress)) {\n break;\n }\n bufferedFeedReplies.push(reply);\n }\n }\n\n // add all replies from comment replies pages\n const _repliesPages = getRepliesPages(comment, sortType, repliesPages);\n for (const repliesPage of _repliesPages) {\n if (repliesPage?.comments) {\n for (const reply of repliesPage.comments) {\n // replies are manually validated, could have fake communityAddress\n if (\n !areEquivalentCommunityAddresses(reply.communityAddress, comment.communityAddress)\n ) {\n break;\n }\n bufferedFeedReplies.push(reply);\n }\n }\n }\n }\n\n if (flat) {\n bufferedFeedReplies = flattenCommentsPages({ comments: bufferedFeedReplies });\n }\n\n // sort the feed before filtering to get more accurate results\n const sortedBufferedFeedReplies = repliesSorter.sort(sortType, bufferedFeedReplies);\n\n // filter the feed\n const filteredSortedBufferedFeedReplies = [];\n for (const reply of sortedBufferedFeedReplies) {\n // TODO: maybe skip if comment community address, comment cid or comment author is blocked?\n\n // feedOptions filter function\n if (filter && !filter.filter(reply)) {\n continue;\n }\n\n filteredSortedBufferedFeedReplies.push(reply);\n }\n\n feeds[feedName] = filteredSortedBufferedFeedReplies;\n }\n return feeds;\n};\n\nconst getPreloadedReplies = (comment: Comment, sortType?: string) => {\n const resolvedSortType = resolveReplySortType(comment, sortType);\n if (!resolvedSortType) {\n return;\n }\n return comment.replies?.pages?.[resolvedSortType]?.comments;\n};\n\nconst previousPageNumbers: { [feedName: string]: number } = {};\nconst pageNumberIncreased = (\n feedName: string,\n pageNumber: number,\n loadedFeed: Comment[],\n bufferedFeed: Comment[],\n) => {\n const isFirstPage = !loadedFeed && bufferedFeed?.length;\n // first page should always update\n // pageNumber has changed should always update\n if (isFirstPage || previousPageNumbers[feedName] !== pageNumber) {\n previousPageNumbers[feedName] = pageNumber;\n return true;\n }\n return false;\n};\n\nconst alwaysStreamPage = (feedOptions: RepliesFeedOptions) => {\n // feedOptions.streamPage set to true means always stream page\n if (feedOptions.streamPage) {\n return true;\n }\n // always stream top level replies and/or flat\n return feedOptions.commentDepth > 0 && !feedOptions.flat ? false : true;\n};\n\nconst getApprovalPublicationKey = (comment: Comment) =>\n [\n comment.timestamp ?? \"\",\n comment.parentCid ?? \"\",\n comment.postCid ?? \"\",\n comment.communityAddress ?? \"\",\n comment.author?.address ?? \"\",\n comment.title ?? \"\",\n comment.content ?? \"\",\n comment.link ?? \"\",\n ].join(\"\\0\");\n\nconst isPurgedAccountReply = (reply: Comment) =>\n typeof reply?.index === \"number\" && !!reply.cid && reply.purged === true;\n\nconst canonicalFeedRefreshedAfterReply = (reply: Comment, feedUpdatedAt?: number) =>\n typeof feedUpdatedAt !== \"number\" ||\n typeof reply.timestamp !== \"number\" ||\n feedUpdatedAt > reply.timestamp;\n\nconst shouldHidePurgedAccountReply = (\n reply: Comment,\n hidePurgedAccountReplies: boolean,\n feedUpdatedAt?: number,\n) =>\n hidePurgedAccountReplies &&\n isPurgedAccountReply(reply) &&\n canonicalFeedRefreshedAfterReply(reply, feedUpdatedAt);\n\ntype GetLoadedFeedsOptions = {\n addAccountComments?: boolean;\n feedsHaveMore?: { [feedName: string]: boolean };\n feedsUpdatedAts?: { [feedName: string]: number | undefined };\n};\n\nexport const getLoadedFeeds = async (\n feedsOptions: RepliesFeedsOptions,\n loadedFeeds: Feeds,\n bufferedFeeds: Feeds,\n accounts: Accounts,\n options: GetLoadedFeedsOptions = {},\n) => {\n const loadedFeedsMissingReplies: Feeds = {};\n for (const feedName in feedsOptions) {\n const { pageNumber, repliesPerPage, accountId, streamPage } = feedsOptions[feedName];\n\n // TODO: fix design issue, pageNumber shouldnt be increased when loadMore is called and repliesPerPage not reached\n // if not always streaming replies, and page number didn't increase, skip updating\n // so UI isn't displaced when new nested replies are added\n if (\n !alwaysStreamPage(feedsOptions[feedName]) &&\n !pageNumberIncreased(feedName, pageNumber, loadedFeeds[feedName], bufferedFeeds[feedName])\n ) {\n continue;\n }\n\n const pkc = accounts[accountId]?.pkc;\n const loadedFeedReplyCount = pageNumber * repliesPerPage;\n const currentLoadedFeed = loadedFeeds[feedName] || [];\n // don't count account replies\n const missingRepliesCount =\n loadedFeedReplyCount - currentLoadedFeed.filter((reply) => reply.index === undefined).length;\n\n // get new replies from buffered feed\n const bufferedFeed = bufferedFeeds[feedName] || [];\n\n let missingReplies: any[] = [];\n for (const reply of bufferedFeed) {\n if (missingReplies.length >= missingRepliesCount) {\n missingReplies = await removeInvalidComments(\n missingReplies,\n { validateReplies: false },\n pkc,\n );\n // only stop if there were no invalid comments\n if (missingReplies.length >= missingRepliesCount) {\n break;\n }\n }\n missingReplies.push(reply);\n }\n\n // the current loaded feed already exist and doesn't need new replies\n if (missingReplies.length === 0 && loadedFeeds[feedName]) {\n continue;\n }\n loadedFeedsMissingReplies[feedName] = missingReplies;\n }\n\n let newLoadedFeeds: Feeds = {};\n for (const feedName in loadedFeedsMissingReplies) {\n newLoadedFeeds[feedName] = [\n ...(loadedFeeds[feedName] || []),\n ...loadedFeedsMissingReplies[feedName],\n ];\n }\n\n // add account comments\n newLoadedFeeds = { ...loadedFeeds, ...newLoadedFeeds };\n const accountCommentsChangedFeeds =\n options.addAccountComments === false\n ? false\n : addAccountsComments(\n feedsOptions,\n newLoadedFeeds,\n options.feedsHaveMore,\n options.feedsUpdatedAts,\n );\n\n // do nothing if there are no missing replies\n if (Object.keys(loadedFeedsMissingReplies).length === 0 && !accountCommentsChangedFeeds) {\n return loadedFeeds;\n }\n return newLoadedFeeds;\n};\n\nexport const addAccountsComments = (\n feedsOptions: RepliesFeedsOptions,\n loadedFeeds: Feeds,\n feedsHaveMore?: { [feedName: string]: boolean },\n feedsUpdatedAts?: { [feedName: string]: number | undefined },\n) => {\n let loadedFeedsChanged = false;\n const accountsComments = accountsStore.getState().accountsComments || {};\n for (const feedName in feedsOptions) {\n const {\n accountId,\n accountComments: accountCommentsOptions,\n commentCid,\n postCid,\n commentDepth,\n flat,\n } = feedsOptions[feedName];\n const { newerThan, append } = accountCommentsOptions || {};\n if (!newerThan) {\n continue;\n }\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n const isNewerThan = (reply: Comment) => reply.timestamp > newerThanTimestamp;\n const hidePurgedAccountReplies = feedsHaveMore?.[feedName] === false;\n const feedUpdatedAt = feedsUpdatedAts?.[feedName];\n\n const accountComments = accountsComments[accountId] || [];\n const accountReplies = accountComments.filter((reply) => {\n if (shouldHidePurgedAccountReply(reply, hidePurgedAccountReplies, feedUpdatedAt)) {\n return false;\n }\n if (!isNewerThan(reply)) {\n return false;\n }\n if (flat) {\n // if flat, add all account replies with greater comment depth\n return reply.postCid === postCid && reply.depth > commentDepth;\n }\n return reply.parentCid === commentCid;\n });\n const validAccountIndices = new Set(accountReplies.map((r) => r.index));\n const accountCidToReply = new Map<string, Comment>();\n for (const r of accountReplies) {\n if (r.cid) accountCidToReply.set(r.cid, r);\n }\n\n let loadedFeed = loadedFeeds[feedName] || [];\n const approvedPublicationKeys = new Set(\n loadedFeed\n .filter((reply) => reply.pendingApproval !== true)\n .map((reply) => getApprovalPublicationKey(reply)),\n );\n // prune stale local-account entries and replace when cid matches but index changed\n const prunedLoadedFeed: Comment[] = [];\n for (const reply of loadedFeed) {\n if (reply.index === undefined) {\n prunedLoadedFeed.push(reply);\n continue;\n }\n if (shouldHidePurgedAccountReply(reply, hidePurgedAccountReplies, feedUpdatedAt)) {\n loadedFeedsChanged = true;\n continue;\n }\n if (\n reply.pendingApproval === true &&\n approvedPublicationKeys.has(getApprovalPublicationKey(reply))\n ) {\n loadedFeedsChanged = true;\n continue;\n }\n if (reply.cid) {\n const freshAccountReply = accountCidToReply.get(reply.cid);\n if (freshAccountReply && freshAccountReply.index !== reply.index) {\n prunedLoadedFeed.push(freshAccountReply);\n loadedFeedsChanged = true;\n continue;\n }\n }\n if (!validAccountIndices.has(reply.index)) {\n loadedFeedsChanged = true;\n continue;\n }\n prunedLoadedFeed.push(reply);\n }\n loadedFeed = loadedFeeds[feedName] = prunedLoadedFeed;\n\n if (!accountReplies.length) {\n continue;\n }\n // if a loaded comment doesn't have a cid, then it's pending\n // and pending account comments should always have unique timestamps\n const loadedFeedMap = new Map();\n loadedFeed.forEach((reply, loadedFeedIndex) => {\n if (reply.cid) loadedFeedMap.set(reply.cid, loadedFeedIndex);\n if (typeof reply.index === \"number\") loadedFeedMap.set(reply.index, loadedFeedIndex);\n if (!reply.cid) loadedFeedMap.set(reply.timestamp, loadedFeedIndex);\n if (reply.pendingApproval !== true) {\n loadedFeedMap.set(getApprovalPublicationKey(reply), loadedFeedIndex);\n }\n });\n for (const accountReply of accountReplies) {\n // account reply with cid already added\n if (accountReply.cid && loadedFeedMap.has(accountReply.cid)) {\n continue;\n }\n if (\n accountReply.pendingApproval === true &&\n loadedFeedMap.has(getApprovalPublicationKey(accountReply))\n ) {\n continue;\n }\n // account reply without cid already added, but now we have the cid\n if (accountReply.cid && loadedFeedMap.has(accountReply.index)) {\n const loadedFeedIndex = loadedFeedMap.get(accountReply.index);\n // update the feed with the accountReply.cid now that we have it\n loadedFeed[loadedFeedIndex] = accountReply;\n loadedFeedsChanged = true;\n continue;\n }\n if (loadedFeedMap.has(accountReply.index)) {\n continue;\n }\n // pending account reply without cid already added\n if (!accountReply.cid && loadedFeedMap.has(accountReply.timestamp)) {\n continue;\n }\n if (append) {\n loadedFeed.push(accountReply);\n } else {\n loadedFeed.unshift(accountReply);\n }\n loadedFeedsChanged = true;\n }\n }\n return loadedFeedsChanged;\n};\n\nexport const getBufferedFeedsWithoutLoadedFeeds = (bufferedFeeds: Feeds, loadedFeeds: Feeds) => {\n // contruct a list of replies already loaded to remove them from buffered feeds\n const loadedFeedsReplies: { [key: string]: Set<string> } = {};\n for (const feedName in loadedFeeds) {\n loadedFeedsReplies[feedName] = new Set();\n for (const reply of loadedFeeds[feedName]) {\n loadedFeedsReplies[feedName].add(reply.cid);\n }\n }\n\n const newBufferedFeeds: Feeds = {};\n for (const feedName in bufferedFeeds) {\n newBufferedFeeds[feedName] = [];\n let bufferedFeedReplyChanged = false;\n for (const [i, reply] of bufferedFeeds[feedName].entries()) {\n if (loadedFeedsReplies[feedName]?.has(reply.cid)) {\n continue;\n }\n newBufferedFeeds[feedName].push(reply);\n if (\n !bufferedFeedReplyChanged &&\n (newBufferedFeeds[feedName][i]?.cid !== bufferedFeeds[feedName][i]?.cid ||\n (newBufferedFeeds[feedName][i]?.updatedAt || 0) >\n (bufferedFeeds[feedName][i]?.updatedAt || 0))\n ) {\n bufferedFeedReplyChanged = true;\n }\n }\n if (\n !bufferedFeedReplyChanged &&\n newBufferedFeeds[feedName].length === bufferedFeeds[feedName].length\n ) {\n newBufferedFeeds[feedName] = bufferedFeeds[feedName];\n }\n }\n return newBufferedFeeds;\n};\n\nexport const getUpdatedFeeds = async (\n feedsOptions: RepliesFeedsOptions,\n filteredSortedFeeds: Feeds,\n updatedFeeds: Feeds,\n loadedFeeds: Feeds,\n accounts: Accounts,\n) => {\n const newUpdatedFeeds: Feeds = { ...updatedFeeds };\n const feedNames = new Set([\n ...Object.keys(filteredSortedFeeds || {}),\n ...Object.keys(loadedFeeds || {}),\n ...Object.keys(updatedFeeds || {}),\n ]);\n for (const feedName of feedNames) {\n const pkc = accounts[feedsOptions[feedName]?.accountId]?.pkc;\n const loadedFeed = loadedFeeds[feedName] || [];\n const previousUpdatedFeed = updatedFeeds[feedName] || [];\n const updatedFeed = [...loadedFeed];\n let updatedFeedChanged = false;\n\n // Keep updated feeds in lock-step with loaded feeds so local deletions\n // (e.g. abandoned pending replies) disappear without requiring a feed reset.\n if (previousUpdatedFeed.length !== updatedFeed.length) {\n updatedFeedChanged = true;\n }\n\n const filteredRepliesByCid = new Map<string, Comment>();\n for (const reply of filteredSortedFeeds[feedName] || []) {\n if (reply?.cid) {\n filteredRepliesByCid.set(reply.cid, reply);\n }\n }\n\n for (let i = 0; i < updatedFeed.length; i++) {\n const loadedReply = updatedFeed[i];\n if (!loadedReply?.cid) {\n continue;\n }\n\n const previousUpdatedReply = previousUpdatedFeed[i];\n if (\n previousUpdatedReply?.cid === loadedReply.cid &&\n (previousUpdatedReply.updatedAt || 0) > (loadedReply.updatedAt || 0)\n ) {\n updatedFeed[i] = previousUpdatedReply;\n updatedFeedChanged = true;\n }\n\n const candidateReply = filteredRepliesByCid.get(loadedReply.cid);\n if (!candidateReply) {\n continue;\n }\n if ((candidateReply.updatedAt || 0) <= (updatedFeed[i]?.updatedAt || 0)) {\n continue;\n }\n if (!(await commentIsValid(candidateReply, { validateReplies: false }, pkc))) {\n continue;\n }\n updatedFeed[i] = candidateReply;\n updatedFeedChanged = true;\n }\n\n if (updatedFeedChanged) {\n newUpdatedFeeds[feedName] = updatedFeed;\n continue;\n }\n\n if (!updatedFeeds[feedName]) {\n newUpdatedFeeds[feedName] = updatedFeed;\n }\n }\n return newUpdatedFeeds;\n};\n\n// find how many replies are in each comments in a buffereds feeds\n// NOTE: not useful, could use feed.length, copied over from useFeed and easier to keep it\nexport const getFeedsReplyCounts = (feedsOptions: RepliesFeedsOptions, feeds: Feeds) => {\n const feedsReplyCounts: { [feedName: string]: number } = {};\n for (const feedName in feedsOptions) {\n feedsReplyCounts[feedName] = feeds[feedName]?.length || 0;\n }\n return feedsReplyCounts;\n};\n\n/**\n * Get which feeds have more replies, i.e. have not reached the final page of all comments\n */\nexport const getFeedsHaveMore = (\n feedsOptions: RepliesFeedsOptions,\n bufferedFeeds: Feeds,\n comments: Comments,\n repliesPages: RepliesPages,\n accounts: Accounts,\n) => {\n const feedsHaveMore: { [feedName: string]: boolean } = {};\n for (const feedName in feedsOptions) {\n // if the feed still has buffered replies, then it still has more\n if (bufferedFeeds[feedName]?.length) {\n feedsHaveMore[feedName] = true;\n continue;\n }\n\n const { commentCid, sortType: requestedSortType, onlyIfCached } = feedsOptions[feedName];\n\n // TODO: maybe skip if comment cid is blocked?\n\n const comment = comments[commentCid];\n // if at least comment hasn't loaded yet, then the feed still has more\n if (!comment?.updatedAt) {\n feedsHaveMore[feedName] = !onlyIfCached;\n continue;\n }\n\n const sortType = getSortTypeFromComment(comment, feedsOptions[feedName]);\n if (requestedSortType !== undefined && sortType === undefined) {\n feedsHaveMore[feedName] = false;\n continue;\n }\n\n const firstPageCid = getRepliesFirstPageCid(comment, sortType);\n // TODO: if a loaded comment doesn't have a first page, it's unclear what we should do\n // should we try to use another sort type by default, like 'best', or should we just ignore it?\n // 'continue' to ignore it for now\n if (!firstPageCid) {\n feedsHaveMore[feedName] = false;\n continue;\n }\n const pages = getRepliesPages(comment, sortType, repliesPages);\n // if first page isn't loaded yet, then the feed still has more\n if (!pages.length) {\n feedsHaveMore[feedName] = !onlyIfCached;\n continue;\n }\n const lastPage = pages[pages.length - 1];\n if (lastPage.nextCid) {\n feedsHaveMore[feedName] = !onlyIfCached;\n continue;\n }\n\n // if buffered feeds are empty and no last page of any comment has a next page, then has more is false\n feedsHaveMore[feedName] = false;\n }\n return feedsHaveMore;\n};\n\n// get all comments replies pages cids of all feeds, use to check if a commentsStore change should trigger updateFeeds\nexport const getFeedsComments = (feedsOptions: RepliesFeedsOptions, comments: Comments) => {\n const feedsComments = new Map<string, Comment>();\n for (const feedName in feedsOptions) {\n feedsComments.set(\n feedsOptions[feedName].commentCid,\n comments[feedsOptions[feedName].commentCid],\n );\n }\n return feedsComments;\n};\n\nexport const feedsCommentsChanged = (\n previousFeedsComments: Map<string, Comment>,\n feedsComments: Map<string, Comment>,\n) => {\n if (previousFeedsComments.size !== feedsComments.size) {\n return true;\n }\n for (let commentCid of previousFeedsComments.keys()) {\n // check if the object is still the same\n if (previousFeedsComments.get(commentCid) !== feedsComments.get(commentCid)) {\n return true;\n }\n }\n return false;\n};\n\n// get all comments replies pages cids of all feeds, use to check if a commentsStore change should trigger updateFeeds\nexport const getFeedsCommentsFirstPageCids = (feedsComments: Map<string, Comment>): string[] => {\n // find all the feeds comments first page cids\n const feedsCommentsFirstPageCids = new Set<string>();\n for (const comment of feedsComments.values()) {\n if (!comment?.replies) {\n continue;\n }\n\n // check pages\n if (comment.replies.pages) {\n for (const page of Object.values<RepliesPage>(comment.replies.pages)) {\n if (page?.nextCid) {\n feedsCommentsFirstPageCids.add(page?.nextCid);\n }\n }\n }\n\n // check pageCids\n if (comment.replies.pageCids) {\n for (const pageCid of Object.values<string>(comment.replies.pageCids)) {\n if (pageCid) {\n feedsCommentsFirstPageCids.add(pageCid);\n }\n }\n }\n }\n\n return [...feedsCommentsFirstPageCids].sort();\n};\n\n// get all comments replies pages first reply updatedAts, use to check if a commentsStore change should trigger updateFeeds\nexport const getFeedsCommentsRepliesPagesFirstUpdatedAts = (\n feedsComments: Map<string, Comment>,\n): string => {\n let feedsCommentsRepliesPagesFirstUpdatedAts = \"\";\n for (const comment of feedsComments.values()) {\n for (const page of Object.values<RepliesPage>(comment?.replies?.pages || {})) {\n if (page?.comments?.[0]?.updatedAt) {\n feedsCommentsRepliesPagesFirstUpdatedAts +=\n page.comments[0].cid + page.comments[0].updatedAt;\n }\n }\n }\n return feedsCommentsRepliesPagesFirstUpdatedAts;\n};\n\n// get number of feeds comments that are loaded\nexport const getFeedsCommentsLoadedCount = (feedsComments: Map<string, Comment>): number => {\n let count = 0;\n for (const comment of feedsComments.values()) {\n if (comment?.updatedAt) {\n count++;\n }\n }\n return count;\n};\n\n// selected sort type could be missing from comment, or not optimized\nexport const getSortTypeFromComment = (comment: Comment, feedOptions: RepliesFeedOptions) =>\n resolveReplySortType(comment, feedOptions.sortType);\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/stores/replies/utils.ts"],"names":[],"mappings":";;;;;;;;;AAaA,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,aAAa,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAClG,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,YAAiC,EACjC,QAAkB,EAClB,YAA0B,EAC1B,QAAkB,EAClB,EAAE;IACF,sBAAsB;IACtB,IAAI,KAAK,GAAU,EAAE,CAAC;IACtB,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE,CAAC;QACpC,MAAM,EACJ,UAAU,EACV,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,EACT,MAAM,EACN,IAAI,GACL,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE3B,2BAA2B;QAC3B,IAAI,mBAAmB,GAAG,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;QAErC,MAAM,QAAQ,GAAG,sBAAsB,CAAC,OAA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AAS,EAAE,CAAC;YACvB,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,qEAAqE;AACrE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAgB,EAAE,WAA+B,EAAE,EAAE,CAC1F,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC","sourcesContent":["import assert from \"assert\";\nimport {\n Feed,\n Feeds,\n RepliesFeedOptions,\n RepliesFeedsOptions,\n Comment,\n Comments,\n Account,\n Accounts,\n RepliesPage,\n RepliesPages,\n} from \"../../types\";\nimport { getRepliesPages, getRepliesFirstPageCid } from \"../replies-pages\";\nimport repliesSorter from \"../feeds/feed-sorter\";\nimport accountsStore from \"../accounts\";\nimport { flattenCommentsPages, commentIsValid, removeInvalidComments } from \"../../lib/utils\";\nimport { areEquivalentCommunityAddresses } from \"../../lib/community-address\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nimport { getReplyPageSortType, isFlatSortType, resolveReplySortType } from \"../../lib/page-sorts\";\nconst log = Logger(\"bitsocial-react-hooks:replies:stores\");\n\n/**\n * Calculate the feeds from all the loaded replies pages, filter and sort them\n */\nexport const getFilteredSortedFeeds = (\n feedsOptions: RepliesFeedsOptions,\n comments: Comments,\n repliesPages: RepliesPages,\n accounts: Accounts,\n) => {\n // calculate each feed\n let feeds: Feeds = {};\n for (const feedName in feedsOptions) {\n const {\n commentCid,\n sortType: requestedSortType,\n accountId,\n filter,\n flat,\n } = feedsOptions[feedName];\n\n // find all fetched replies\n let bufferedFeedReplies = [];\n const comment = comments[commentCid];\n\n const sortType = getSortTypeFromComment(comment, feedsOptions[feedName]);\n const requestedSortIsUnavailable = requestedSortType !== undefined && sortType === undefined;\n // the page serving the sort, re-sorted client-side when the comment preloads all of its replies\n const pageSortType = comment ? getReplyPageSortType(comment, sortType) : undefined;\n\n // comment has loaded and cache not expired\n if (comment && !requestedSortIsUnavailable) {\n // use comment preloaded replies if any\n const preloadedReplies = getPreloadedReplies(comment, pageSortType);\n if (preloadedReplies) {\n for (const reply of preloadedReplies) {\n // replies are manually validated, could have fake communityAddress\n if (!areEquivalentCommunityAddresses(reply.communityAddress, comment.communityAddress)) {\n break;\n }\n bufferedFeedReplies.push(reply);\n }\n }\n\n // add all replies from comment replies pages\n const _repliesPages = getRepliesPages(comment, sortType, repliesPages);\n for (const repliesPage of _repliesPages) {\n if (repliesPage?.comments) {\n for (const reply of repliesPage.comments) {\n // replies are manually validated, could have fake communityAddress\n if (\n !areEquivalentCommunityAddresses(reply.communityAddress, comment.communityAddress)\n ) {\n break;\n }\n bufferedFeedReplies.push(reply);\n }\n }\n }\n }\n\n // a flat sort served from a hierarchical page is flattened like the flat page pkc-js would publish\n if (flat || (isFlatSortType(sortType) && pageSortType !== sortType)) {\n bufferedFeedReplies = flattenCommentsPages({ comments: bufferedFeedReplies });\n }\n\n // sort the feed before filtering to get more accurate results\n const sortedBufferedFeedReplies = repliesSorter.sort(sortType, bufferedFeedReplies);\n\n // filter the feed\n const filteredSortedBufferedFeedReplies = [];\n for (const reply of sortedBufferedFeedReplies) {\n // TODO: maybe skip if comment community address, comment cid or comment author is blocked?\n\n // feedOptions filter function\n if (filter && !filter.filter(reply)) {\n continue;\n }\n\n filteredSortedBufferedFeedReplies.push(reply);\n }\n\n feeds[feedName] = filteredSortedBufferedFeedReplies;\n }\n return feeds;\n};\n\nconst getPreloadedReplies = (comment: Comment, pageSortType?: string) => {\n if (!pageSortType) {\n return;\n }\n return comment.replies?.pages?.[pageSortType]?.comments;\n};\n\nconst previousPageNumbers: { [feedName: string]: number } = {};\nconst pageNumberIncreased = (\n feedName: string,\n pageNumber: number,\n loadedFeed: Comment[],\n bufferedFeed: Comment[],\n) => {\n const isFirstPage = !loadedFeed && bufferedFeed?.length;\n // first page should always update\n // pageNumber has changed should always update\n if (isFirstPage || previousPageNumbers[feedName] !== pageNumber) {\n previousPageNumbers[feedName] = pageNumber;\n return true;\n }\n return false;\n};\n\nconst alwaysStreamPage = (feedOptions: RepliesFeedOptions) => {\n // feedOptions.streamPage set to true means always stream page\n if (feedOptions.streamPage) {\n return true;\n }\n // always stream top level replies and/or flat\n return feedOptions.commentDepth > 0 && !feedOptions.flat ? false : true;\n};\n\nconst getApprovalPublicationKey = (comment: Comment) =>\n [\n comment.timestamp ?? \"\",\n comment.parentCid ?? \"\",\n comment.postCid ?? \"\",\n comment.communityAddress ?? \"\",\n comment.author?.address ?? \"\",\n comment.title ?? \"\",\n comment.content ?? \"\",\n comment.link ?? \"\",\n ].join(\"\\0\");\n\nconst isPurgedAccountReply = (reply: Comment) =>\n typeof reply?.index === \"number\" && !!reply.cid && reply.purged === true;\n\nconst canonicalFeedRefreshedAfterReply = (reply: Comment, feedUpdatedAt?: number) =>\n typeof feedUpdatedAt !== \"number\" ||\n typeof reply.timestamp !== \"number\" ||\n feedUpdatedAt > reply.timestamp;\n\nconst shouldHidePurgedAccountReply = (\n reply: Comment,\n hidePurgedAccountReplies: boolean,\n feedUpdatedAt?: number,\n) =>\n hidePurgedAccountReplies &&\n isPurgedAccountReply(reply) &&\n canonicalFeedRefreshedAfterReply(reply, feedUpdatedAt);\n\ntype GetLoadedFeedsOptions = {\n addAccountComments?: boolean;\n feedsHaveMore?: { [feedName: string]: boolean };\n feedsUpdatedAts?: { [feedName: string]: number | undefined };\n};\n\nexport const getLoadedFeeds = async (\n feedsOptions: RepliesFeedsOptions,\n loadedFeeds: Feeds,\n bufferedFeeds: Feeds,\n accounts: Accounts,\n options: GetLoadedFeedsOptions = {},\n) => {\n const loadedFeedsMissingReplies: Feeds = {};\n for (const feedName in feedsOptions) {\n const { pageNumber, repliesPerPage, accountId, streamPage } = feedsOptions[feedName];\n\n // TODO: fix design issue, pageNumber shouldnt be increased when loadMore is called and repliesPerPage not reached\n // if not always streaming replies, and page number didn't increase, skip updating\n // so UI isn't displaced when new nested replies are added\n if (\n !alwaysStreamPage(feedsOptions[feedName]) &&\n !pageNumberIncreased(feedName, pageNumber, loadedFeeds[feedName], bufferedFeeds[feedName])\n ) {\n continue;\n }\n\n const pkc = accounts[accountId]?.pkc;\n const loadedFeedReplyCount = pageNumber * repliesPerPage;\n const currentLoadedFeed = loadedFeeds[feedName] || [];\n // don't count account replies\n const missingRepliesCount =\n loadedFeedReplyCount - currentLoadedFeed.filter((reply) => reply.index === undefined).length;\n\n // get new replies from buffered feed\n const bufferedFeed = bufferedFeeds[feedName] || [];\n\n let missingReplies: any[] = [];\n for (const reply of bufferedFeed) {\n if (missingReplies.length >= missingRepliesCount) {\n missingReplies = await removeInvalidComments(\n missingReplies,\n { validateReplies: false },\n pkc,\n );\n // only stop if there were no invalid comments\n if (missingReplies.length >= missingRepliesCount) {\n break;\n }\n }\n missingReplies.push(reply);\n }\n\n // the current loaded feed already exist and doesn't need new replies\n if (missingReplies.length === 0 && loadedFeeds[feedName]) {\n continue;\n }\n loadedFeedsMissingReplies[feedName] = missingReplies;\n }\n\n let newLoadedFeeds: Feeds = {};\n for (const feedName in loadedFeedsMissingReplies) {\n newLoadedFeeds[feedName] = [\n ...(loadedFeeds[feedName] || []),\n ...loadedFeedsMissingReplies[feedName],\n ];\n }\n\n // add account comments\n newLoadedFeeds = { ...loadedFeeds, ...newLoadedFeeds };\n const accountCommentsChangedFeeds =\n options.addAccountComments === false\n ? false\n : addAccountsComments(\n feedsOptions,\n newLoadedFeeds,\n options.feedsHaveMore,\n options.feedsUpdatedAts,\n );\n\n // do nothing if there are no missing replies\n if (Object.keys(loadedFeedsMissingReplies).length === 0 && !accountCommentsChangedFeeds) {\n return loadedFeeds;\n }\n return newLoadedFeeds;\n};\n\nexport const addAccountsComments = (\n feedsOptions: RepliesFeedsOptions,\n loadedFeeds: Feeds,\n feedsHaveMore?: { [feedName: string]: boolean },\n feedsUpdatedAts?: { [feedName: string]: number | undefined },\n) => {\n let loadedFeedsChanged = false;\n const accountsComments = accountsStore.getState().accountsComments || {};\n for (const feedName in feedsOptions) {\n const {\n accountId,\n accountComments: accountCommentsOptions,\n commentCid,\n postCid,\n commentDepth,\n flat,\n } = feedsOptions[feedName];\n const { newerThan, append } = accountCommentsOptions || {};\n if (!newerThan) {\n continue;\n }\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n const isNewerThan = (reply: Comment) => reply.timestamp > newerThanTimestamp;\n const hidePurgedAccountReplies = feedsHaveMore?.[feedName] === false;\n const feedUpdatedAt = feedsUpdatedAts?.[feedName];\n\n const accountComments = accountsComments[accountId] || [];\n const accountReplies = accountComments.filter((reply) => {\n if (shouldHidePurgedAccountReply(reply, hidePurgedAccountReplies, feedUpdatedAt)) {\n return false;\n }\n if (!isNewerThan(reply)) {\n return false;\n }\n if (flat) {\n // if flat, add all account replies with greater comment depth\n return reply.postCid === postCid && reply.depth > commentDepth;\n }\n return reply.parentCid === commentCid;\n });\n const validAccountIndices = new Set(accountReplies.map((r) => r.index));\n const accountCidToReply = new Map<string, Comment>();\n for (const r of accountReplies) {\n if (r.cid) accountCidToReply.set(r.cid, r);\n }\n\n let loadedFeed = loadedFeeds[feedName] || [];\n const approvedPublicationKeys = new Set(\n loadedFeed\n .filter((reply) => reply.pendingApproval !== true)\n .map((reply) => getApprovalPublicationKey(reply)),\n );\n // prune stale local-account entries and replace when cid matches but index changed\n const prunedLoadedFeed: Comment[] = [];\n for (const reply of loadedFeed) {\n if (reply.index === undefined) {\n prunedLoadedFeed.push(reply);\n continue;\n }\n if (shouldHidePurgedAccountReply(reply, hidePurgedAccountReplies, feedUpdatedAt)) {\n loadedFeedsChanged = true;\n continue;\n }\n if (\n reply.pendingApproval === true &&\n approvedPublicationKeys.has(getApprovalPublicationKey(reply))\n ) {\n loadedFeedsChanged = true;\n continue;\n }\n if (reply.cid) {\n const freshAccountReply = accountCidToReply.get(reply.cid);\n if (freshAccountReply && freshAccountReply.index !== reply.index) {\n prunedLoadedFeed.push(freshAccountReply);\n loadedFeedsChanged = true;\n continue;\n }\n }\n if (!validAccountIndices.has(reply.index)) {\n loadedFeedsChanged = true;\n continue;\n }\n prunedLoadedFeed.push(reply);\n }\n loadedFeed = loadedFeeds[feedName] = prunedLoadedFeed;\n\n if (!accountReplies.length) {\n continue;\n }\n // if a loaded comment doesn't have a cid, then it's pending\n // and pending account comments should always have unique timestamps\n const loadedFeedMap = new Map();\n loadedFeed.forEach((reply, loadedFeedIndex) => {\n if (reply.cid) loadedFeedMap.set(reply.cid, loadedFeedIndex);\n if (typeof reply.index === \"number\") loadedFeedMap.set(reply.index, loadedFeedIndex);\n if (!reply.cid) loadedFeedMap.set(reply.timestamp, loadedFeedIndex);\n if (reply.pendingApproval !== true) {\n loadedFeedMap.set(getApprovalPublicationKey(reply), loadedFeedIndex);\n }\n });\n for (const accountReply of accountReplies) {\n // account reply with cid already added\n if (accountReply.cid && loadedFeedMap.has(accountReply.cid)) {\n continue;\n }\n if (\n accountReply.pendingApproval === true &&\n loadedFeedMap.has(getApprovalPublicationKey(accountReply))\n ) {\n continue;\n }\n // account reply without cid already added, but now we have the cid\n if (accountReply.cid && loadedFeedMap.has(accountReply.index)) {\n const loadedFeedIndex = loadedFeedMap.get(accountReply.index);\n // update the feed with the accountReply.cid now that we have it\n loadedFeed[loadedFeedIndex] = accountReply;\n loadedFeedsChanged = true;\n continue;\n }\n if (loadedFeedMap.has(accountReply.index)) {\n continue;\n }\n // pending account reply without cid already added\n if (!accountReply.cid && loadedFeedMap.has(accountReply.timestamp)) {\n continue;\n }\n if (append) {\n loadedFeed.push(accountReply);\n } else {\n loadedFeed.unshift(accountReply);\n }\n loadedFeedsChanged = true;\n }\n }\n return loadedFeedsChanged;\n};\n\nexport const getBufferedFeedsWithoutLoadedFeeds = (bufferedFeeds: Feeds, loadedFeeds: Feeds) => {\n // contruct a list of replies already loaded to remove them from buffered feeds\n const loadedFeedsReplies: { [key: string]: Set<string> } = {};\n for (const feedName in loadedFeeds) {\n loadedFeedsReplies[feedName] = new Set();\n for (const reply of loadedFeeds[feedName]) {\n loadedFeedsReplies[feedName].add(reply.cid);\n }\n }\n\n const newBufferedFeeds: Feeds = {};\n for (const feedName in bufferedFeeds) {\n newBufferedFeeds[feedName] = [];\n let bufferedFeedReplyChanged = false;\n for (const [i, reply] of bufferedFeeds[feedName].entries()) {\n if (loadedFeedsReplies[feedName]?.has(reply.cid)) {\n continue;\n }\n newBufferedFeeds[feedName].push(reply);\n if (\n !bufferedFeedReplyChanged &&\n (newBufferedFeeds[feedName][i]?.cid !== bufferedFeeds[feedName][i]?.cid ||\n (newBufferedFeeds[feedName][i]?.updatedAt || 0) >\n (bufferedFeeds[feedName][i]?.updatedAt || 0))\n ) {\n bufferedFeedReplyChanged = true;\n }\n }\n if (\n !bufferedFeedReplyChanged &&\n newBufferedFeeds[feedName].length === bufferedFeeds[feedName].length\n ) {\n newBufferedFeeds[feedName] = bufferedFeeds[feedName];\n }\n }\n return newBufferedFeeds;\n};\n\nexport const getUpdatedFeeds = async (\n feedsOptions: RepliesFeedsOptions,\n filteredSortedFeeds: Feeds,\n updatedFeeds: Feeds,\n loadedFeeds: Feeds,\n accounts: Accounts,\n) => {\n const newUpdatedFeeds: Feeds = { ...updatedFeeds };\n const feedNames = new Set([\n ...Object.keys(filteredSortedFeeds || {}),\n ...Object.keys(loadedFeeds || {}),\n ...Object.keys(updatedFeeds || {}),\n ]);\n for (const feedName of feedNames) {\n const pkc = accounts[feedsOptions[feedName]?.accountId]?.pkc;\n const loadedFeed = loadedFeeds[feedName] || [];\n const previousUpdatedFeed = updatedFeeds[feedName] || [];\n const updatedFeed = [...loadedFeed];\n let updatedFeedChanged = false;\n\n // Keep updated feeds in lock-step with loaded feeds so local deletions\n // (e.g. abandoned pending replies) disappear without requiring a feed reset.\n if (previousUpdatedFeed.length !== updatedFeed.length) {\n updatedFeedChanged = true;\n }\n\n const filteredRepliesByCid = new Map<string, Comment>();\n for (const reply of filteredSortedFeeds[feedName] || []) {\n if (reply?.cid) {\n filteredRepliesByCid.set(reply.cid, reply);\n }\n }\n\n for (let i = 0; i < updatedFeed.length; i++) {\n const loadedReply = updatedFeed[i];\n if (!loadedReply?.cid) {\n continue;\n }\n\n const previousUpdatedReply = previousUpdatedFeed[i];\n if (\n previousUpdatedReply?.cid === loadedReply.cid &&\n (previousUpdatedReply.updatedAt || 0) > (loadedReply.updatedAt || 0)\n ) {\n updatedFeed[i] = previousUpdatedReply;\n updatedFeedChanged = true;\n }\n\n const candidateReply = filteredRepliesByCid.get(loadedReply.cid);\n if (!candidateReply) {\n continue;\n }\n if ((candidateReply.updatedAt || 0) <= (updatedFeed[i]?.updatedAt || 0)) {\n continue;\n }\n if (!(await commentIsValid(candidateReply, { validateReplies: false }, pkc))) {\n continue;\n }\n updatedFeed[i] = candidateReply;\n updatedFeedChanged = true;\n }\n\n if (updatedFeedChanged) {\n newUpdatedFeeds[feedName] = updatedFeed;\n continue;\n }\n\n if (!updatedFeeds[feedName]) {\n newUpdatedFeeds[feedName] = updatedFeed;\n }\n }\n return newUpdatedFeeds;\n};\n\n// find how many replies are in each comments in a buffereds feeds\n// NOTE: not useful, could use feed.length, copied over from useFeed and easier to keep it\nexport const getFeedsReplyCounts = (feedsOptions: RepliesFeedsOptions, feeds: Feeds) => {\n const feedsReplyCounts: { [feedName: string]: number } = {};\n for (const feedName in feedsOptions) {\n feedsReplyCounts[feedName] = feeds[feedName]?.length || 0;\n }\n return feedsReplyCounts;\n};\n\n/**\n * Get which feeds have more replies, i.e. have not reached the final page of all comments\n */\nexport const getFeedsHaveMore = (\n feedsOptions: RepliesFeedsOptions,\n bufferedFeeds: Feeds,\n comments: Comments,\n repliesPages: RepliesPages,\n accounts: Accounts,\n) => {\n const feedsHaveMore: { [feedName: string]: boolean } = {};\n for (const feedName in feedsOptions) {\n // if the feed still has buffered replies, then it still has more\n if (bufferedFeeds[feedName]?.length) {\n feedsHaveMore[feedName] = true;\n continue;\n }\n\n const { commentCid, sortType: requestedSortType, onlyIfCached } = feedsOptions[feedName];\n\n // TODO: maybe skip if comment cid is blocked?\n\n const comment = comments[commentCid];\n // if at least comment hasn't loaded yet, then the feed still has more\n if (!comment?.updatedAt) {\n feedsHaveMore[feedName] = !onlyIfCached;\n continue;\n }\n\n const sortType = getSortTypeFromComment(comment, feedsOptions[feedName]);\n if (requestedSortType !== undefined && sortType === undefined) {\n feedsHaveMore[feedName] = false;\n continue;\n }\n\n const firstPageCid = getRepliesFirstPageCid(comment, sortType);\n // TODO: if a loaded comment doesn't have a first page, it's unclear what we should do\n // should we try to use another sort type by default, like 'best', or should we just ignore it?\n // 'continue' to ignore it for now\n if (!firstPageCid) {\n feedsHaveMore[feedName] = false;\n continue;\n }\n const pages = getRepliesPages(comment, sortType, repliesPages);\n // if first page isn't loaded yet, then the feed still has more\n if (!pages.length) {\n feedsHaveMore[feedName] = !onlyIfCached;\n continue;\n }\n const lastPage = pages[pages.length - 1];\n if (lastPage.nextCid) {\n feedsHaveMore[feedName] = !onlyIfCached;\n continue;\n }\n\n // if buffered feeds are empty and no last page of any comment has a next page, then has more is false\n feedsHaveMore[feedName] = false;\n }\n return feedsHaveMore;\n};\n\n// get all comments replies pages cids of all feeds, use to check if a commentsStore change should trigger updateFeeds\nexport const getFeedsComments = (feedsOptions: RepliesFeedsOptions, comments: Comments) => {\n const feedsComments = new Map<string, Comment>();\n for (const feedName in feedsOptions) {\n feedsComments.set(\n feedsOptions[feedName].commentCid,\n comments[feedsOptions[feedName].commentCid],\n );\n }\n return feedsComments;\n};\n\nexport const feedsCommentsChanged = (\n previousFeedsComments: Map<string, Comment>,\n feedsComments: Map<string, Comment>,\n) => {\n if (previousFeedsComments.size !== feedsComments.size) {\n return true;\n }\n for (let commentCid of previousFeedsComments.keys()) {\n // check if the object is still the same\n if (previousFeedsComments.get(commentCid) !== feedsComments.get(commentCid)) {\n return true;\n }\n }\n return false;\n};\n\n// get all comments replies pages cids of all feeds, use to check if a commentsStore change should trigger updateFeeds\nexport const getFeedsCommentsFirstPageCids = (feedsComments: Map<string, Comment>): string[] => {\n // find all the feeds comments first page cids\n const feedsCommentsFirstPageCids = new Set<string>();\n for (const comment of feedsComments.values()) {\n if (!comment?.replies) {\n continue;\n }\n\n // check pages\n if (comment.replies.pages) {\n for (const page of Object.values<RepliesPage>(comment.replies.pages)) {\n if (page?.nextCid) {\n feedsCommentsFirstPageCids.add(page?.nextCid);\n }\n }\n }\n\n // check pageCids\n if (comment.replies.pageCids) {\n for (const pageCid of Object.values<string>(comment.replies.pageCids)) {\n if (pageCid) {\n feedsCommentsFirstPageCids.add(pageCid);\n }\n }\n }\n }\n\n return [...feedsCommentsFirstPageCids].sort();\n};\n\n// get all comments replies pages first reply updatedAts, use to check if a commentsStore change should trigger updateFeeds\nexport const getFeedsCommentsRepliesPagesFirstUpdatedAts = (\n feedsComments: Map<string, Comment>,\n): string => {\n let feedsCommentsRepliesPagesFirstUpdatedAts = \"\";\n for (const comment of feedsComments.values()) {\n for (const page of Object.values<RepliesPage>(comment?.replies?.pages || {})) {\n if (page?.comments?.[0]?.updatedAt) {\n feedsCommentsRepliesPagesFirstUpdatedAts +=\n page.comments[0].cid + page.comments[0].updatedAt;\n }\n // a reply added or removed past the first one changes a preloaded page without new page cids\n if (page?.comments?.length) {\n feedsCommentsRepliesPagesFirstUpdatedAts += `:${page.comments.length};`;\n }\n }\n }\n return feedsCommentsRepliesPagesFirstUpdatedAts;\n};\n\n// get number of feeds comments that are loaded\nexport const getFeedsCommentsLoadedCount = (feedsComments: Map<string, Comment>): number => {\n let count = 0;\n for (const comment of feedsComments.values()) {\n if (comment?.updatedAt) {\n count++;\n }\n }\n return count;\n};\n\n// selected sort type could be missing from comment, or not optimized\nexport const getSortTypeFromComment = (comment: Comment, feedOptions: RepliesFeedOptions) =>\n resolveReplySortType(comment, feedOptions.sortType);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"replies-pages-store.d.ts","sourceRoot":"","sources":["../../../src/stores/replies-pages/replies-pages-store.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,yBAAyB,CAAC;AA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BAAsB,GAAI,SAAS,OAAO,EAAE,WAAW,MAAM,QAmBzE,CAAC;AAKF,eAAO,MAAM,sBAAsB,qBAQlC,CAAC;AAGF,eAAO,MAAM,iCAAiC,qBAG7C,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -17,7 +17,7 @@ import { addChildrenRepliesFeedsToAddToStore } from "./utils.js";
17
17
  import localForageLru from "../../lib/localforage-lru/index.js";
18
18
  import createStore from "zustand";
19
19
  import assert from "assert";
20
- import { resolveReplySortType } from "../../lib/page-sorts.js";
20
+ import { getReplyPageSortType, resolveReplySortType } from "../../lib/page-sorts.js";
21
21
  const repliesPagesDatabase = localForageLru.createInstance({
22
22
  name: "bitsocialReactHooks-repliesPages",
23
23
  size: 500,
@@ -247,15 +247,16 @@ export const getRepliesFirstPageCid = (comment, sortType) => {
247
247
  var _a, _b, _c, _d, _e, _f, _g, _h;
248
248
  assert(comment === null || comment === void 0 ? void 0 : comment.cid, `getRepliesFirstPageCid comment '${comment}' invalid`);
249
249
  assert(sortType === undefined || (typeof sortType === "string" && sortType.length > 0), `getRepliesFirstPageCid sortType '${sortType}' invalid`);
250
- const resolvedSortType = resolveReplySortType(comment, sortType);
251
- if (!resolvedSortType) {
250
+ // replies served client-side from a complete preloaded page read that page instead of their own
251
+ const pageSortType = getReplyPageSortType(comment, sortType);
252
+ if (!pageSortType) {
252
253
  return;
253
254
  }
254
255
  // comment has preloaded replies for sort type
255
- if ((_c = (_b = (_a = comment.replies) === null || _a === void 0 ? void 0 : _a.pages) === null || _b === void 0 ? void 0 : _b[resolvedSortType]) === null || _c === void 0 ? void 0 : _c.comments) {
256
- return (_f = (_e = (_d = comment.replies) === null || _d === void 0 ? void 0 : _d.pages) === null || _e === void 0 ? void 0 : _e[resolvedSortType]) === null || _f === void 0 ? void 0 : _f.nextCid;
256
+ if ((_c = (_b = (_a = comment.replies) === null || _a === void 0 ? void 0 : _a.pages) === null || _b === void 0 ? void 0 : _b[pageSortType]) === null || _c === void 0 ? void 0 : _c.comments) {
257
+ return (_f = (_e = (_d = comment.replies) === null || _d === void 0 ? void 0 : _d.pages) === null || _e === void 0 ? void 0 : _e[pageSortType]) === null || _f === void 0 ? void 0 : _f.nextCid;
257
258
  }
258
- return (_h = (_g = comment.replies) === null || _g === void 0 ? void 0 : _g.pageCids) === null || _h === void 0 ? void 0 : _h[resolvedSortType];
259
+ return (_h = (_g = comment.replies) === null || _g === void 0 ? void 0 : _g.pageCids) === null || _h === void 0 ? void 0 : _h[pageSortType];
259
260
  // TODO: if a loaded comment doesn't have a first page, it's unclear what we should do
260
261
  // should we try to use another sort type by default, like 'best', or should we just ignore it?
261
262
  };
@@ -1 +1 @@
1
- {"version":3,"file":"replies-pages-store.js","sourceRoot":"","sources":["../../../src/stores/replies-pages/replies-pages-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,uDAAuD;AACvD,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAElE,OAAO,aAAa,MAAM,aAAa,CAAC;AACxC,OAAO,aAAgC,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,oBAAoB,GAAG,cAAc,CAAC,cAAc,CAAC;IACzD,IAAI,EAAE,kCAAkC;IACxC,IAAI,EAAE,GAAG;CACV,CAAC,CAAC;AAEH,6CAA6C;AAC7C,MAAM,SAAS,GAAQ,EAAE,CAAC;AAS1B,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAC,QAAkB,EAAE,QAAkB,EAAE,EAAE,CAAC,CAAC;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E,OAAO,CAAC;IAC7D,CAAC;IACD,OAAO,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,QAAQ,0CAAG,gBAAgB,CAAC,CAAC;IAErD,sFAAsF;IACtF,+FAA+F;AACjG,CAAC,CAAC;AAEF,+BAA+B;AAC/B,MAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;AACnD,qDAAqD;AACrD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAS,EAAE;IAC/C,gBAAgB,GAAG,EAAE,CAAC;IACtB,6BAA6B;IAC7B,SAAS,CAAC,OAAO,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACpE,mDAAmD;IACnD,iBAAiB,CAAC,OAAO,EAAE,CAAC;IAC5B,yBAAyB;IACzB,iBAAiB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAS,EAAE;IAC1D,MAAM,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,kCAAkC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IAC1F,MAAM,sBAAsB,EAAE,CAAC;AACjC,CAAC,CAAA,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import utils from \"../../lib/utils\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\n// include replies pages store with feeds for debugging\nexport const log = Logger(\"bitsocial-react-hooks:replies:stores\");\nimport { RepliesPage, RepliesPages, Account, Comment, Comments } from \"../../types\";\nimport accountsStore from \"../accounts\";\nimport commentsStore, { CommentsState } from \"../comments\";\nimport { addChildrenRepliesFeedsToAddToStore } from \"./utils\";\nimport localForageLru from \"../../lib/localforage-lru\";\nimport createStore from \"zustand\";\nimport assert from \"assert\";\nimport { resolveReplySortType } from \"../../lib/page-sorts\";\n\nconst repliesPagesDatabase = localForageLru.createInstance({\n name: \"bitsocialReactHooks-repliesPages\",\n size: 500,\n});\n\n// reset all event listeners in between tests\nconst listeners: any = [];\n\ntype RepliesPagesState = {\n repliesPages: RepliesPages;\n comments: Comments;\n addNextRepliesPageToStore: Function;\n addRepliesPageCommentsToStore: Function;\n};\n\nconst repliesPagesStore = createStore<RepliesPagesState>(\n (setState: Function, getState: Function) => ({\n // TODO: eventually clear old pages and comments from memory\n repliesPages: {},\n comments: {},\n\n addNextRepliesPageToStore: async (\n comment: Comment,\n sortType: string | undefined,\n account: Account,\n ) => {\n assert(\n comment?.cid && typeof comment?.cid === \"string\",\n `repliesPagesStore.addNextRepliesPageToStore comment '${comment}' invalid`,\n );\n assert(\n sortType === undefined || (typeof sortType === \"string\" && sortType.length > 0),\n `repliesPagesStore.addNextRepliesPageToStore sortType '${sortType}' invalid`,\n );\n const resolvedSortType = resolveReplySortType(comment, sortType);\n if (!resolvedSortType) {\n return;\n }\n sortType = resolvedSortType;\n assert(\n typeof account?.pkc?.createComment === \"function\",\n `repliesPagesStore.addNextRepliesPageToStore account '${account}' invalid`,\n );\n\n // check the preloaded replies on comment.replies.pages first, then the comment.replies.pageCids\n const repliesFirstPageCid = getRepliesFirstPageCid(comment, sortType);\n if (!repliesFirstPageCid) {\n log(\n `repliesPagesStore.addNextRepliesPageToStore comment '${comment?.cid}' sortType '${sortType}' no repliesFirstPageCid`,\n );\n return;\n }\n\n // all replies pages in store\n const repliesPagesStore = getState();\n // only specific pages of the comment+sortType\n const repliesPages = getRepliesPages(comment, sortType, repliesPagesStore.repliesPages);\n\n // if no pages exist yet, add the first page\n let pageCidToAdd: string;\n if (!repliesPages.length) {\n pageCidToAdd = repliesFirstPageCid;\n } else {\n const nextCid = repliesPages[repliesPages.length - 1]?.nextCid;\n // if last nextCid is undefined, reached end of pages\n if (!nextCid) {\n log.trace(\"repliesPagesStore.addNextRepliesPageToStore no more pages\", {\n commentCid: comment.cid,\n sortType,\n account,\n });\n return;\n }\n\n pageCidToAdd = nextCid;\n }\n\n // page is already added or pending\n if (\n repliesPagesStore.repliesPages[pageCidToAdd] ||\n fetchPagePending[account.id + pageCidToAdd]\n ) {\n return;\n }\n\n fetchPagePending[account.id + pageCidToAdd] = true;\n let page: RepliesPage;\n try {\n page = await fetchPage(pageCidToAdd, comment, account);\n log.trace(\"repliesPagesStore.addNextRepliesPageToStore comment.replies.getPage\", {\n pageCid: pageCidToAdd,\n page,\n commentCid: comment.cid,\n communityAddress: comment.communityAddress,\n account,\n });\n } catch (e) {\n throw e;\n } finally {\n fetchPagePending[account.id + pageCidToAdd] = false;\n }\n\n // find new comments in the page (missing-or-fresher: insert when absent or incoming is fresher)\n const flattenedComments = utils.flattenCommentsPages(page);\n const { comments } = getState();\n let hasNewComments = false;\n const newComments: Comments = {};\n for (const comment of flattenedComments) {\n if (!comment.cid) continue;\n const existing = comments[comment.cid];\n const incomingFresh = Math.max(comment.updatedAt || 0, comment.timestamp || 0, 0);\n const existingFresh = existing\n ? Math.max(existing.updatedAt || 0, existing.timestamp || 0, 0)\n : -1;\n if (!existing || incomingFresh > existingFresh) {\n // don't clone the comment to save memory, comments remain a pointer to the page object\n newComments[comment.cid] = comment;\n hasNewComments = true;\n }\n }\n\n // add missing children replies feeds\n addChildrenRepliesFeedsToAddToStore(page, comment);\n\n setState(({ repliesPages, comments }: any) => {\n const newState: any = { repliesPages: { ...repliesPages, [pageCidToAdd]: page } };\n if (hasNewComments) {\n newState.comments = { ...comments, ...newComments };\n }\n return newState;\n });\n log(\"repliesPagesStore.addNextRepliesPageToStore\", {\n pageCid: pageCidToAdd,\n commentCid: comment.cid,\n sortType,\n page,\n account,\n });\n\n // when publishing a comment, you don't yet know its CID\n // so when a new comment is fetched, check to see if it's your own\n // comment, and if yes, add the CID to your account comments database\n for (const comment of flattenedComments) {\n accountsStore\n .getState()\n .accountsActionsInternal.addCidToAccountComment(comment)\n .catch((error: unknown) =>\n log.error(\"repliesPagesStore.addNextRepliesPageToStore addCidToAccountComment error\", {\n comment,\n error,\n }),\n );\n }\n },\n\n // comments contain preloaded pages, those page comments must be added separately\n addRepliesPageCommentsToStore: (comment: Comment) => {\n if (!comment.replies?.pages) {\n return;\n }\n\n // find new comments in the page (missing-or-fresher: insert when absent or incoming is fresher)\n const flattenedComments = utils.flattenCommentsPages(comment.replies.pages);\n const { comments } = getState();\n let hasNewComments = false;\n const newComments: Comments = {};\n for (const c of flattenedComments) {\n if (!c.cid) continue;\n const existing = comments[c.cid];\n const incomingFresh = Math.max(c.updatedAt || 0, c.timestamp || 0, 0);\n const existingFresh = existing\n ? Math.max(existing.updatedAt || 0, existing.timestamp || 0, 0)\n : -1;\n if (!existing || incomingFresh > existingFresh) {\n // don't clone the comment to save memory, comments remain a pointer to the page object\n newComments[c.cid] = c;\n hasNewComments = true;\n }\n }\n\n if (!hasNewComments) {\n return;\n }\n\n setState(({ comments }: any) => {\n return { comments: { ...comments, ...newComments } };\n });\n log(\"repliesPagesStore.addRepliesPageCommentsToStore\", { comment, newComments });\n },\n }),\n);\n\n// set clients states on comments store so the frontend can display it, dont persist in db because a reload cancels updating\nconst onCommentRepliesClientsStateChange =\n (commentCid: string) =>\n (clientState: string, clientType: string, sortType: string, clientUrl: string) => {\n commentsStore.setState((state: CommentsState) => {\n // make sure not undefined, sometimes happens in e2e tests\n if (!state.comments[commentCid]) {\n return {};\n }\n const client = { state: clientState };\n const comment = { ...state.comments[commentCid] };\n comment.replies = { ...comment.replies };\n comment.replies.clients = { ...comment.replies.clients };\n comment.replies.clients[clientType] = { ...comment.replies.clients[clientType] };\n comment.replies.clients[clientType][sortType] = {\n ...comment.replies.clients[clientType][sortType],\n };\n comment.replies.clients[clientType][sortType][clientUrl] = client;\n return { comments: { ...state.comments, [commentCid]: comment } };\n });\n };\n\nconst fetchPageComments: { [commentCid: string]: any } = {}; // cache pkc.createComment because sometimes it's slow\nlet fetchPagePending: { [key: string]: boolean } = {};\nconst fetchPage = async (pageCid: string, comment: Comment, account: Account) => {\n // replies page is cached\n const cachedRepliesPage = await repliesPagesDatabase.getItem(pageCid);\n if (cachedRepliesPage) {\n return cachedRepliesPage;\n }\n if (!fetchPageComments[comment.cid]) {\n fetchPageComments[comment.cid] = await account.pkc.createComment({\n cid: comment.cid,\n postCid: comment.postCid,\n communityAddress: comment.communityAddress,\n depth: comment.depth,\n });\n listeners.push(fetchPageComments[comment.cid]);\n\n // set clients states on communities store so the frontend can display it\n utils.pageClientsOnStateChange(\n fetchPageComments[comment.cid].replies?.clients,\n onCommentRepliesClientsStateChange(comment.cid),\n );\n }\n\n const onError = (error: any) =>\n log.error(\n `repliesPagesStore comment '${comment.cid}' failed comment.replies.getPage page cid '${pageCid}':`,\n error,\n );\n const fetchedRepliesPage = await utils.retryInfinity(\n () => fetchPageComments[comment.cid].replies.getPage({ cid: pageCid }),\n { onError },\n );\n await repliesPagesDatabase.setItem(pageCid, utils.clone(fetchedRepliesPage));\n return fetchedRepliesPage;\n};\n\n/**\n * Util function to get all pages in the store for a\n * specific comment+sortType using `RepliesPage.nextCid`\n */\nexport const getRepliesPages = (\n comment: Comment,\n sortType: string | undefined,\n repliesPages: RepliesPages,\n) => {\n assert(\n repliesPages && typeof repliesPages === \"object\",\n `getRepliesPages repliesPages '${repliesPages}' invalid`,\n );\n const pages: RepliesPage[] = [];\n const firstPageCid = getRepliesFirstPageCid(comment, sortType);\n // comment has no pages\n // TODO: if a loaded comment doesn't have a first page, it's unclear what we should do\n // should we try to use another sort type by default, like 'best', or should we just ignore it?\n // 'return pages' to ignore it for now\n if (!firstPageCid) {\n return pages;\n }\n const firstPage = repliesPages[firstPageCid];\n if (!firstPage) {\n return pages;\n }\n pages.push(firstPage);\n while (true) {\n const nextCid = pages[pages.length - 1]?.nextCid;\n const repliesPage = nextCid && repliesPages[nextCid];\n if (!repliesPage) {\n return pages;\n }\n pages.push(repliesPage);\n }\n};\n\nexport const getRepliesFirstPageCid = (comment: Comment, sortType?: string) => {\n assert(comment?.cid, `getRepliesFirstPageCid comment '${comment}' invalid`);\n assert(\n sortType === undefined || (typeof sortType === \"string\" && sortType.length > 0),\n `getRepliesFirstPageCid sortType '${sortType}' invalid`,\n );\n const resolvedSortType = resolveReplySortType(comment, sortType);\n if (!resolvedSortType) {\n return;\n }\n // comment has preloaded replies for sort type\n if (comment.replies?.pages?.[resolvedSortType]?.comments) {\n return comment.replies?.pages?.[resolvedSortType]?.nextCid;\n }\n return comment.replies?.pageCids?.[resolvedSortType];\n\n // TODO: if a loaded comment doesn't have a first page, it's unclear what we should do\n // should we try to use another sort type by default, like 'best', or should we just ignore it?\n};\n\n// reset store in between tests\nconst originalState = repliesPagesStore.getState();\n// async function because some stores have async init\nexport const resetRepliesPagesStore = async () => {\n fetchPagePending = {};\n // remove all event listeners\n listeners.forEach((listener: any) => listener.removeAllListeners());\n // destroy all component subscriptions to the store\n repliesPagesStore.destroy();\n // restore original state\n repliesPagesStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetRepliesPagesDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-repliesPages\" }).clear();\n await resetRepliesPagesStore();\n};\n\nexport default repliesPagesStore;\n"]}
1
+ {"version":3,"file":"replies-pages-store.js","sourceRoot":"","sources":["../../../src/stores/replies-pages/replies-pages-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,uDAAuD;AACvD,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAElE,OAAO,aAAa,MAAM,aAAa,CAAC;AACxC,OAAO,aAAgC,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,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,EAAE,QAAQ,CAAC,CAAC;IAC7D,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO;IACT,CAAC;IACD,8CAA8C;IAC9C,IAAI,MAAA,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,KAAK,0CAAG,YAAY,CAAC,0CAAE,QAAQ,EAAE,CAAC;QACrD,OAAO,MAAA,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,KAAK,0CAAG,YAAY,CAAC,0CAAE,OAAO,CAAC;IACzD,CAAC;IACD,OAAO,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,QAAQ,0CAAG,YAAY,CAAC,CAAC;IAEjD,sFAAsF;IACtF,+FAA+F;AACjG,CAAC,CAAC;AAEF,+BAA+B;AAC/B,MAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;AACnD,qDAAqD;AACrD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAS,EAAE;IAC/C,gBAAgB,GAAG,EAAE,CAAC;IACtB,6BAA6B;IAC7B,SAAS,CAAC,OAAO,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACpE,mDAAmD;IACnD,iBAAiB,CAAC,OAAO,EAAE,CAAC;IAC5B,yBAAyB;IACzB,iBAAiB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAS,EAAE;IAC1D,MAAM,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,kCAAkC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IAC1F,MAAM,sBAAsB,EAAE,CAAC;AACjC,CAAC,CAAA,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import utils from \"../../lib/utils\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\n// include replies pages store with feeds for debugging\nexport const log = Logger(\"bitsocial-react-hooks:replies:stores\");\nimport { RepliesPage, RepliesPages, Account, Comment, Comments } from \"../../types\";\nimport accountsStore from \"../accounts\";\nimport commentsStore, { CommentsState } from \"../comments\";\nimport { addChildrenRepliesFeedsToAddToStore } from \"./utils\";\nimport localForageLru from \"../../lib/localforage-lru\";\nimport createStore from \"zustand\";\nimport assert from \"assert\";\nimport { getReplyPageSortType, resolveReplySortType } from \"../../lib/page-sorts\";\n\nconst repliesPagesDatabase = localForageLru.createInstance({\n name: \"bitsocialReactHooks-repliesPages\",\n size: 500,\n});\n\n// reset all event listeners in between tests\nconst listeners: any = [];\n\ntype RepliesPagesState = {\n repliesPages: RepliesPages;\n comments: Comments;\n addNextRepliesPageToStore: Function;\n addRepliesPageCommentsToStore: Function;\n};\n\nconst repliesPagesStore = createStore<RepliesPagesState>(\n (setState: Function, getState: Function) => ({\n // TODO: eventually clear old pages and comments from memory\n repliesPages: {},\n comments: {},\n\n addNextRepliesPageToStore: async (\n comment: Comment,\n sortType: string | undefined,\n account: Account,\n ) => {\n assert(\n comment?.cid && typeof comment?.cid === \"string\",\n `repliesPagesStore.addNextRepliesPageToStore comment '${comment}' invalid`,\n );\n assert(\n sortType === undefined || (typeof sortType === \"string\" && sortType.length > 0),\n `repliesPagesStore.addNextRepliesPageToStore sortType '${sortType}' invalid`,\n );\n const resolvedSortType = resolveReplySortType(comment, sortType);\n if (!resolvedSortType) {\n return;\n }\n sortType = resolvedSortType;\n assert(\n typeof account?.pkc?.createComment === \"function\",\n `repliesPagesStore.addNextRepliesPageToStore account '${account}' invalid`,\n );\n\n // check the preloaded replies on comment.replies.pages first, then the comment.replies.pageCids\n const repliesFirstPageCid = getRepliesFirstPageCid(comment, sortType);\n if (!repliesFirstPageCid) {\n log(\n `repliesPagesStore.addNextRepliesPageToStore comment '${comment?.cid}' sortType '${sortType}' no repliesFirstPageCid`,\n );\n return;\n }\n\n // all replies pages in store\n const repliesPagesStore = getState();\n // only specific pages of the comment+sortType\n const repliesPages = getRepliesPages(comment, sortType, repliesPagesStore.repliesPages);\n\n // if no pages exist yet, add the first page\n let pageCidToAdd: string;\n if (!repliesPages.length) {\n pageCidToAdd = repliesFirstPageCid;\n } else {\n const nextCid = repliesPages[repliesPages.length - 1]?.nextCid;\n // if last nextCid is undefined, reached end of pages\n if (!nextCid) {\n log.trace(\"repliesPagesStore.addNextRepliesPageToStore no more pages\", {\n commentCid: comment.cid,\n sortType,\n account,\n });\n return;\n }\n\n pageCidToAdd = nextCid;\n }\n\n // page is already added or pending\n if (\n repliesPagesStore.repliesPages[pageCidToAdd] ||\n fetchPagePending[account.id + pageCidToAdd]\n ) {\n return;\n }\n\n fetchPagePending[account.id + pageCidToAdd] = true;\n let page: RepliesPage;\n try {\n page = await fetchPage(pageCidToAdd, comment, account);\n log.trace(\"repliesPagesStore.addNextRepliesPageToStore comment.replies.getPage\", {\n pageCid: pageCidToAdd,\n page,\n commentCid: comment.cid,\n communityAddress: comment.communityAddress,\n account,\n });\n } catch (e) {\n throw e;\n } finally {\n fetchPagePending[account.id + pageCidToAdd] = false;\n }\n\n // find new comments in the page (missing-or-fresher: insert when absent or incoming is fresher)\n const flattenedComments = utils.flattenCommentsPages(page);\n const { comments } = getState();\n let hasNewComments = false;\n const newComments: Comments = {};\n for (const comment of flattenedComments) {\n if (!comment.cid) continue;\n const existing = comments[comment.cid];\n const incomingFresh = Math.max(comment.updatedAt || 0, comment.timestamp || 0, 0);\n const existingFresh = existing\n ? Math.max(existing.updatedAt || 0, existing.timestamp || 0, 0)\n : -1;\n if (!existing || incomingFresh > existingFresh) {\n // don't clone the comment to save memory, comments remain a pointer to the page object\n newComments[comment.cid] = comment;\n hasNewComments = true;\n }\n }\n\n // add missing children replies feeds\n addChildrenRepliesFeedsToAddToStore(page, comment);\n\n setState(({ repliesPages, comments }: any) => {\n const newState: any = { repliesPages: { ...repliesPages, [pageCidToAdd]: page } };\n if (hasNewComments) {\n newState.comments = { ...comments, ...newComments };\n }\n return newState;\n });\n log(\"repliesPagesStore.addNextRepliesPageToStore\", {\n pageCid: pageCidToAdd,\n commentCid: comment.cid,\n sortType,\n page,\n account,\n });\n\n // when publishing a comment, you don't yet know its CID\n // so when a new comment is fetched, check to see if it's your own\n // comment, and if yes, add the CID to your account comments database\n for (const comment of flattenedComments) {\n accountsStore\n .getState()\n .accountsActionsInternal.addCidToAccountComment(comment)\n .catch((error: unknown) =>\n log.error(\"repliesPagesStore.addNextRepliesPageToStore addCidToAccountComment error\", {\n comment,\n error,\n }),\n );\n }\n },\n\n // comments contain preloaded pages, those page comments must be added separately\n addRepliesPageCommentsToStore: (comment: Comment) => {\n if (!comment.replies?.pages) {\n return;\n }\n\n // find new comments in the page (missing-or-fresher: insert when absent or incoming is fresher)\n const flattenedComments = utils.flattenCommentsPages(comment.replies.pages);\n const { comments } = getState();\n let hasNewComments = false;\n const newComments: Comments = {};\n for (const c of flattenedComments) {\n if (!c.cid) continue;\n const existing = comments[c.cid];\n const incomingFresh = Math.max(c.updatedAt || 0, c.timestamp || 0, 0);\n const existingFresh = existing\n ? Math.max(existing.updatedAt || 0, existing.timestamp || 0, 0)\n : -1;\n if (!existing || incomingFresh > existingFresh) {\n // don't clone the comment to save memory, comments remain a pointer to the page object\n newComments[c.cid] = c;\n hasNewComments = true;\n }\n }\n\n if (!hasNewComments) {\n return;\n }\n\n setState(({ comments }: any) => {\n return { comments: { ...comments, ...newComments } };\n });\n log(\"repliesPagesStore.addRepliesPageCommentsToStore\", { comment, newComments });\n },\n }),\n);\n\n// set clients states on comments store so the frontend can display it, dont persist in db because a reload cancels updating\nconst onCommentRepliesClientsStateChange =\n (commentCid: string) =>\n (clientState: string, clientType: string, sortType: string, clientUrl: string) => {\n commentsStore.setState((state: CommentsState) => {\n // make sure not undefined, sometimes happens in e2e tests\n if (!state.comments[commentCid]) {\n return {};\n }\n const client = { state: clientState };\n const comment = { ...state.comments[commentCid] };\n comment.replies = { ...comment.replies };\n comment.replies.clients = { ...comment.replies.clients };\n comment.replies.clients[clientType] = { ...comment.replies.clients[clientType] };\n comment.replies.clients[clientType][sortType] = {\n ...comment.replies.clients[clientType][sortType],\n };\n comment.replies.clients[clientType][sortType][clientUrl] = client;\n return { comments: { ...state.comments, [commentCid]: comment } };\n });\n };\n\nconst fetchPageComments: { [commentCid: string]: any } = {}; // cache pkc.createComment because sometimes it's slow\nlet fetchPagePending: { [key: string]: boolean } = {};\nconst fetchPage = async (pageCid: string, comment: Comment, account: Account) => {\n // replies page is cached\n const cachedRepliesPage = await repliesPagesDatabase.getItem(pageCid);\n if (cachedRepliesPage) {\n return cachedRepliesPage;\n }\n if (!fetchPageComments[comment.cid]) {\n fetchPageComments[comment.cid] = await account.pkc.createComment({\n cid: comment.cid,\n postCid: comment.postCid,\n communityAddress: comment.communityAddress,\n depth: comment.depth,\n });\n listeners.push(fetchPageComments[comment.cid]);\n\n // set clients states on communities store so the frontend can display it\n utils.pageClientsOnStateChange(\n fetchPageComments[comment.cid].replies?.clients,\n onCommentRepliesClientsStateChange(comment.cid),\n );\n }\n\n const onError = (error: any) =>\n log.error(\n `repliesPagesStore comment '${comment.cid}' failed comment.replies.getPage page cid '${pageCid}':`,\n error,\n );\n const fetchedRepliesPage = await utils.retryInfinity(\n () => fetchPageComments[comment.cid].replies.getPage({ cid: pageCid }),\n { onError },\n );\n await repliesPagesDatabase.setItem(pageCid, utils.clone(fetchedRepliesPage));\n return fetchedRepliesPage;\n};\n\n/**\n * Util function to get all pages in the store for a\n * specific comment+sortType using `RepliesPage.nextCid`\n */\nexport const getRepliesPages = (\n comment: Comment,\n sortType: string | undefined,\n repliesPages: RepliesPages,\n) => {\n assert(\n repliesPages && typeof repliesPages === \"object\",\n `getRepliesPages repliesPages '${repliesPages}' invalid`,\n );\n const pages: RepliesPage[] = [];\n const firstPageCid = getRepliesFirstPageCid(comment, sortType);\n // comment has no pages\n // TODO: if a loaded comment doesn't have a first page, it's unclear what we should do\n // should we try to use another sort type by default, like 'best', or should we just ignore it?\n // 'return pages' to ignore it for now\n if (!firstPageCid) {\n return pages;\n }\n const firstPage = repliesPages[firstPageCid];\n if (!firstPage) {\n return pages;\n }\n pages.push(firstPage);\n while (true) {\n const nextCid = pages[pages.length - 1]?.nextCid;\n const repliesPage = nextCid && repliesPages[nextCid];\n if (!repliesPage) {\n return pages;\n }\n pages.push(repliesPage);\n }\n};\n\nexport const getRepliesFirstPageCid = (comment: Comment, sortType?: string) => {\n assert(comment?.cid, `getRepliesFirstPageCid comment '${comment}' invalid`);\n assert(\n sortType === undefined || (typeof sortType === \"string\" && sortType.length > 0),\n `getRepliesFirstPageCid sortType '${sortType}' invalid`,\n );\n // replies served client-side from a complete preloaded page read that page instead of their own\n const pageSortType = getReplyPageSortType(comment, sortType);\n if (!pageSortType) {\n return;\n }\n // comment has preloaded replies for sort type\n if (comment.replies?.pages?.[pageSortType]?.comments) {\n return comment.replies?.pages?.[pageSortType]?.nextCid;\n }\n return comment.replies?.pageCids?.[pageSortType];\n\n // TODO: if a loaded comment doesn't have a first page, it's unclear what we should do\n // should we try to use another sort type by default, like 'best', or should we just ignore it?\n};\n\n// reset store in between tests\nconst originalState = repliesPagesStore.getState();\n// async function because some stores have async init\nexport const resetRepliesPagesStore = async () => {\n fetchPagePending = {};\n // remove all event listeners\n listeners.forEach((listener: any) => listener.removeAllListeners());\n // destroy all component subscriptions to the store\n repliesPagesStore.destroy();\n // restore original state\n repliesPagesStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetRepliesPagesDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-repliesPages\" }).clear();\n await resetRepliesPagesStore();\n};\n\nexport default repliesPagesStore;\n"]}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
- "version": "0.1.45",
17
+ "version": "0.1.47",
18
18
  "packageManager": "yarn@4.13.0",
19
19
  "files": [
20
20
  "CHANGELOG.md",
@@ -56,7 +56,10 @@
56
56
  "prettier": "oxfmt src/**/*.{js,ts,tsx} test/**/*.{js,ts,tsx} config/**/*.{js,ts,tsx}",
57
57
  "type-check": "node ./node_modules/typescript/bin/tsc --noEmit --project config/tsconfig.json",
58
58
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
59
- "changelog:release-notes": "node scripts/changelog-release-notes.mjs"
59
+ "changelog:release-notes": "node scripts/changelog-release-notes.mjs",
60
+ "ai-workflow:sync": "node scripts/sync-ai-workflow.mjs",
61
+ "ai-workflow:check": "node scripts/validate-ai-workflow.mjs",
62
+ "ai-workflow:test": "node --test scripts/__tests__/ai-workflow.node-test.mjs scripts/__tests__/agent-hooks.node-test.mjs"
60
63
  },
61
64
  "dependencies": {
62
65
  "@bitsocial/bso-resolver": "0.0.10",
@@ -86,7 +89,7 @@
86
89
  "axios": "1.18.0",
87
90
  "vite": "8.0.16",
88
91
  "tar": "7.5.22",
89
- "undici": "7.29.0",
92
+ "undici": "7.29.1",
90
93
  "minimatch": "3.1.4",
91
94
  "brace-expansion@npm:^1.1.7": "1.1.18",
92
95
  "browserslist": "4.28.7",
@@ -104,16 +107,16 @@
104
107
  "tmp": "0.2.7",
105
108
  "@tootallnate/once": "3.0.1",
106
109
  "@protobufjs/utf8": "1.1.1",
107
- "@libp2p/gossipsub": "16.0.4",
110
+ "@libp2p/gossipsub": "16.0.5",
108
111
  "@libp2p/kad-dht": "16.2.6",
109
- "fast-uri": "3.1.6",
110
- "ip-address": "10.3.1",
112
+ "fast-uri": "3.1.7",
113
+ "ip-address": "10.5.1",
111
114
  "nanoid@npm:^3.3.16": "3.3.18",
112
115
  "nanoid@npm:^5.0.7": "5.1.16",
113
116
  "nanoid@npm:^5.1.5": "5.1.16",
114
117
  "ws": "8.21.0",
115
118
  "form-data": "4.0.6",
116
- "js-yaml": "4.3.1"
119
+ "js-yaml": "4.3.2"
117
120
  },
118
121
  "devDependencies": {
119
122
  "@testing-library/dom": "10.4.1",
@@ -124,14 +127,16 @@
124
127
  "@types/node": "22.19.21",
125
128
  "@types/react": "19.1.6",
126
129
  "@types/react-dom": "19.1.6",
127
- "@vitest/browser": "4.1.10",
128
- "@vitest/browser-playwright": "4.1.10",
129
- "@vitest/coverage-istanbul": "4.1.10",
130
+ "@vitest/browser": "4.1.11",
131
+ "@vitest/browser-playwright": "4.1.11",
132
+ "@vitest/coverage-istanbul": "4.1.11",
130
133
  "commitizen": "4.3.1",
131
134
  "conventional-changelog-cli": "4.1.0",
132
135
  "cross-env": "10.0.0",
136
+ "cross-spawn": "7.0.6",
133
137
  "cz-conventional-changelog": "3.3.0",
134
138
  "husky": "4.3.8",
139
+ "js-yaml": "4.3.2",
135
140
  "jsdom": "27.3.0",
136
141
  "knip": "6.17.0",
137
142
  "kubo": "0.43.0",
@@ -141,11 +146,12 @@
141
146
  "playwright": "1.56.1",
142
147
  "react": "19.1.0",
143
148
  "react-dom": "19.1.0",
149
+ "smol-toml": "1.7.1",
144
150
  "tcp-port-used": "1.0.2",
145
151
  "tempy": "1.0.1",
146
152
  "typescript": "6.0.3",
147
153
  "vite": "8.0.16",
148
- "vitest": "4.1.10",
154
+ "vitest": "4.1.11",
149
155
  "wait-on": "9.0.3"
150
156
  },
151
157
  "lint-staged": {