@bitsocial/bitsocial-react-hooks 0.1.50 → 0.1.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [0.1.52](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.51...v0.1.52) (2026-10-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **accounts:** keep the published author on pseudonymous account comments (release 0.1.52) ([792b83c](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/792b83c9451d39b92b63effe59e46861809b0053))
7
+
8
+
9
+
10
+ ## [0.1.51](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.50...v0.1.51) (2026-10-16)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **feeds:** keep a community's order for a sort file under a built-in name (release 0.1.51) ([a06f8e5](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/a06f8e59a9024b409948be3f4f4da0a5e7506787))
16
+
17
+
18
+
1
19
  ## [0.1.50](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.49...v0.1.50) (2026-10-14)
2
20
 
3
21
 
package/README.md CHANGED
@@ -170,7 +170,7 @@ useBufferedFeeds({feedsOptions: UseFeedOptions[]}) // preload or buffer feeds in
170
170
  `useFeed().reset()` clears the current feed and refreshes the latest community snapshots before rebuilding it.
171
171
  `useFeed().expandTimeWindow(newerThan)` broadens `newerThan` in place without constructing a different sort name, so older posts can be appended without replacing the feed instance.
172
172
 
173
- Feed and reply sort names are defined by each community record, not by a fixed hooks allowlist. Omit `sortType` to use the preloaded page, or discover the requestable names with `getAvailablePostSortTypes(community)` and `getAvailableReplySortTypes(comment)`. pkc-js preloads a single sort and only publishes `pageCids` once that page overflows, so when every post or reply fits in the preloaded page the standard sorts (`hot`, `new`, `active` and `top*` for posts; `best`, `new`, `old`, `newFlat` and `oldFlat` for replies) are also requestable and are sorted client-side from that page, including the time window of `top*` timeframe sorts. `getPostPageSortType(community, sortType)` and `getReplyPageSortType(comment, sortType)` return the page that serves a sort. A requested sort that is neither published nor computable client-side is not silently replaced with another sort. Hooks preserve protocol page order for unknown custom sorts because their scoring algorithm is not available to the client.
173
+ Feed and reply sort names are defined by each community record, not by a fixed hooks allowlist. Omit `sortType` to use the preloaded page, or discover the requestable names with `getAvailablePostSortTypes(community)` and `getAvailableReplySortTypes(comment)`. pkc-js preloads a single sort and only publishes `pageCids` once that page overflows, so when every post or reply fits in the preloaded page the standard sorts (`hot`, `new`, `active` and `top*` for posts; `best`, `new`, `old`, `newFlat` and `oldFlat` for replies) are also requestable and are sorted client-side from that page, including the time window of `top*` timeframe sorts. `getPostPageSortType(community, sortType)` and `getReplyPageSortType(comment, sortType)` return the page that serves a sort. A requested sort that is neither published nor computable client-side is not silently replaced with another sort. Hooks preserve protocol page order for unknown custom sorts because their scoring algorithm is not available to the client. The same applies to a sort file that a community publishes under a built-in name (for example a keyword no-bump `active`), which `community.pageSorts.posts[sortType]` reveals through a different `name` or options of its own: a single-community feed reading that sort's pages keeps the community's page order, while a feed merging several communities still orders them with the built-in sorter of that name.
174
174
 
175
175
  #### Actions Hooks
176
176
 
@@ -1065,6 +1065,7 @@ for (const accountComment of accountComments) {
1065
1065
  }
1066
1066
  // `state` becomes `failed` as soon as a pending local publish records terminal failure (`publishingState === "failed"` and `state === "stopped"`) or a publish error, instead of waiting for the 20-minute fallback.
1067
1067
  // local account comments returned by useAccountComment and useAccountComments include the account author's address and shortAddress when an older cached account comment is missing author identity fields.
1068
+ // comments published in a pseudonymous community (comment.pseudonymityMode is set) keep their community-assigned author instead, because the account identity was never published.
1068
1069
  // note: accountComment.index can change after deletions; prefer commentCid for stable identifiers
1069
1070
 
1070
1071
  // all my own votes
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../src/hooks/accounts/accounts.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,OAAO,EAKP,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uBAAuB,CAgD7F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,qBAAqB,CA8GvF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CAyBpF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,qBAAqB,CA0DvF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,sBAAsB,CA4J1F;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,wBAAwB,CA+ChG"}
@@ -301,7 +301,9 @@ const getAccountCommentWithAccountAuthor = (accountComment, account, accountId)
301
301
  if (!accountId ||
302
302
  accountComment.accountId !== accountId ||
303
303
  !(accountAuthor === null || accountAuthor === void 0 ? void 0 : accountAuthor.address) ||
304
- ((_a = accountComment.author) === null || _a === void 0 ? void 0 : _a.address)) {
304
+ ((_a = accountComment.author) === null || _a === void 0 ? void 0 : _a.address) ||
305
+ // a pseudonymous community published the comment under an alias, never the account identity
306
+ accountComment.pseudonymityMode) {
305
307
  return accountComment;
306
308
  }
307
309
  const accountShortAddress = accountAuthor.shortAddress || PkcJs.PKC.getShortAddress({ address: accountAuthor.address });
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/hooks/accounts/accounts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,C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AAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAErC,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,KAAK;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM;KACP,CAAC,EACF,CAAC,KAAK,EAAE,MAAM,CAAC,CAChB,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo, useState, useEffect } from \"react\";\nimport isEqual from \"lodash.isequal\";\nimport useAccountsStore from \"../../stores/accounts\";\nimport useCommunitiesStore from \"../../stores/communities\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:hooks\");\nimport assert from \"assert\";\nimport { useListCommunities, useCommunities } from \"../communities\";\nimport type {\n AccountComment,\n AccountComments,\n Account,\n Accounts,\n AccountVote,\n AccountsComments,\n AccountsCommentsReplies,\n UseAccountCommunitiesOptions,\n UseAccountCommunitiesResult,\n UseAccountVoteOptions,\n UseAccountVoteResult,\n UseAccountVotesOptions,\n UseAccountVotesResult,\n UseAccountCommentsOptions,\n UseAccountCommentsResult,\n UseAccountCommentOptions,\n UseAccountCommentResult,\n UseNotificationsOptions,\n UseNotificationsResult,\n UseAccountEditsOptions,\n UseAccountEditsResult,\n UseEditedCommentOptions,\n UseEditedCommentResult,\n UseAccountOptions,\n UseAccountResult,\n UsePubsubSubscribeOptions,\n UsePubsubSubscribeResult,\n} from \"../../types\";\nimport {\n useAccountsWithCalculatedProperties,\n useAccountWithCalculatedProperties,\n useCalculatedNotifications,\n} from \"./utils\";\nimport {\n COMMENT_MODERATION_AUTHOR_SUMMARY_KEY,\n getAccountEditPropertySummary,\n} from \"../../stores/accounts/utils\";\nimport {\n getCanonicalCommunityAddress,\n getEquivalentCommunityAddressGroupKey,\n pickPreferredEquivalentCommunityAddress,\n} from \"../../lib/community-address\";\nimport { addCommentModeration } from \"../../lib/utils/comment-moderation\";\nimport useInterval from \"../utils/use-interval\";\nimport PkcJs from \"../../lib/pkc-js\";\n\nconst getCommentEditPropertyValue = (comment: any, propertyName: string) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n return comment?.[propertyName];\n }\n\n const commentModeration = comment?.commentModeration;\n if (\n commentModeration &&\n typeof commentModeration === \"object\" &&\n Object.prototype.hasOwnProperty.call(commentModeration, \"author\")\n ) {\n return commentModeration.author;\n }\n\n return comment?.author?.community?.banExpiresAt !== undefined\n ? { banExpiresAt: comment.author.community.banExpiresAt }\n : undefined;\n};\n\nconst applyEditedCommentProperty = (comment: any, propertyName: string, value: any) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n comment[propertyName] = value;\n return;\n }\n\n comment.commentModeration = comment.commentModeration ? { ...comment.commentModeration } : {};\n if (value === undefined) {\n delete comment.commentModeration.author;\n } else {\n comment.commentModeration.author = value;\n }\n\n comment.author = comment.author ? { ...comment.author } : {};\n comment.author.community = comment.author.community ? { ...comment.author.community } : {};\n if (value?.banExpiresAt === undefined) {\n delete comment.author.community.banExpiresAt;\n } else {\n comment.author.community.banExpiresAt = value.banExpiresAt;\n }\n};\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, return\n * the active account id.\n */\nexport function useAccountId(accountName?: string) {\n const accountId = useAccountsStore((state) => state.accountNamesToAccountIds[accountName || \"\"]);\n // don't consider active account if account name is defined\n const activeAccountId = useAccountsStore((state) => !accountName && state.activeAccountId);\n const accountIdToUse = accountName ? accountId : activeAccountId;\n return accountIdToUse;\n}\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, return\n * the active account.\n */\nexport function useAccount(options?: UseAccountOptions): UseAccountResult {\n assert(\n !options || typeof options === \"object\",\n `useAccount options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const accountStore = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const account = useAccountWithCalculatedProperties(\n accountStore,\n accountComments,\n accountCommentsReplies,\n );\n log(\"useAccount\", { accountId, account, accountName });\n return account;\n}\n\n/**\n * Return all accounts in the order of `accountsStore.accountIds`. To reorder, use `accountsActions.setAccountsOrder(accountNames)`.\n */\nexport function useAccounts() {\n const accountIds = useAccountsStore((state) => state.accountIds);\n const accountsStore = useAccountsStore((state) => state.accounts);\n const accountsComments = useAccountsStore((state) => state.accountsComments);\n const accountsCommentsReplies = useAccountsStore((state) => state.accountsCommentsReplies);\n const accounts = useAccountsWithCalculatedProperties(\n accountsStore,\n accountsComments,\n accountsCommentsReplies,\n );\n const accountsArray: Account[] = useMemo(() => {\n const accountsArray = [];\n if (accountIds?.length && accounts) {\n for (const accountId of accountIds) {\n accountsArray.push(accounts[accountId]);\n }\n }\n return accountsArray;\n }, [accounts, accountIds]);\n\n log(\"useAccounts\", { accounts, accountIds });\n\n const state = accountsArray?.length ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accounts: accountsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [accountsArray, state],\n );\n}\n\n/**\n * Returns all communities where the account is a creator or moderator\n */\nexport function useAccountCommunities(\n options?: UseAccountCommunitiesOptions,\n): UseAccountCommunitiesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountCommunities options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, onlyIfCached } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const accountsStoreAccountCommunities = useAccountsStore(\n (state) => state.accounts[accountIdKey]?.communities,\n );\n\n // get all unique account community addresses\n const ownerCommunityAddresses = useListCommunities(accountName);\n const groupedCommunityAddresses = useMemo(() => {\n const accountCommunityAddresses = [];\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n accountCommunityAddresses.push(communityAddress);\n }\n }\n const allCommunityAddresses = [\n ...new Set([...ownerCommunityAddresses, ...accountCommunityAddresses]),\n ].sort();\n const groupedAddresses = new Map<string, string[]>();\n for (const communityAddress of allCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const addresses = groupedAddresses.get(groupKey);\n if (addresses) {\n addresses.push(communityAddress);\n } else {\n groupedAddresses.set(groupKey, [communityAddress]);\n }\n }\n return [...groupedAddresses.entries()].map(([groupKey, addresses]) => ({\n groupKey,\n addresses,\n preferredAddress: pickPreferredEquivalentCommunityAddress(addresses),\n }));\n }, [accountsStoreAccountCommunities, ownerCommunityAddresses]);\n const uniqueCommunityAddresses = useMemo(\n () => groupedCommunityAddresses.map(({ preferredAddress }) => preferredAddress),\n [groupedCommunityAddresses],\n );\n\n // fetch all community data\n const {\n communities: communitiesArray,\n state: communitiesState,\n error: communitiesError,\n errors: communitiesErrors,\n } = useCommunities({\n communities: uniqueCommunityAddresses.map((communityAddress) => ({ name: communityAddress })),\n accountName,\n onlyIfCached,\n });\n const communityFetchErrors = useCommunitiesStore((state: any) =>\n uniqueCommunityAddresses.flatMap((communityAddress) => state.errors[communityAddress] || []),\n );\n const canonicalAddressByGroupKey = useMemo(() => {\n const canonicalAddresses: { [groupKey: string]: string } = {};\n for (const [i, { groupKey, preferredAddress }] of groupedCommunityAddresses.entries()) {\n const fetchedAddress = communitiesArray[i]?.address;\n canonicalAddresses[groupKey] = getCanonicalCommunityAddress(\n fetchedAddress || preferredAddress,\n );\n }\n return canonicalAddresses;\n }, [groupedCommunityAddresses, communitiesArray]);\n const communities: any = useMemo(() => {\n const communities: any = {};\n for (const [i, community] of communitiesArray.entries()) {\n const { groupKey, preferredAddress } = groupedCommunityAddresses[i];\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n communities[canonicalAddress] = {\n ...communities[canonicalAddress],\n ...community,\n // make sure the canonical address is defined even if the community hasn't fetched yet\n address: canonicalAddress,\n };\n }\n return communities;\n }, [communitiesArray, groupedCommunityAddresses, canonicalAddressByGroupKey]);\n\n // merged community data with account.communities data\n const accountCommunities: any = useMemo(() => {\n const accountCommunities: any = { ...communities };\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n ...accountsStoreAccountCommunities[communityAddress],\n address: canonicalAddress,\n };\n }\n }\n // add pkc.communities data\n for (const communityAddress of ownerCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n address: canonicalAddress,\n role: { role: \"owner\" },\n };\n }\n return accountCommunities;\n }, [\n accountsStoreAccountCommunities,\n ownerCommunityAddresses,\n communities,\n canonicalAddressByGroupKey,\n ]);\n\n if (accountId) {\n log(\"useAccountCommunities\", { accountCommunities });\n }\n\n const pendingAccountCommunities = Object.values(accountCommunities).some(\n (community: any) => community?.address && !community?.updatedAt,\n );\n const errors = communityFetchErrors.length ? communityFetchErrors : communitiesErrors;\n const error = communitiesError || errors[errors.length - 1];\n const state = !accountId\n ? \"initializing\"\n : error\n ? \"failed\"\n : pendingAccountCommunities\n ? \"fetching-ipns\"\n : communitiesState;\n\n return useMemo(\n () => ({\n accountCommunities,\n state,\n error,\n errors,\n }),\n [accountCommunities, state, error, errors],\n );\n}\n\n/**\n * Returns an account's notifications in an array. Unread notifications have a field markedAsRead: false.\n *\n * @param accountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, return\n * the active account's notifications.\n */\nexport function useNotifications(options?: UseNotificationsOptions): UseNotificationsResult {\n assert(\n !options || typeof options === \"object\",\n `useNotifications options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const accountsActionsInternal = useAccountsStore((state) => state.accountsActionsInternal);\n const notifications = useCalculatedNotifications(account, accountCommentsReplies);\n const [errors, setErrors] = useState<Error[]>([]);\n\n const markAsRead = async () => {\n try {\n if (!account) {\n throw Error(\"useNotifications cannot mark as read accounts not initalized yet\");\n }\n accountsActionsInternal.markNotificationsAsRead(account);\n } catch (e: any) {\n setErrors([...errors, e]);\n }\n };\n\n if (account) {\n log(\"useNotifications\", { notifications });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n notifications,\n markAsRead,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [notifications, errors],\n );\n}\n\nconst getAccountCommentsStates = (accountComments: AccountComment[]) => {\n // Without a cid, the account comment is still a local pending publish. pkc-js marks\n // terminal publish failures when `publishingState === \"failed\"` and publication `state`\n // is `\"stopped\"`, so we derive failed from that terminal pair or recorded publish errors.\n const now = Math.round(Date.now() / 1000);\n const expiryTime = now - 60 * 20;\n\n const states: string[] = [];\n for (const accountComment of accountComments) {\n let state = \"succeeded\";\n if (!accountComment.cid) {\n const ac = accountComment as AccountComment & {\n error?: Error;\n errors?: Error[];\n publishingState?: string;\n state?: string;\n };\n const resolvedPublishFailed =\n (ac.publishingState === \"failed\" && ac.state === \"stopped\") ||\n ac.error != null ||\n (Array.isArray(ac.errors) && ac.errors.length > 0);\n\n if (resolvedPublishFailed) {\n state = \"failed\";\n } else if (accountComment.timestamp > expiryTime) {\n state = \"pending\";\n } else {\n state = \"failed\";\n }\n }\n states.push(state);\n }\n\n return states;\n};\n\nexport const haveAccountCommentStatesChanged = (nextStates: string[], previousStates: string[]) =>\n nextStates.toString() !== previousStates.toString();\n\nconst getAccountHistorySortType = (\n sortType?: \"new\" | \"old\",\n order?: \"asc\" | \"desc\",\n): \"new\" | \"old\" => {\n if (sortType === \"new\" || sortType === \"old\") {\n return sortType;\n }\n return order === \"desc\" ? \"new\" : \"old\";\n};\n\nconst getAccountCommentWithAccountAuthor = (\n accountComment: AccountComment,\n account?: Account,\n accountId?: string,\n): AccountComment => {\n const accountAuthor = account?.author;\n if (\n !accountId ||\n accountComment.accountId !== accountId ||\n !accountAuthor?.address ||\n accountComment.author?.address\n ) {\n return accountComment;\n }\n\n const accountShortAddress =\n accountAuthor.shortAddress || PkcJs.PKC.getShortAddress({ address: accountAuthor.address });\n\n return {\n ...accountComment,\n author: {\n ...accountAuthor,\n ...accountComment.author,\n address: accountAuthor.address,\n ...(accountShortAddress ? { shortAddress: accountShortAddress } : {}),\n },\n };\n};\n\nexport function useAccountComments(options?: UseAccountCommentsOptions): UseAccountCommentsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComments options argument '${options}' not an object`,\n );\n const {\n accountName,\n filter,\n commentCid,\n commentIndices,\n communityAddress,\n parentCid,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = options || {};\n assert(\n !filter || typeof filter === \"function\",\n `useAccountComments options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountCommentsIndexes = useAccountsStore(\n (state) => state.accountsCommentsIndexes[accountId || \"\"],\n );\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const [accountCommentStates, setAccountCommentStates] = useState<string[]>([]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountComments = useMemo(() => {\n if (!accountComments) {\n return [];\n }\n\n let scopedAccountComments = accountComments;\n if (Array.isArray(commentIndices) && commentIndices.length > 0) {\n const normalizedCommentIndices = commentIndices\n .map((commentIndex) => Number(commentIndex))\n .filter((commentIndex) => Number.isInteger(commentIndex) && commentIndex >= 0);\n scopedAccountComments = normalizedCommentIndices\n .map((commentIndex) => accountComments[commentIndex])\n .filter(Boolean);\n } else if (commentCid) {\n const mappedIndex =\n commentCidToAccountComment?.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n scopedAccountComments =\n typeof mappedIndex === \"number\" ? [accountComments[mappedIndex]].filter(Boolean) : [];\n } else if (parentCid) {\n const parentIndexes = accountCommentsIndexes?.byParentCid?.[parentCid];\n scopedAccountComments = parentIndexes?.length\n ? parentIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter((accountComment) => accountComment.parentCid === parentCid);\n } else if (communityAddress) {\n const communityIndexes = accountCommentsIndexes?.byCommunityAddress?.[communityAddress];\n scopedAccountComments = communityIndexes?.length\n ? communityIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter(\n (accountComment) => accountComment.communityAddress === communityAddress,\n );\n }\n\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n scopedAccountComments = scopedAccountComments.filter(\n (accountComment) => accountComment.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n scopedAccountComments = scopedAccountComments.filter(filter);\n }\n if (accountHistorySortType === \"new\") {\n scopedAccountComments = [...scopedAccountComments].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n return scopedAccountComments.slice(startIndex, startIndex + pageSize);\n }\n return scopedAccountComments;\n }, [\n accountComments,\n accountCommentsIndexes,\n accountId,\n commentCid,\n commentIndices,\n commentCidToAccountComment,\n communityAddress,\n filter,\n newerThan,\n accountHistorySortType,\n page,\n pageSize,\n parentCid,\n ]);\n\n // Recheck periodically so the 20-minute “stale pending → failed” transition updates without other store events\n const delay = 60_000;\n const immediate = false;\n useInterval(\n () => {\n const states = getAccountCommentsStates(filteredAccountComments);\n if (haveAccountCommentStatesChanged(states, accountCommentStates)) {\n setAccountCommentStates(states);\n }\n },\n delay,\n immediate,\n );\n\n const filteredAccountCommentsWithStates = useMemo(() => {\n const states = getAccountCommentsStates(filteredAccountComments);\n return filteredAccountComments.map((comment, i) => ({\n ...getAccountCommentWithAccountAuthor(comment, account, accountId || undefined),\n state: states[i],\n }));\n }, [filteredAccountComments, accountCommentStates, account, accountId]);\n\n if (options) {\n log(\"useAccountComments\", {\n accountId,\n filteredAccountCommentsWithStates,\n accountComments,\n commentCid,\n commentIndices,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n parentCid,\n });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountComments: filteredAccountCommentsWithStates,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountCommentsWithStates, state],\n );\n}\n\n/**\n * Returns an account's single comment, e.g. a pending comment they published.\n */\nexport function useAccountComment(options?: UseAccountCommentOptions): UseAccountCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentIndex, commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const normalizedCommentIndex = commentIndex === undefined ? undefined : Number(commentIndex);\n const resolvedCommentIndex =\n typeof normalizedCommentIndex === \"number\" &&\n Number.isInteger(normalizedCommentIndex) &&\n normalizedCommentIndex >= 0\n ? normalizedCommentIndex\n : commentCidToAccountComment && commentCidToAccountComment.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n const storedAccountComment = useMemo(() => {\n if (typeof resolvedCommentIndex !== \"number\") {\n return undefined;\n }\n return accountComments?.[resolvedCommentIndex];\n }, [accountComments, resolvedCommentIndex]);\n const state = storedAccountComment\n ? getAccountCommentsStates([storedAccountComment])[0]\n : \"initializing\";\n\n return useMemo(() => {\n const accountComment = (\n storedAccountComment\n ? getAccountCommentWithAccountAuthor(storedAccountComment, account, accountId || undefined)\n : {}\n ) as Partial<AccountComment> & {\n error?: Error;\n errors?: Error[];\n };\n return {\n ...accountComment,\n state,\n error: accountComment.error,\n errors: accountComment.errors || [],\n } as UseAccountCommentResult;\n }, [storedAccountComment, account, accountId, state]);\n}\n\n/**\n * Returns the own user's votes stored locally, even those not yet published by the community owner.\n * Check UseAccountCommentsOptions type in types.tsx to filter them, e.g. filter = {communityAddresses: ['memes.eth']}.\n */\nexport function useAccountVotes(options?: UseAccountVotesOptions): UseAccountVotesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVotes options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const {\n accountName,\n filter,\n vote,\n commentCid,\n communityAddress,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountVotes options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountId || \"\"]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountVotesArray = useMemo(() => {\n let accountVotesArray: AccountVote[] = [];\n if (!accountVotes) {\n return accountVotesArray;\n }\n for (const i in accountVotes) {\n accountVotesArray.push(accountVotes[i]);\n }\n if (typeof vote === \"number\") {\n accountVotesArray = accountVotesArray.filter((accountVote) => accountVote.vote === vote);\n }\n if (commentCid) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.commentCid === commentCid,\n );\n }\n if (communityAddress) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.communityAddress === communityAddress,\n );\n }\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n accountVotesArray = accountVotesArray.filter(filter);\n }\n accountVotesArray = [...accountVotesArray].sort(\n (firstVote, secondVote) => (firstVote.timestamp || 0) - (secondVote.timestamp || 0),\n );\n if (accountHistorySortType === \"new\") {\n accountVotesArray = [...accountVotesArray].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n accountVotesArray = accountVotesArray.slice(startIndex, startIndex + pageSize);\n }\n return accountVotesArray;\n }, [\n accountVotes,\n accountHistorySortType,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n page,\n pageSize,\n vote,\n ]);\n\n if (accountVotes && options) {\n log(\"useAccountVotes\", {\n accountId,\n filteredAccountVotesArray,\n accountVotes,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n vote,\n });\n }\n\n // TODO: add failed / pending states\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountVotes: filteredAccountVotesArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountVotesArray, state],\n );\n}\n\n/**\n * Returns an account's single vote on a comment, e.g. to know if you already voted on a comment.\n */\nexport function useAccountVote(options?: UseAccountVoteOptions): UseAccountVoteResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVote options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = commentCid || \"\";\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountIdKey]);\n const accountVote: any = accountVotes?.[commentCidKey];\n const state = accountId && commentCid ? \"succeeded\" : \"initializing\";\n\n // TODO: add failed / pending state\n\n return useMemo(\n () => ({\n ...accountVote,\n state,\n error: undefined,\n errors: [],\n }),\n [accountVote, state],\n );\n}\n\n/**\n * Returns all the comment and community edits published by an account.\n */\nexport function useAccountEdits(options?: UseAccountEditsOptions): UseAccountEditsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountEdits options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { filter, accountName } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountEdits options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const ensureAccountEditsLoaded = useAccountsStore(\n (state) => state.accountsActionsInternal.ensureAccountEditsLoaded,\n );\n const accountEdits = useAccountsStore((state) => state.accountsEdits[accountId || \"\"]);\n const accountEditsLoaded = useAccountsStore(\n (state) => state.accountsEditsLoaded[accountId || \"\"],\n );\n\n useEffect(() => {\n if (!accountId || accountEditsLoaded) {\n return;\n }\n ensureAccountEditsLoaded(accountId).catch((error: unknown) =>\n log.error(\"useAccountEdits ensureAccountEditsLoaded error\", { accountId, error }),\n );\n }, [accountEditsLoaded, accountId, ensureAccountEditsLoaded]);\n\n const accountEditsArray = useMemo(() => {\n const accountEditsArray = [];\n for (const i in accountEdits || {}) {\n accountEditsArray.push(...accountEdits[i]);\n }\n // sort by oldest first\n return accountEditsArray.sort((a, b) => a.timestamp - b.timestamp);\n }, [accountEdits]);\n\n const filteredAccountEditsArray = useMemo(() => {\n if (!filter) {\n return accountEditsArray;\n }\n return accountEditsArray.filter(filter);\n }, [accountEditsArray, filter]);\n\n // TODO: add failed / pending states\n\n const state = accountId ? (accountEditsLoaded ? \"succeeded\" : \"initializing\") : \"initializing\";\n\n return useMemo(\n () => ({\n accountEdits: filteredAccountEditsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountEditsArray, state],\n );\n}\n\n/**\n * Returns the comment edited (if has any edits), as well as the pending, succeeded or failed state of the edit.\n */\nexport function useEditedComment(options?: UseEditedCommentOptions): UseEditedCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useEditedComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { comment, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = (comment && comment.cid) || \"\";\n const commentEdits = useAccountsStore(\n (state) => state.accountsEdits[accountIdKey]?.[commentCidKey],\n );\n const commentEditSummary = useAccountsStore(\n (state) => state.accountsEditsSummaries[accountIdKey]?.[commentCidKey],\n );\n\n let initialState = \"initializing\";\n if (accountId && comment && comment.cid) {\n initialState = \"unedited\";\n }\n\n const editedResult = useMemo(() => {\n const editedResult: any = {\n editedComment: undefined,\n succeededEdits: {},\n pendingEdits: {},\n failedEdits: {},\n state: undefined,\n };\n\n // there are no edits\n const propertyNameEdits: any =\n commentEdits?.length > 0 ? getAccountEditPropertySummary(commentEdits) : commentEditSummary;\n\n if (!propertyNameEdits || Object.keys(propertyNameEdits).length === 0) {\n return editedResult;\n }\n\n const now = Math.round(Date.now() / 1000);\n // no longer consider an edit pending ater an expiry time of 20 minutes\n const expiryTime = 60 * 20;\n\n // iterate over propertyNameEdits and find if succeeded, pending or failed\n for (const propertyName in propertyNameEdits) {\n const propertyNameEdit = propertyNameEdits[propertyName];\n\n const setPropertyNameEditState = (state: \"succeeded\" | \"pending\" | \"failed\") => {\n // set propertyNameEdit e.g. editedResult.succeededEdits.removed = true\n editedResult[`${state}Edits`][propertyName] = propertyNameEdit.value;\n\n // if any propertyNameEdit failed, consider the commentEdit failed\n if (state === \"failed\") {\n editedResult.state = \"failed\";\n }\n // if all propertyNameEdit succeeded, consider the commentEdit succeeded\n if (state === \"succeeded\" && !editedResult.state) {\n editedResult.state = \"succeeded\";\n }\n // if any propertyNameEdit are pending, and none have failed, consider the commentEdit pending\n if (state === \"pending\" && editedResult.state !== \"failed\") {\n editedResult.state = \"pending\";\n }\n };\n\n // Without a newer update we can only treat recent edits as pending. Older edits that never\n // produced any update are effectively stale and should stop shadowing the live comment.\n if (!comment?.updatedAt) {\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n } else if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n } else {\n setPropertyNameEditState(\"failed\");\n }\n continue;\n }\n\n // comment.updatedAt is older than propertyNameEdit, propertyNameEdit is pending\n // because we haven't received the update yet and can't evaluate\n if (comment.updatedAt < propertyNameEdit.timestamp) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment.updatedAt is newer than propertyNameEdit, a comment update\n // has been received after the edit was published so we can evaluate\n else {\n // comment has propertyNameEdit, propertyNameEdit succeeded\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n continue;\n }\n\n // comment does not have propertyNameEdit\n else {\n // propertyNameEdit is newer than 20min, it is too recent to evaluate\n // so we should assume pending\n if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // propertyNameEdit is older than 20min, we can evaluate it\n else {\n // comment update was received too shortly after propertyNameEdit was\n // published, assume pending until a more recent comment update is received\n const timeSinceUpdate = comment.updatedAt - propertyNameEdit.timestamp;\n if (timeSinceUpdate < expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment update time is sufficiently distanced from propertyNameEdit\n // and comment doesn't have propertyNameEdit, assume failed\n else {\n setPropertyNameEditState(\"failed\");\n continue;\n }\n }\n }\n }\n }\n\n // define editedComment\n editedResult.editedComment = { ...comment };\n // add pending and succeeded props so the editor can see his changes right away\n // don't add failed edits to reflect the current state of the edited comment\n for (const propertyName in editedResult.pendingEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.pendingEdits[propertyName],\n );\n }\n for (const propertyName in editedResult.succeededEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.succeededEdits[propertyName],\n );\n }\n editedResult.editedComment = addCommentModeration(editedResult.editedComment);\n\n return editedResult;\n }, [comment, commentEditSummary, commentEdits]);\n\n return useMemo(\n () => ({\n ...editedResult,\n state: editedResult.state || initialState,\n error: undefined,\n errors: [],\n }),\n [editedResult, initialState],\n );\n}\n\n/**\n * This hook should be added to pages where the user is likely to publish something, i,e. the\n * submit page and the /c/<commentCid> page, it improves the speed of publishing to the pubsub\n * by subscribing to the pubsub right away.\n *\n * @param accountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'.\n * @param communityAddress - The community address to subscribe to, e.g. 'news.eth'.\n */\nexport function usePubsubSubscribe(options?: UsePubsubSubscribeOptions): UsePubsubSubscribeResult {\n assert(\n !options || typeof options === \"object\",\n `usePubsubSubscribe options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, communityAddress } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const account = useAccountsStore((state) => state.accounts[accountIdKey]);\n const [state, setState] = useState(\"initializing\");\n const [errors, setErrors] = useState<Error[]>([]);\n\n useEffect(() => {\n if (!account?.pkc || !communityAddress) {\n return;\n }\n setState(\"subscribing\");\n account.pkc\n .pubsubSubscribe(communityAddress)\n .then(() => setState(\"succeeded\"))\n .catch((error: any) => {\n setErrors([...errors, error]);\n setState(\"failed\");\n log.error(\"usePubsubSubscribe pkc.pubsubSubscribe error\", { communityAddress, error });\n });\n\n // unsub on component unmount\n return function () {\n account.pkc.pubsubUnsubscribe(communityAddress).catch((error: any) => {\n setErrors([...errors, error]);\n log.error(\"usePubsubSubscribe pkc.pubsubUnsubscribe error\", {\n communityAddress,\n error,\n });\n });\n };\n }, [account?.pkc, communityAddress]);\n\n return useMemo(\n () => ({\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [state, errors],\n );\n}\n"]}
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/hooks/accounts/accounts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,m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BAC1D,gBAAgB;oBAChB,KAAK;iBACN,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAErC,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,KAAK;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM;KACP,CAAC,EACF,CAAC,KAAK,EAAE,MAAM,CAAC,CAChB,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo, useState, useEffect } from \"react\";\nimport isEqual from \"lodash.isequal\";\nimport useAccountsStore from \"../../stores/accounts\";\nimport useCommunitiesStore from \"../../stores/communities\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:hooks\");\nimport assert from \"assert\";\nimport { useListCommunities, useCommunities } from \"../communities\";\nimport type {\n AccountComment,\n AccountComments,\n Account,\n Accounts,\n AccountVote,\n AccountsComments,\n AccountsCommentsReplies,\n UseAccountCommunitiesOptions,\n UseAccountCommunitiesResult,\n UseAccountVoteOptions,\n UseAccountVoteResult,\n UseAccountVotesOptions,\n UseAccountVotesResult,\n UseAccountCommentsOptions,\n UseAccountCommentsResult,\n UseAccountCommentOptions,\n UseAccountCommentResult,\n UseNotificationsOptions,\n UseNotificationsResult,\n UseAccountEditsOptions,\n UseAccountEditsResult,\n UseEditedCommentOptions,\n UseEditedCommentResult,\n UseAccountOptions,\n UseAccountResult,\n UsePubsubSubscribeOptions,\n UsePubsubSubscribeResult,\n} from \"../../types\";\nimport {\n useAccountsWithCalculatedProperties,\n useAccountWithCalculatedProperties,\n useCalculatedNotifications,\n} from \"./utils\";\nimport {\n COMMENT_MODERATION_AUTHOR_SUMMARY_KEY,\n getAccountEditPropertySummary,\n} from \"../../stores/accounts/utils\";\nimport {\n getCanonicalCommunityAddress,\n getEquivalentCommunityAddressGroupKey,\n pickPreferredEquivalentCommunityAddress,\n} from \"../../lib/community-address\";\nimport { addCommentModeration } from \"../../lib/utils/comment-moderation\";\nimport useInterval from \"../utils/use-interval\";\nimport PkcJs from \"../../lib/pkc-js\";\n\nconst getCommentEditPropertyValue = (comment: any, propertyName: string) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n return comment?.[propertyName];\n }\n\n const commentModeration = comment?.commentModeration;\n if (\n commentModeration &&\n typeof commentModeration === \"object\" &&\n Object.prototype.hasOwnProperty.call(commentModeration, \"author\")\n ) {\n return commentModeration.author;\n }\n\n return comment?.author?.community?.banExpiresAt !== undefined\n ? { banExpiresAt: comment.author.community.banExpiresAt }\n : undefined;\n};\n\nconst applyEditedCommentProperty = (comment: any, propertyName: string, value: any) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n comment[propertyName] = value;\n return;\n }\n\n comment.commentModeration = comment.commentModeration ? { ...comment.commentModeration } : {};\n if (value === undefined) {\n delete comment.commentModeration.author;\n } else {\n comment.commentModeration.author = value;\n }\n\n comment.author = comment.author ? { ...comment.author } : {};\n comment.author.community = comment.author.community ? { ...comment.author.community } : {};\n if (value?.banExpiresAt === undefined) {\n delete comment.author.community.banExpiresAt;\n } else {\n comment.author.community.banExpiresAt = value.banExpiresAt;\n }\n};\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, return\n * the active account id.\n */\nexport function useAccountId(accountName?: string) {\n const accountId = useAccountsStore((state) => state.accountNamesToAccountIds[accountName || \"\"]);\n // don't consider active account if account name is defined\n const activeAccountId = useAccountsStore((state) => !accountName && state.activeAccountId);\n const accountIdToUse = accountName ? accountId : activeAccountId;\n return accountIdToUse;\n}\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, return\n * the active account.\n */\nexport function useAccount(options?: UseAccountOptions): UseAccountResult {\n assert(\n !options || typeof options === \"object\",\n `useAccount options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const accountStore = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const account = useAccountWithCalculatedProperties(\n accountStore,\n accountComments,\n accountCommentsReplies,\n );\n log(\"useAccount\", { accountId, account, accountName });\n return account;\n}\n\n/**\n * Return all accounts in the order of `accountsStore.accountIds`. To reorder, use `accountsActions.setAccountsOrder(accountNames)`.\n */\nexport function useAccounts() {\n const accountIds = useAccountsStore((state) => state.accountIds);\n const accountsStore = useAccountsStore((state) => state.accounts);\n const accountsComments = useAccountsStore((state) => state.accountsComments);\n const accountsCommentsReplies = useAccountsStore((state) => state.accountsCommentsReplies);\n const accounts = useAccountsWithCalculatedProperties(\n accountsStore,\n accountsComments,\n accountsCommentsReplies,\n );\n const accountsArray: Account[] = useMemo(() => {\n const accountsArray = [];\n if (accountIds?.length && accounts) {\n for (const accountId of accountIds) {\n accountsArray.push(accounts[accountId]);\n }\n }\n return accountsArray;\n }, [accounts, accountIds]);\n\n log(\"useAccounts\", { accounts, accountIds });\n\n const state = accountsArray?.length ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accounts: accountsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [accountsArray, state],\n );\n}\n\n/**\n * Returns all communities where the account is a creator or moderator\n */\nexport function useAccountCommunities(\n options?: UseAccountCommunitiesOptions,\n): UseAccountCommunitiesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountCommunities options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, onlyIfCached } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const accountsStoreAccountCommunities = useAccountsStore(\n (state) => state.accounts[accountIdKey]?.communities,\n );\n\n // get all unique account community addresses\n const ownerCommunityAddresses = useListCommunities(accountName);\n const groupedCommunityAddresses = useMemo(() => {\n const accountCommunityAddresses = [];\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n accountCommunityAddresses.push(communityAddress);\n }\n }\n const allCommunityAddresses = [\n ...new Set([...ownerCommunityAddresses, ...accountCommunityAddresses]),\n ].sort();\n const groupedAddresses = new Map<string, string[]>();\n for (const communityAddress of allCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const addresses = groupedAddresses.get(groupKey);\n if (addresses) {\n addresses.push(communityAddress);\n } else {\n groupedAddresses.set(groupKey, [communityAddress]);\n }\n }\n return [...groupedAddresses.entries()].map(([groupKey, addresses]) => ({\n groupKey,\n addresses,\n preferredAddress: pickPreferredEquivalentCommunityAddress(addresses),\n }));\n }, [accountsStoreAccountCommunities, ownerCommunityAddresses]);\n const uniqueCommunityAddresses = useMemo(\n () => groupedCommunityAddresses.map(({ preferredAddress }) => preferredAddress),\n [groupedCommunityAddresses],\n );\n\n // fetch all community data\n const {\n communities: communitiesArray,\n state: communitiesState,\n error: communitiesError,\n errors: communitiesErrors,\n } = useCommunities({\n communities: uniqueCommunityAddresses.map((communityAddress) => ({ name: communityAddress })),\n accountName,\n onlyIfCached,\n });\n const communityFetchErrors = useCommunitiesStore((state: any) =>\n uniqueCommunityAddresses.flatMap((communityAddress) => state.errors[communityAddress] || []),\n );\n const canonicalAddressByGroupKey = useMemo(() => {\n const canonicalAddresses: { [groupKey: string]: string } = {};\n for (const [i, { groupKey, preferredAddress }] of groupedCommunityAddresses.entries()) {\n const fetchedAddress = communitiesArray[i]?.address;\n canonicalAddresses[groupKey] = getCanonicalCommunityAddress(\n fetchedAddress || preferredAddress,\n );\n }\n return canonicalAddresses;\n }, [groupedCommunityAddresses, communitiesArray]);\n const communities: any = useMemo(() => {\n const communities: any = {};\n for (const [i, community] of communitiesArray.entries()) {\n const { groupKey, preferredAddress } = groupedCommunityAddresses[i];\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n communities[canonicalAddress] = {\n ...communities[canonicalAddress],\n ...community,\n // make sure the canonical address is defined even if the community hasn't fetched yet\n address: canonicalAddress,\n };\n }\n return communities;\n }, [communitiesArray, groupedCommunityAddresses, canonicalAddressByGroupKey]);\n\n // merged community data with account.communities data\n const accountCommunities: any = useMemo(() => {\n const accountCommunities: any = { ...communities };\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n ...accountsStoreAccountCommunities[communityAddress],\n address: canonicalAddress,\n };\n }\n }\n // add pkc.communities data\n for (const communityAddress of ownerCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n address: canonicalAddress,\n role: { role: \"owner\" },\n };\n }\n return accountCommunities;\n }, [\n accountsStoreAccountCommunities,\n ownerCommunityAddresses,\n communities,\n canonicalAddressByGroupKey,\n ]);\n\n if (accountId) {\n log(\"useAccountCommunities\", { accountCommunities });\n }\n\n const pendingAccountCommunities = Object.values(accountCommunities).some(\n (community: any) => community?.address && !community?.updatedAt,\n );\n const errors = communityFetchErrors.length ? communityFetchErrors : communitiesErrors;\n const error = communitiesError || errors[errors.length - 1];\n const state = !accountId\n ? \"initializing\"\n : error\n ? \"failed\"\n : pendingAccountCommunities\n ? \"fetching-ipns\"\n : communitiesState;\n\n return useMemo(\n () => ({\n accountCommunities,\n state,\n error,\n errors,\n }),\n [accountCommunities, state, error, errors],\n );\n}\n\n/**\n * Returns an account's notifications in an array. Unread notifications have a field markedAsRead: false.\n *\n * @param accountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, return\n * the active account's notifications.\n */\nexport function useNotifications(options?: UseNotificationsOptions): UseNotificationsResult {\n assert(\n !options || typeof options === \"object\",\n `useNotifications options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const accountsActionsInternal = useAccountsStore((state) => state.accountsActionsInternal);\n const notifications = useCalculatedNotifications(account, accountCommentsReplies);\n const [errors, setErrors] = useState<Error[]>([]);\n\n const markAsRead = async () => {\n try {\n if (!account) {\n throw Error(\"useNotifications cannot mark as read accounts not initalized yet\");\n }\n accountsActionsInternal.markNotificationsAsRead(account);\n } catch (e: any) {\n setErrors([...errors, e]);\n }\n };\n\n if (account) {\n log(\"useNotifications\", { notifications });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n notifications,\n markAsRead,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [notifications, errors],\n );\n}\n\nconst getAccountCommentsStates = (accountComments: AccountComment[]) => {\n // Without a cid, the account comment is still a local pending publish. pkc-js marks\n // terminal publish failures when `publishingState === \"failed\"` and publication `state`\n // is `\"stopped\"`, so we derive failed from that terminal pair or recorded publish errors.\n const now = Math.round(Date.now() / 1000);\n const expiryTime = now - 60 * 20;\n\n const states: string[] = [];\n for (const accountComment of accountComments) {\n let state = \"succeeded\";\n if (!accountComment.cid) {\n const ac = accountComment as AccountComment & {\n error?: Error;\n errors?: Error[];\n publishingState?: string;\n state?: string;\n };\n const resolvedPublishFailed =\n (ac.publishingState === \"failed\" && ac.state === \"stopped\") ||\n ac.error != null ||\n (Array.isArray(ac.errors) && ac.errors.length > 0);\n\n if (resolvedPublishFailed) {\n state = \"failed\";\n } else if (accountComment.timestamp > expiryTime) {\n state = \"pending\";\n } else {\n state = \"failed\";\n }\n }\n states.push(state);\n }\n\n return states;\n};\n\nexport const haveAccountCommentStatesChanged = (nextStates: string[], previousStates: string[]) =>\n nextStates.toString() !== previousStates.toString();\n\nconst getAccountHistorySortType = (\n sortType?: \"new\" | \"old\",\n order?: \"asc\" | \"desc\",\n): \"new\" | \"old\" => {\n if (sortType === \"new\" || sortType === \"old\") {\n return sortType;\n }\n return order === \"desc\" ? \"new\" : \"old\";\n};\n\nconst getAccountCommentWithAccountAuthor = (\n accountComment: AccountComment,\n account?: Account,\n accountId?: string,\n): AccountComment => {\n const accountAuthor = account?.author;\n if (\n !accountId ||\n accountComment.accountId !== accountId ||\n !accountAuthor?.address ||\n accountComment.author?.address ||\n // a pseudonymous community published the comment under an alias, never the account identity\n accountComment.pseudonymityMode\n ) {\n return accountComment;\n }\n\n const accountShortAddress =\n accountAuthor.shortAddress || PkcJs.PKC.getShortAddress({ address: accountAuthor.address });\n\n return {\n ...accountComment,\n author: {\n ...accountAuthor,\n ...accountComment.author,\n address: accountAuthor.address,\n ...(accountShortAddress ? { shortAddress: accountShortAddress } : {}),\n },\n };\n};\n\nexport function useAccountComments(options?: UseAccountCommentsOptions): UseAccountCommentsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComments options argument '${options}' not an object`,\n );\n const {\n accountName,\n filter,\n commentCid,\n commentIndices,\n communityAddress,\n parentCid,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = options || {};\n assert(\n !filter || typeof filter === \"function\",\n `useAccountComments options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountCommentsIndexes = useAccountsStore(\n (state) => state.accountsCommentsIndexes[accountId || \"\"],\n );\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const [accountCommentStates, setAccountCommentStates] = useState<string[]>([]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountComments = useMemo(() => {\n if (!accountComments) {\n return [];\n }\n\n let scopedAccountComments = accountComments;\n if (Array.isArray(commentIndices) && commentIndices.length > 0) {\n const normalizedCommentIndices = commentIndices\n .map((commentIndex) => Number(commentIndex))\n .filter((commentIndex) => Number.isInteger(commentIndex) && commentIndex >= 0);\n scopedAccountComments = normalizedCommentIndices\n .map((commentIndex) => accountComments[commentIndex])\n .filter(Boolean);\n } else if (commentCid) {\n const mappedIndex =\n commentCidToAccountComment?.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n scopedAccountComments =\n typeof mappedIndex === \"number\" ? [accountComments[mappedIndex]].filter(Boolean) : [];\n } else if (parentCid) {\n const parentIndexes = accountCommentsIndexes?.byParentCid?.[parentCid];\n scopedAccountComments = parentIndexes?.length\n ? parentIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter((accountComment) => accountComment.parentCid === parentCid);\n } else if (communityAddress) {\n const communityIndexes = accountCommentsIndexes?.byCommunityAddress?.[communityAddress];\n scopedAccountComments = communityIndexes?.length\n ? communityIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter(\n (accountComment) => accountComment.communityAddress === communityAddress,\n );\n }\n\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n scopedAccountComments = scopedAccountComments.filter(\n (accountComment) => accountComment.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n scopedAccountComments = scopedAccountComments.filter(filter);\n }\n if (accountHistorySortType === \"new\") {\n scopedAccountComments = [...scopedAccountComments].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n return scopedAccountComments.slice(startIndex, startIndex + pageSize);\n }\n return scopedAccountComments;\n }, [\n accountComments,\n accountCommentsIndexes,\n accountId,\n commentCid,\n commentIndices,\n commentCidToAccountComment,\n communityAddress,\n filter,\n newerThan,\n accountHistorySortType,\n page,\n pageSize,\n parentCid,\n ]);\n\n // Recheck periodically so the 20-minute “stale pending → failed” transition updates without other store events\n const delay = 60_000;\n const immediate = false;\n useInterval(\n () => {\n const states = getAccountCommentsStates(filteredAccountComments);\n if (haveAccountCommentStatesChanged(states, accountCommentStates)) {\n setAccountCommentStates(states);\n }\n },\n delay,\n immediate,\n );\n\n const filteredAccountCommentsWithStates = useMemo(() => {\n const states = getAccountCommentsStates(filteredAccountComments);\n return filteredAccountComments.map((comment, i) => ({\n ...getAccountCommentWithAccountAuthor(comment, account, accountId || undefined),\n state: states[i],\n }));\n }, [filteredAccountComments, accountCommentStates, account, accountId]);\n\n if (options) {\n log(\"useAccountComments\", {\n accountId,\n filteredAccountCommentsWithStates,\n accountComments,\n commentCid,\n commentIndices,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n parentCid,\n });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountComments: filteredAccountCommentsWithStates,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountCommentsWithStates, state],\n );\n}\n\n/**\n * Returns an account's single comment, e.g. a pending comment they published.\n */\nexport function useAccountComment(options?: UseAccountCommentOptions): UseAccountCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentIndex, commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const normalizedCommentIndex = commentIndex === undefined ? undefined : Number(commentIndex);\n const resolvedCommentIndex =\n typeof normalizedCommentIndex === \"number\" &&\n Number.isInteger(normalizedCommentIndex) &&\n normalizedCommentIndex >= 0\n ? normalizedCommentIndex\n : commentCidToAccountComment && commentCidToAccountComment.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n const storedAccountComment = useMemo(() => {\n if (typeof resolvedCommentIndex !== \"number\") {\n return undefined;\n }\n return accountComments?.[resolvedCommentIndex];\n }, [accountComments, resolvedCommentIndex]);\n const state = storedAccountComment\n ? getAccountCommentsStates([storedAccountComment])[0]\n : \"initializing\";\n\n return useMemo(() => {\n const accountComment = (\n storedAccountComment\n ? getAccountCommentWithAccountAuthor(storedAccountComment, account, accountId || undefined)\n : {}\n ) as Partial<AccountComment> & {\n error?: Error;\n errors?: Error[];\n };\n return {\n ...accountComment,\n state,\n error: accountComment.error,\n errors: accountComment.errors || [],\n } as UseAccountCommentResult;\n }, [storedAccountComment, account, accountId, state]);\n}\n\n/**\n * Returns the own user's votes stored locally, even those not yet published by the community owner.\n * Check UseAccountCommentsOptions type in types.tsx to filter them, e.g. filter = {communityAddresses: ['memes.eth']}.\n */\nexport function useAccountVotes(options?: UseAccountVotesOptions): UseAccountVotesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVotes options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const {\n accountName,\n filter,\n vote,\n commentCid,\n communityAddress,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountVotes options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountId || \"\"]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountVotesArray = useMemo(() => {\n let accountVotesArray: AccountVote[] = [];\n if (!accountVotes) {\n return accountVotesArray;\n }\n for (const i in accountVotes) {\n accountVotesArray.push(accountVotes[i]);\n }\n if (typeof vote === \"number\") {\n accountVotesArray = accountVotesArray.filter((accountVote) => accountVote.vote === vote);\n }\n if (commentCid) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.commentCid === commentCid,\n );\n }\n if (communityAddress) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.communityAddress === communityAddress,\n );\n }\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n accountVotesArray = accountVotesArray.filter(filter);\n }\n accountVotesArray = [...accountVotesArray].sort(\n (firstVote, secondVote) => (firstVote.timestamp || 0) - (secondVote.timestamp || 0),\n );\n if (accountHistorySortType === \"new\") {\n accountVotesArray = [...accountVotesArray].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n accountVotesArray = accountVotesArray.slice(startIndex, startIndex + pageSize);\n }\n return accountVotesArray;\n }, [\n accountVotes,\n accountHistorySortType,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n page,\n pageSize,\n vote,\n ]);\n\n if (accountVotes && options) {\n log(\"useAccountVotes\", {\n accountId,\n filteredAccountVotesArray,\n accountVotes,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n vote,\n });\n }\n\n // TODO: add failed / pending states\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountVotes: filteredAccountVotesArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountVotesArray, state],\n );\n}\n\n/**\n * Returns an account's single vote on a comment, e.g. to know if you already voted on a comment.\n */\nexport function useAccountVote(options?: UseAccountVoteOptions): UseAccountVoteResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVote options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = commentCid || \"\";\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountIdKey]);\n const accountVote: any = accountVotes?.[commentCidKey];\n const state = accountId && commentCid ? \"succeeded\" : \"initializing\";\n\n // TODO: add failed / pending state\n\n return useMemo(\n () => ({\n ...accountVote,\n state,\n error: undefined,\n errors: [],\n }),\n [accountVote, state],\n );\n}\n\n/**\n * Returns all the comment and community edits published by an account.\n */\nexport function useAccountEdits(options?: UseAccountEditsOptions): UseAccountEditsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountEdits options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { filter, accountName } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountEdits options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const ensureAccountEditsLoaded = useAccountsStore(\n (state) => state.accountsActionsInternal.ensureAccountEditsLoaded,\n );\n const accountEdits = useAccountsStore((state) => state.accountsEdits[accountId || \"\"]);\n const accountEditsLoaded = useAccountsStore(\n (state) => state.accountsEditsLoaded[accountId || \"\"],\n );\n\n useEffect(() => {\n if (!accountId || accountEditsLoaded) {\n return;\n }\n ensureAccountEditsLoaded(accountId).catch((error: unknown) =>\n log.error(\"useAccountEdits ensureAccountEditsLoaded error\", { accountId, error }),\n );\n }, [accountEditsLoaded, accountId, ensureAccountEditsLoaded]);\n\n const accountEditsArray = useMemo(() => {\n const accountEditsArray = [];\n for (const i in accountEdits || {}) {\n accountEditsArray.push(...accountEdits[i]);\n }\n // sort by oldest first\n return accountEditsArray.sort((a, b) => a.timestamp - b.timestamp);\n }, [accountEdits]);\n\n const filteredAccountEditsArray = useMemo(() => {\n if (!filter) {\n return accountEditsArray;\n }\n return accountEditsArray.filter(filter);\n }, [accountEditsArray, filter]);\n\n // TODO: add failed / pending states\n\n const state = accountId ? (accountEditsLoaded ? \"succeeded\" : \"initializing\") : \"initializing\";\n\n return useMemo(\n () => ({\n accountEdits: filteredAccountEditsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountEditsArray, state],\n );\n}\n\n/**\n * Returns the comment edited (if has any edits), as well as the pending, succeeded or failed state of the edit.\n */\nexport function useEditedComment(options?: UseEditedCommentOptions): UseEditedCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useEditedComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { comment, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = (comment && comment.cid) || \"\";\n const commentEdits = useAccountsStore(\n (state) => state.accountsEdits[accountIdKey]?.[commentCidKey],\n );\n const commentEditSummary = useAccountsStore(\n (state) => state.accountsEditsSummaries[accountIdKey]?.[commentCidKey],\n );\n\n let initialState = \"initializing\";\n if (accountId && comment && comment.cid) {\n initialState = \"unedited\";\n }\n\n const editedResult = useMemo(() => {\n const editedResult: any = {\n editedComment: undefined,\n succeededEdits: {},\n pendingEdits: {},\n failedEdits: {},\n state: undefined,\n };\n\n // there are no edits\n const propertyNameEdits: any =\n commentEdits?.length > 0 ? getAccountEditPropertySummary(commentEdits) : commentEditSummary;\n\n if (!propertyNameEdits || Object.keys(propertyNameEdits).length === 0) {\n return editedResult;\n }\n\n const now = Math.round(Date.now() / 1000);\n // no longer consider an edit pending ater an expiry time of 20 minutes\n const expiryTime = 60 * 20;\n\n // iterate over propertyNameEdits and find if succeeded, pending or failed\n for (const propertyName in propertyNameEdits) {\n const propertyNameEdit = propertyNameEdits[propertyName];\n\n const setPropertyNameEditState = (state: \"succeeded\" | \"pending\" | \"failed\") => {\n // set propertyNameEdit e.g. editedResult.succeededEdits.removed = true\n editedResult[`${state}Edits`][propertyName] = propertyNameEdit.value;\n\n // if any propertyNameEdit failed, consider the commentEdit failed\n if (state === \"failed\") {\n editedResult.state = \"failed\";\n }\n // if all propertyNameEdit succeeded, consider the commentEdit succeeded\n if (state === \"succeeded\" && !editedResult.state) {\n editedResult.state = \"succeeded\";\n }\n // if any propertyNameEdit are pending, and none have failed, consider the commentEdit pending\n if (state === \"pending\" && editedResult.state !== \"failed\") {\n editedResult.state = \"pending\";\n }\n };\n\n // Without a newer update we can only treat recent edits as pending. Older edits that never\n // produced any update are effectively stale and should stop shadowing the live comment.\n if (!comment?.updatedAt) {\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n } else if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n } else {\n setPropertyNameEditState(\"failed\");\n }\n continue;\n }\n\n // comment.updatedAt is older than propertyNameEdit, propertyNameEdit is pending\n // because we haven't received the update yet and can't evaluate\n if (comment.updatedAt < propertyNameEdit.timestamp) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment.updatedAt is newer than propertyNameEdit, a comment update\n // has been received after the edit was published so we can evaluate\n else {\n // comment has propertyNameEdit, propertyNameEdit succeeded\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n continue;\n }\n\n // comment does not have propertyNameEdit\n else {\n // propertyNameEdit is newer than 20min, it is too recent to evaluate\n // so we should assume pending\n if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // propertyNameEdit is older than 20min, we can evaluate it\n else {\n // comment update was received too shortly after propertyNameEdit was\n // published, assume pending until a more recent comment update is received\n const timeSinceUpdate = comment.updatedAt - propertyNameEdit.timestamp;\n if (timeSinceUpdate < expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment update time is sufficiently distanced from propertyNameEdit\n // and comment doesn't have propertyNameEdit, assume failed\n else {\n setPropertyNameEditState(\"failed\");\n continue;\n }\n }\n }\n }\n }\n\n // define editedComment\n editedResult.editedComment = { ...comment };\n // add pending and succeeded props so the editor can see his changes right away\n // don't add failed edits to reflect the current state of the edited comment\n for (const propertyName in editedResult.pendingEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.pendingEdits[propertyName],\n );\n }\n for (const propertyName in editedResult.succeededEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.succeededEdits[propertyName],\n );\n }\n editedResult.editedComment = addCommentModeration(editedResult.editedComment);\n\n return editedResult;\n }, [comment, commentEditSummary, commentEdits]);\n\n return useMemo(\n () => ({\n ...editedResult,\n state: editedResult.state || initialState,\n error: undefined,\n errors: [],\n }),\n [editedResult, initialState],\n );\n}\n\n/**\n * This hook should be added to pages where the user is likely to publish something, i,e. the\n * submit page and the /c/<commentCid> page, it improves the speed of publishing to the pubsub\n * by subscribing to the pubsub right away.\n *\n * @param accountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'.\n * @param communityAddress - The community address to subscribe to, e.g. 'news.eth'.\n */\nexport function usePubsubSubscribe(options?: UsePubsubSubscribeOptions): UsePubsubSubscribeResult {\n assert(\n !options || typeof options === \"object\",\n `usePubsubSubscribe options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, communityAddress } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const account = useAccountsStore((state) => state.accounts[accountIdKey]);\n const [state, setState] = useState(\"initializing\");\n const [errors, setErrors] = useState<Error[]>([]);\n\n useEffect(() => {\n if (!account?.pkc || !communityAddress) {\n return;\n }\n setState(\"subscribing\");\n account.pkc\n .pubsubSubscribe(communityAddress)\n .then(() => setState(\"succeeded\"))\n .catch((error: any) => {\n setErrors([...errors, error]);\n setState(\"failed\");\n log.error(\"usePubsubSubscribe pkc.pubsubSubscribe error\", { communityAddress, error });\n });\n\n // unsub on component unmount\n return function () {\n account.pkc.pubsubUnsubscribe(communityAddress).catch((error: any) => {\n setErrors([...errors, error]);\n log.error(\"usePubsubSubscribe pkc.pubsubUnsubscribe error\", {\n communityAddress,\n error,\n });\n });\n };\n }, [account?.pkc, communityAddress]);\n\n return useMemo(\n () => ({\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [state, errors],\n );\n}\n"]}
@@ -7,6 +7,7 @@ export declare const getPreloadedPostSortType: (community?: Community) => string
7
7
  export declare const getPreloadedReplySortType: (comment?: Comment) => string | undefined;
8
8
  export declare const resolvePostSortType: (community: Community | undefined, requestedSortType?: string) => string | undefined;
9
9
  export declare const resolveReplySortType: (comment: Comment | undefined, requestedSortType?: string) => string | undefined;
10
+ export declare const isBuiltInPostSortType: (community: Community | undefined, sortType: string | undefined) => boolean;
10
11
  export declare const getPostPageSortType: (community: Community | undefined, requestedSortType?: string) => string | undefined;
11
12
  export declare const getReplyPageSortType: (comment: Comment | undefined, requestedSortType?: string) => string | undefined;
12
13
  //# sourceMappingURL=page-sorts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-sorts.d.ts","sourceRoot":"","sources":["../../src/lib/page-sorts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AA4C9C,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,KAAG,OAA8C,CAAC;AAElG,eAAO,MAAM,uBAAuB,GAAI,WAAW,MAAM,KAAG,MAAM,GAAG,SAGpE,CAAC;AAyHF,eAAO,MAAM,yBAAyB,GAAI,YAAY,SAAS,KAAG,MAAM,EACM,CAAC;AAE/E,eAAO,MAAM,0BAA0B,GAAI,UAAU,OAAO,KAAG,MAAM,EACkB,CAAC;AAExF,eAAO,MAAM,wBAAwB,GAAI,YAAY,SAAS,KAAG,MAAM,GAAG,SAC9B,CAAC;AAE7C,eAAO,MAAM,yBAAyB,GAAI,UAAU,OAAO,KAAG,MAAM,GAAG,SAC3B,CAAC;AAE7C,eAAO,MAAM,mBAAmB,GAC9B,WAAW,SAAS,GAAG,SAAS,EAChC,oBAAoB,MAAM,KACzB,MAAM,GAAG,SAC+E,CAAC;AAE5F,eAAO,MAAM,oBAAoB,GAC/B,SAAS,OAAO,GAAG,SAAS,EAC5B,oBAAoB,MAAM,KACzB,MAAM,GAAG,SAKT,CAAC;AAIJ,eAAO,MAAM,mBAAmB,GAC9B,WAAW,SAAS,GAAG,SAAS,EAChC,oBAAoB,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MAAM,KACzB,MAAM,GAAG,SAC+E,CAAC"}
@@ -138,6 +138,28 @@ export const getPreloadedPostSortType = (community) => getPreloadedPageSortType(
138
138
  export const getPreloadedReplySortType = (comment) => getPreloadedPageSortType(comment === null || comment === void 0 ? void 0 : comment.replies);
139
139
  export const resolvePostSortType = (community, requestedSortType) => resolvePageSortType(community === null || community === void 0 ? void 0 : community.posts, requestedSortType, CLIENT_SORTABLE_POST_SORT_TYPES);
140
140
  export const resolveReplySortType = (comment, requestedSortType) => resolvePageSortType(comment === null || comment === void 0 ? void 0 : comment.replies, requestedSortType, getClientSortableReplySortTypes(comment));
141
+ // the options pkc-js applies to every sort; any other published option belongs to the sort file itself
142
+ const RESERVED_PAGE_SORT_OPTIONS = new Set([
143
+ "maxAge",
144
+ "pinnedFirst",
145
+ "excludeRemovedComments",
146
+ "excludeDeletedComments",
147
+ "excludeCommentPendingApproval",
148
+ "excludeCommentWithApprovedFalse",
149
+ "excludeCommentsWithDifferentCommunityAddress",
150
+ ]);
151
+ // a community configured with `settings.pages` publishes `community.pageSorts`, naming the file behind
152
+ // each key; a package or path file published under a built-in key (e.g. a keyword no-bump `active`)
153
+ // orders its pages by a score the client sorters do not reproduce. A node may also register such a
154
+ // file under the built-in name itself, which its own options (e.g. `noBumpKeywords`) still reveal.
155
+ // Unconfigured communities publish no `pageSorts`, so their keys are the built-ins.
156
+ export const isBuiltInPostSortType = (community, sortType) => {
157
+ var _a, _b;
158
+ const publishedPageSort = sortType ? (_b = (_a = community === null || community === void 0 ? void 0 : community.pageSorts) === null || _a === void 0 ? void 0 : _a.posts) === null || _b === void 0 ? void 0 : _b[sortType] : undefined;
159
+ return (!publishedPageSort ||
160
+ (publishedPageSort.name === sortType &&
161
+ Object.keys(publishedPageSort.publicOptions || {}).every((option) => RESERVED_PAGE_SORT_OPTIONS.has(option))));
162
+ };
141
163
  // the `community.posts` page sort that serves a request, e.g. the preloaded `hot` page when a
142
164
  // single-page community serves `active` client-side; undefined when the sort cannot be served
143
165
  export const getPostPageSortType = (community, requestedSortType) => getPageSortTypeToRead(community === null || community === void 0 ? void 0 : community.posts, resolvePostSortType(community, requestedSortType));
@@ -1 +1 @@
1
- {"version":3,"file":"page-sorts.js","sourceRoot":"","sources":["../../src/lib/page-sorts.ts"],"names":[],"mappings":"AASA,oGAAoG;AACpG,iGAAiG;AACjG,qGAAqG;AACrG,MAAM,+BAA+B,GAAG;IACtC,KAAK;IACL,KAAK;IACL,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,SAAS;IACT,UAAU;IACV,SAAS;IACT,QAAQ;CACT,CAAC;AACF,MAAM,gCAAgC,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAEtF,kGAAkG;AAClG,yFAAyF;AACzF,MAAM,+BAA+B,GAAG,CAAC,OAAiB,EAAY,EAAE;IACtE,MAAM,MAAM,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,MAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA,CAAC;IACxF,OAAO,MAAM;QACX,CAAC,CAAC,gCAAgC;QAClC,CAAC,CAAC,gCAAgC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvF,CAAC,CAAC;AAEF,6FAA6F;AAC7F,iEAAiE;AACjE,MAAM,uBAAuB,GAA2B;IACtD,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,QAAQ;CACf,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAiB,EAAW,EAAE,CAAC,OAAO,CAAC,QAAQ,aAAR,QAAQ,u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4B,EAC5B,iBAA0B,EACN,EAAE,CACtB,mBAAmB,CACjB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAChB,iBAAiB,EACjB,+BAA+B,CAAC,OAAO,CAAC,CACzC,CAAC;AAEJ,8FAA8F;AAC9F,8FAA8F;AAC9F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,SAAgC,EAChC,iBAA0B,EACN,EAAE,CACtB,qBAAqB,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,EAAE,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAE7F,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,OAA4B,EAC5B,iBAA0B,EACN,EAAE,CACtB,qBAAqB,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC","sourcesContent":["import { Comment, Community } from \"../types\";\n\ntype PagesRecord = {\n pages?: Record<string, unknown>;\n pageCids?: Record<string, unknown>;\n};\n\ntype PreloadedPage = { comments?: unknown; nextCid?: string } | undefined;\n\n// Standard pkc-js sorts (pkc-js src/pages/util.ts) whose scoring the feed sorter reproduces. pkc-js\n// preloads a single sort and only publishes pageCids once that page overflows, so a record whose\n// comments all fit in the preloaded page can serve any of these by re-sorting that page client-side.\nconst CLIENT_SORTABLE_POST_SORT_TYPES = [\n \"hot\",\n \"new\",\n \"active\",\n \"topHour\",\n \"topDay\",\n \"topWeek\",\n \"topMonth\",\n \"topYear\",\n \"topAll\",\n];\nconst CLIENT_SORTABLE_REPLY_SORT_TYPES = [\"best\", \"new\", \"old\", \"newFlat\", \"oldFlat\"];\n\n// pkc-js only publishes flat sorts for a post's replies (REPLY_REPLIES_SORT_TYPES has none), so a\n// nested reply must not advertise them while its replies still fit in the preloaded page\nconst getClientSortableReplySortTypes = (comment?: Comment): string[] => {\n const isPost = comment?.depth !== undefined ? comment.depth === 0 : !comment?.parentCid;\n return isPost\n ? CLIENT_SORTABLE_REPLY_SORT_TYPES\n : CLIENT_SORTABLE_REPLY_SORT_TYPES.filter((sortType) => !isFlatSortType(sortType));\n};\n\n// pkc-js TIMEFRAMES_TO_SECONDS, applied client-side when a timeframe sort is computed from a\n// preloaded page instead of a page the community windowed itself\nconst SORT_TIMEFRAMES_SECONDS: Record<string, number> = {\n Hour: 3600,\n Day: 86400,\n Week: 604800,\n Month: 2629746,\n Year: 31557600,\n};\n\nexport const isFlatSortType = (sortType?: string): boolean => Boolean(sortType?.endsWith(\"Flat\"));\n\nexport const getSortTimeframeSeconds = (sortType?: string): number | undefined => {\n const timeframe = sortType?.match(/^(?:top|controversial)(Hour|Day|Week|Month|Year)$/)?.[1];\n return timeframe ? SORT_TIMEFRAMES_SECONDS[timeframe] : undefined;\n};\n\nconst getPublishedPageSortTypes = (record?: PagesRecord): string[] => {\n const sortTypes = new Set<string>();\n for (const sortType of Object.keys(record?.pages || {})) {\n if (sortType) sortTypes.add(sortType);\n }\n for (const sortType of Object.keys(record?.pageCids || {})) {\n if (sortType) sortTypes.add(sortType);\n }\n return [...sortTypes];\n};\n\n// preloaded pages holding the record's complete comment set: no page continues with a nextCid and\n// no pageCids are published (pkc-js publishes pageCids for every sort once the preloaded page overflows)\nconst getCompletePreloadedPageSortTypes = (record?: PagesRecord): string[] => {\n if (Object.keys(record?.pageCids || {}).length > 0) {\n return [];\n }\n const pages = record?.pages || {};\n const sortTypes = Object.keys(pages).filter((sortType) =>\n Array.isArray((pages[sortType] as PreloadedPage)?.comments),\n );\n if (\n !sortTypes.length ||\n sortTypes.some((sortType) => (pages[sortType] as PreloadedPage)?.nextCid)\n ) {\n return [];\n }\n // a page windowed by a timeframe sort only holds that window, never the complete set\n return sortTypes.filter((sortType) => !getSortTimeframeSeconds(sortType));\n};\n\n// a flat sort flattens the whole reply tree, so every nested reply chain must be complete too\nconst hasCompleteReplyTree = (page: PreloadedPage): boolean =>\n ((page?.comments as Comment[] | undefined) || []).every((comment) => {\n const completeSortTypes = getCompletePreloadedPageSortTypes(comment?.replies);\n if (!completeSortTypes.length) {\n // no preloaded replies is only complete when the comment reports none, and a continued or\n // paged chain is never complete\n return !(comment?.replyCount > 0) && !Object.keys(comment?.replies?.pages || {}).length;\n }\n const hierarchicalSortType = completeSortTypes.find((sortType) => !isFlatSortType(sortType));\n return hierarchicalSortType === undefined\n ? true\n : hasCompleteReplyTree(comment.replies.pages[hierarchicalSortType]);\n });\n\n// a flat page cannot rebuild the reply tree, so it only serves flat sorts; a hierarchical page\n// serves flat sorts only when its nested reply chains are complete\nconst getClientSortableSortTypes = (\n record: PagesRecord | undefined,\n clientSortableSortTypes: string[],\n): string[] => {\n const completeSortTypes = getCompletePreloadedPageSortTypes(record);\n if (!completeSortTypes.length) {\n return [];\n }\n const hierarchicalSortType = completeSortTypes.find((sortType) => !isFlatSortType(sortType));\n if (hierarchicalSortType === undefined) {\n return clientSortableSortTypes.filter(isFlatSortType);\n }\n const canFlatten =\n completeSortTypes.some(isFlatSortType) ||\n hasCompleteReplyTree(record?.pages?.[hierarchicalSortType] as PreloadedPage);\n return canFlatten\n ? clientSortableSortTypes\n : clientSortableSortTypes.filter((sortType) => !isFlatSortType(sortType));\n};\n\nconst getAvailablePageSortTypes = (\n record: PagesRecord | undefined,\n clientSortableSortTypes: string[],\n): string[] => {\n const sortTypes = getPublishedPageSortTypes(record);\n for (const sortType of getClientSortableSortTypes(record, clientSortableSortTypes)) {\n if (!sortTypes.includes(sortType)) sortTypes.push(sortType);\n }\n return sortTypes;\n};\n\nconst getPreloadedPageSortType = (record?: PagesRecord): string | undefined => {\n const preloadedSortType = Object.keys(record?.pages || {}).find(Boolean);\n return preloadedSortType || getPublishedPageSortTypes(record)[0];\n};\n\nconst resolvePageSortType = (\n record: PagesRecord | undefined,\n requestedSortType: string | undefined,\n clientSortableSortTypes: string[],\n): string | undefined => {\n if (requestedSortType !== undefined) {\n return getAvailablePageSortTypes(record, clientSortableSortTypes).includes(requestedSortType)\n ? requestedSortType\n : undefined;\n }\n return getPreloadedPageSortType(record);\n};\n\n// the page that serves a resolved sort: its published page, or the complete preloaded page the\n// client re-sorts (a flat sort prefers a complete flat page, else flattens a hierarchical one)\nconst getPageSortTypeToRead = (\n record: PagesRecord | undefined,\n sortType: string | undefined,\n): string | undefined => {\n if (sortType === undefined) {\n return undefined;\n }\n if (getPublishedPageSortTypes(record).includes(sortType)) {\n return sortType;\n }\n const completeSortTypes = getCompletePreloadedPageSortTypes(record);\n const hierarchicalSortType = completeSortTypes.find(\n (preloadedSortType) => !isFlatSortType(preloadedSortType),\n );\n if (isFlatSortType(sortType)) {\n return completeSortTypes.find(isFlatSortType) ?? hierarchicalSortType;\n }\n return hierarchicalSortType;\n};\n\nexport const getAvailablePostSortTypes = (community?: Community): string[] =>\n getAvailablePageSortTypes(community?.posts, CLIENT_SORTABLE_POST_SORT_TYPES);\n\nexport const getAvailableReplySortTypes = (comment?: Comment): string[] =>\n getAvailablePageSortTypes(comment?.replies, getClientSortableReplySortTypes(comment));\n\nexport const getPreloadedPostSortType = (community?: Community): string | undefined =>\n getPreloadedPageSortType(community?.posts);\n\nexport const getPreloadedReplySortType = (comment?: Comment): string | undefined =>\n getPreloadedPageSortType(comment?.replies);\n\nexport const resolvePostSortType = (\n community: Community | undefined,\n requestedSortType?: string,\n): string | undefined =>\n resolvePageSortType(community?.posts, requestedSortType, CLIENT_SORTABLE_POST_SORT_TYPES);\n\nexport const resolveReplySortType = (\n comment: Comment | undefined,\n requestedSortType?: string,\n): string | undefined =>\n resolvePageSortType(\n comment?.replies,\n requestedSortType,\n getClientSortableReplySortTypes(comment),\n );\n\n// the `community.posts` page sort that serves a request, e.g. the preloaded `hot` page when a\n// single-page community serves `active` client-side; undefined when the sort cannot be served\nexport const getPostPageSortType = (\n community: Community | undefined,\n requestedSortType?: string,\n): string | undefined =>\n getPageSortTypeToRead(community?.posts, resolvePostSortType(community, requestedSortType));\n\nexport const getReplyPageSortType = (\n comment: Comment | undefined,\n requestedSortType?: string,\n): string | undefined =>\n getPageSortTypeToRead(comment?.replies, resolveReplySortType(comment, requestedSortType));\n"]}
1
+ {"version":3,"file":"page-sorts.js","sourceRoot":"","sources":["../../src/lib/page-sorts.ts"],"names":[],"mappings":"AASA,oGAAoG;AACpG,iGAAiG;AACjG,qGAAqG;AACrG,MAAM,+BAA+B,GAAG;IACtC,KAAK;IACL,KAAK;IACL,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,SAAS;IACT,UAAU;IACV,SAAS;IACT,QAAQ;CACT,CAAC;AACF,MAAM,gCAAgC,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAEtF,kGAAkG;AAClG,yFAAyF;AACzF,MAAM,+BAA+B,GAAG,CAAC,OAAiB,EAAY,EAAE;IACtE,MAAM,MAAM,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,MAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA,CAAC;IACxF,OAAO,MAAM;QACX,CAAC,CAAC,gCAAgC;QAClC,CAAC,CAAC,gCAAgC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvF,CAAC,CAAC;AAEF,6FAA6F;AAC7F,iEAAiE;AACjE,MAAM,uBAAuB,GAA2B;IACtD,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,QAAQ;CACf,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAiB,EAAW,EAAE,CAAC,OAAO,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QA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AAqB,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC","sourcesContent":["import { Comment, Community } from \"../types\";\n\ntype PagesRecord = {\n pages?: Record<string, unknown>;\n pageCids?: Record<string, unknown>;\n};\n\ntype PreloadedPage = { comments?: unknown; nextCid?: string } | undefined;\n\n// Standard pkc-js sorts (pkc-js src/pages/util.ts) whose scoring the feed sorter reproduces. pkc-js\n// preloads a single sort and only publishes pageCids once that page overflows, so a record whose\n// comments all fit in the preloaded page can serve any of these by re-sorting that page client-side.\nconst CLIENT_SORTABLE_POST_SORT_TYPES = [\n \"hot\",\n \"new\",\n \"active\",\n \"topHour\",\n \"topDay\",\n \"topWeek\",\n \"topMonth\",\n \"topYear\",\n \"topAll\",\n];\nconst CLIENT_SORTABLE_REPLY_SORT_TYPES = [\"best\", \"new\", \"old\", \"newFlat\", \"oldFlat\"];\n\n// pkc-js only publishes flat sorts for a post's replies (REPLY_REPLIES_SORT_TYPES has none), so a\n// nested reply must not advertise them while its replies still fit in the preloaded page\nconst getClientSortableReplySortTypes = (comment?: Comment): string[] => {\n const isPost = comment?.depth !== undefined ? comment.depth === 0 : !comment?.parentCid;\n return isPost\n ? CLIENT_SORTABLE_REPLY_SORT_TYPES\n : CLIENT_SORTABLE_REPLY_SORT_TYPES.filter((sortType) => !isFlatSortType(sortType));\n};\n\n// pkc-js TIMEFRAMES_TO_SECONDS, applied client-side when a timeframe sort is computed from a\n// preloaded page instead of a page the community windowed itself\nconst SORT_TIMEFRAMES_SECONDS: Record<string, number> = {\n Hour: 3600,\n Day: 86400,\n Week: 604800,\n Month: 2629746,\n Year: 31557600,\n};\n\nexport const isFlatSortType = (sortType?: string): boolean => Boolean(sortType?.endsWith(\"Flat\"));\n\nexport const getSortTimeframeSeconds = (sortType?: string): number | undefined => {\n const timeframe = sortType?.match(/^(?:top|controversial)(Hour|Day|Week|Month|Year)$/)?.[1];\n return timeframe ? SORT_TIMEFRAMES_SECONDS[timeframe] : undefined;\n};\n\nconst getPublishedPageSortTypes = (record?: PagesRecord): string[] => {\n const sortTypes = new Set<string>();\n for (const sortType of Object.keys(record?.pages || {})) {\n if (sortType) sortTypes.add(sortType);\n }\n for (const sortType of Object.keys(record?.pageCids || {})) {\n if (sortType) sortTypes.add(sortType);\n }\n return [...sortTypes];\n};\n\n// preloaded pages holding the record's complete comment set: no page continues with a nextCid and\n// no pageCids are published (pkc-js publishes pageCids for every sort once the preloaded page overflows)\nconst getCompletePreloadedPageSortTypes = (record?: PagesRecord): string[] => {\n if (Object.keys(record?.pageCids || {}).length > 0) {\n return [];\n }\n const pages = record?.pages || {};\n const sortTypes = Object.keys(pages).filter((sortType) =>\n Array.isArray((pages[sortType] as PreloadedPage)?.comments),\n );\n if (\n !sortTypes.length ||\n sortTypes.some((sortType) => (pages[sortType] as PreloadedPage)?.nextCid)\n ) {\n return [];\n }\n // a page windowed by a timeframe sort only holds that window, never the complete set\n return sortTypes.filter((sortType) => !getSortTimeframeSeconds(sortType));\n};\n\n// a flat sort flattens the whole reply tree, so every nested reply chain must be complete too\nconst hasCompleteReplyTree = (page: PreloadedPage): boolean =>\n ((page?.comments as Comment[] | undefined) || []).every((comment) => {\n const completeSortTypes = getCompletePreloadedPageSortTypes(comment?.replies);\n if (!completeSortTypes.length) {\n // no preloaded replies is only complete when the comment reports none, and a continued or\n // paged chain is never complete\n return !(comment?.replyCount > 0) && !Object.keys(comment?.replies?.pages || {}).length;\n }\n const hierarchicalSortType = completeSortTypes.find((sortType) => !isFlatSortType(sortType));\n return hierarchicalSortType === undefined\n ? true\n : hasCompleteReplyTree(comment.replies.pages[hierarchicalSortType]);\n });\n\n// a flat page cannot rebuild the reply tree, so it only serves flat sorts; a hierarchical page\n// serves flat sorts only when its nested reply chains are complete\nconst getClientSortableSortTypes = (\n record: PagesRecord | undefined,\n clientSortableSortTypes: string[],\n): string[] => {\n const completeSortTypes = getCompletePreloadedPageSortTypes(record);\n if (!completeSortTypes.length) {\n return [];\n }\n const hierarchicalSortType = completeSortTypes.find((sortType) => !isFlatSortType(sortType));\n if (hierarchicalSortType === undefined) {\n return clientSortableSortTypes.filter(isFlatSortType);\n }\n const canFlatten =\n completeSortTypes.some(isFlatSortType) ||\n hasCompleteReplyTree(record?.pages?.[hierarchicalSortType] as PreloadedPage);\n return canFlatten\n ? clientSortableSortTypes\n : clientSortableSortTypes.filter((sortType) => !isFlatSortType(sortType));\n};\n\nconst getAvailablePageSortTypes = (\n record: PagesRecord | undefined,\n clientSortableSortTypes: string[],\n): string[] => {\n const sortTypes = getPublishedPageSortTypes(record);\n for (const sortType of getClientSortableSortTypes(record, clientSortableSortTypes)) {\n if (!sortTypes.includes(sortType)) sortTypes.push(sortType);\n }\n return sortTypes;\n};\n\nconst getPreloadedPageSortType = (record?: PagesRecord): string | undefined => {\n const preloadedSortType = Object.keys(record?.pages || {}).find(Boolean);\n return preloadedSortType || getPublishedPageSortTypes(record)[0];\n};\n\nconst resolvePageSortType = (\n record: PagesRecord | undefined,\n requestedSortType: string | undefined,\n clientSortableSortTypes: string[],\n): string | undefined => {\n if (requestedSortType !== undefined) {\n return getAvailablePageSortTypes(record, clientSortableSortTypes).includes(requestedSortType)\n ? requestedSortType\n : undefined;\n }\n return getPreloadedPageSortType(record);\n};\n\n// the page that serves a resolved sort: its published page, or the complete preloaded page the\n// client re-sorts (a flat sort prefers a complete flat page, else flattens a hierarchical one)\nconst getPageSortTypeToRead = (\n record: PagesRecord | undefined,\n sortType: string | undefined,\n): string | undefined => {\n if (sortType === undefined) {\n return undefined;\n }\n if (getPublishedPageSortTypes(record).includes(sortType)) {\n return sortType;\n }\n const completeSortTypes = getCompletePreloadedPageSortTypes(record);\n const hierarchicalSortType = completeSortTypes.find(\n (preloadedSortType) => !isFlatSortType(preloadedSortType),\n );\n if (isFlatSortType(sortType)) {\n return completeSortTypes.find(isFlatSortType) ?? hierarchicalSortType;\n }\n return hierarchicalSortType;\n};\n\nexport const getAvailablePostSortTypes = (community?: Community): string[] =>\n getAvailablePageSortTypes(community?.posts, CLIENT_SORTABLE_POST_SORT_TYPES);\n\nexport const getAvailableReplySortTypes = (comment?: Comment): string[] =>\n getAvailablePageSortTypes(comment?.replies, getClientSortableReplySortTypes(comment));\n\nexport const getPreloadedPostSortType = (community?: Community): string | undefined =>\n getPreloadedPageSortType(community?.posts);\n\nexport const getPreloadedReplySortType = (comment?: Comment): string | undefined =>\n getPreloadedPageSortType(comment?.replies);\n\nexport const resolvePostSortType = (\n community: Community | undefined,\n requestedSortType?: string,\n): string | undefined =>\n resolvePageSortType(community?.posts, requestedSortType, CLIENT_SORTABLE_POST_SORT_TYPES);\n\nexport const resolveReplySortType = (\n comment: Comment | undefined,\n requestedSortType?: string,\n): string | undefined =>\n resolvePageSortType(\n comment?.replies,\n requestedSortType,\n getClientSortableReplySortTypes(comment),\n );\n\n// the options pkc-js applies to every sort; any other published option belongs to the sort file itself\nconst RESERVED_PAGE_SORT_OPTIONS = new Set([\n \"maxAge\",\n \"pinnedFirst\",\n \"excludeRemovedComments\",\n \"excludeDeletedComments\",\n \"excludeCommentPendingApproval\",\n \"excludeCommentWithApprovedFalse\",\n \"excludeCommentsWithDifferentCommunityAddress\",\n]);\n\n// a community configured with `settings.pages` publishes `community.pageSorts`, naming the file behind\n// each key; a package or path file published under a built-in key (e.g. a keyword no-bump `active`)\n// orders its pages by a score the client sorters do not reproduce. A node may also register such a\n// file under the built-in name itself, which its own options (e.g. `noBumpKeywords`) still reveal.\n// Unconfigured communities publish no `pageSorts`, so their keys are the built-ins.\nexport const isBuiltInPostSortType = (\n community: Community | undefined,\n sortType: string | undefined,\n): boolean => {\n const publishedPageSort = sortType ? community?.pageSorts?.posts?.[sortType] : undefined;\n return (\n !publishedPageSort ||\n (publishedPageSort.name === sortType &&\n Object.keys(publishedPageSort.publicOptions || {}).every((option) =>\n RESERVED_PAGE_SORT_OPTIONS.has(option),\n ))\n );\n};\n\n// the `community.posts` page sort that serves a request, e.g. the preloaded `hot` page when a\n// single-page community serves `active` client-side; undefined when the sort cannot be served\nexport const getPostPageSortType = (\n community: Community | undefined,\n requestedSortType?: string,\n): string | undefined =>\n getPageSortTypeToRead(community?.posts, resolvePostSortType(community, requestedSortType));\n\nexport const getReplyPageSortType = (\n comment: Comment | undefined,\n requestedSortType?: string,\n): string | undefined =>\n getPageSortTypeToRead(comment?.replies, resolveReplySortType(comment, requestedSortType));\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-actions.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/accounts-actions.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,OAAO,EAEP,qBAAqB,EAGrB,kBAAkB,EAClB,yBAAyB,EACzB,+BAA+B,EAC/B,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EAIhB,MAAM,aAAa,CAAC;AAsSrB,sGAAsG;AACtG,eAAO,MAAM,yBAAyB,GACpC,kBAAkB,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EACvC,WAAW,MAAM,EACjB,OAAO,MAAM,EACb,SAAS,CAAC,eAAe,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,GAAG,KAAK,IAAI;;;;;;CAO/D,CAAC;AA2BF,eAAO,MAAM,0BAA0B,GAAI,mBAAmB,GAAG,EAAE,yBAAyB,GAAG,YAGtC,CAAC;AAE1D,eAAO,MAAM,yBAAyB,GAAI,mBAAmB,GAAG,QAK/D,CAAC;AAuCF,eAAO,MAAM,kCAAkC,GAC7C,wBAAwB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC3D,WAAW,MAAM,EACjB,mBAAmB,GAAG;;CAsCvB,CAAC;AAEF,eAAO,MAAM,uCAAuC,GAClD,wBAAwB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC3D,eAAe,MAAM,CAAC,MAAM,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MAAM,WAAW,GAAU,YAAY,MAAM,EAAE,cAAc,MAAM,kBAEzE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,YAAY,MAAM,EAAE,cAAc,MAAM,kBAE3E,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,uBAAuB,qBAAqB,EAC5C,cAAc,MAAM,iBA+arB,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,iCAAiC,MAAM,GAAG,MAAM,EAChD,cAAc,MAAM,kBA2DrB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,oBAAoB,kBAAkB,EAAE,cAAc,MAAM,kBA4I7F,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAU,YAAY,MAAM,EAAE,cAAc,MAAM,kBAmCzE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,2BAA2B,yBAAyB,EACpD,cAAc,MAAM,kBA4IrB,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,iCAAiC,+BAA+B,EAChE,cAAc,MAAM,kBAyJrB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,kBAAkB,MAAM,EACxB,6BAA6B,2BAA2B,EACxD,cAAc,MAAM,kBA+JrB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,wBAAwB,sBAAsB,EAC9C,cAAc,MAAM,iBAkBrB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,kBAAkB,MAAM,EAAE,cAAc,MAAM,kBAcnF,CAAC"}
@@ -128,6 +128,10 @@ const getClientsSnapshotForState = (clients) => {
128
128
  return Object.keys(snapshot).length > 0 ? snapshot : undefined;
129
129
  };
130
130
  const unsafeCommentUpdatePropertyNames = new Set(["__proto__", "constructor", "prototype"]);
131
+ // commentUpdate.signature is the community's signature over the update, not the comment's own
132
+ // signature, which pkc-js keeps on the publication (and which a pseudonymous community re-signs).
133
+ const commentOwnedCommentUpdatePropertyNames = new Set(["signature"]);
134
+ const isPlainObject = (value) => !!value && typeof value === "object" && !Array.isArray(value);
131
135
  const applyChallengeVerificationCommentUpdateToPublication = (challengeVerification, publication) => {
132
136
  const commentUpdate = challengeVerification === null || challengeVerification === void 0 ? void 0 : challengeVerification.commentUpdate;
133
137
  if (!commentUpdate ||
@@ -138,9 +142,20 @@ const applyChallengeVerificationCommentUpdateToPublication = (challengeVerificat
138
142
  return;
139
143
  }
140
144
  for (const key of Object.keys(commentUpdate)) {
141
- if (!unsafeCommentUpdatePropertyNames.has(key)) {
142
- publication[key] = commentUpdate[key];
145
+ if (unsafeCommentUpdatePropertyNames.has(key) ||
146
+ commentOwnedCommentUpdatePropertyNames.has(key)) {
147
+ continue;
148
+ }
149
+ // commentUpdate.author only carries community-side fields such as author.community, so merge
150
+ // it like pkc-js does. Replacing it drops the published author address, which in a pseudonymous
151
+ // community is the community-assigned alias, not the account address.
152
+ if (key === "author" &&
153
+ isPlainObject(publication.author) &&
154
+ isPlainObject(commentUpdate.author)) {
155
+ publication.author = Object.assign(Object.assign({}, publication.author), commentUpdate.author);
156
+ continue;
143
157
  }
158
+ publication[key] = commentUpdate[key];
144
159
  }
145
160
  };
146
161
  const syncCommentClientsSnapshot = (publishSessionId, accountId, publication) => {