@bitsocial/bitsocial-react-hooks 0.4.0 → 0.4.1

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,17 @@
1
+ ## [0.4.1](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.4.0...v0.4.1) (2026-11-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **feeds:** treat a missing navigator.onLine as online, add setOnlineStatus ([#194](https://github.com/bitsocialnet/bitsocial-react-hooks/issues/194)) ([def871a](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/def871a4375cea6e52ab2dc71c13d77af20eb3bc))
7
+
8
+
9
+ ### Features
10
+
11
+ * **accounts:** recognize own comments across devices on pseudonymous boards ([#201](https://github.com/bitsocialnet/bitsocial-react-hooks/issues/201)) ([dd92a3a](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/dd92a3a30b9013c0cb63953d757e4ab5f5b2f5f5)), closes [#153](https://github.com/bitsocialnet/bitsocial-react-hooks/issues/153)
12
+
13
+
14
+
1
15
  # [0.4.0](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.3.6...v0.4.0) (2026-11-25)
2
16
 
3
17
 
@@ -1,4 +1,4 @@
1
- import type { Account, UseAccountCommunitiesOptions, UseAccountCommunitiesResult, UseAccountVoteOptions, UseAccountVoteResult, UseAccountVotesOptions, UseAccountVotesResult, UseAccountCommentsOptions, UseAccountCommentsResult, UseAccountCommentOptions, UseAccountCommentResult, UseNotificationsOptions, UseNotificationsResult, UseAccountEditsOptions, UseAccountEditsResult, UseEditedCommentOptions, UseEditedCommentResult, UseAccountOptions, UseAccountResult, UsePubsubSubscribeOptions, UsePubsubSubscribeResult } from "../../types.js";
1
+ import type { Account, UseAccountCommunitiesOptions, UseAccountCommunitiesResult, UseAccountVoteOptions, UseAccountVoteResult, UseAccountVotesOptions, UseAccountVotesResult, UseAccountCommentsOptions, UseAccountCommentsResult, UseAccountCommentOptions, UseAccountCommentResult, UseIsAccountCommentOptions, Comment, UseNotificationsOptions, UseNotificationsResult, UseAccountEditsOptions, UseAccountEditsResult, UseEditedCommentOptions, UseEditedCommentResult, UseAccountOptions, UseAccountResult, UsePubsubSubscribeOptions, UsePubsubSubscribeResult } from "../../types.js";
2
2
  /**
3
3
  * @param accountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, return
4
4
  * the active account id.
@@ -35,6 +35,22 @@ export declare function useAccountComments(options?: UseAccountCommentsOptions):
35
35
  * Returns an account's single comment, e.g. a pending comment they published.
36
36
  */
37
37
  export declare function useAccountComment(options?: UseAccountCommentOptions): UseAccountCommentResult;
38
+ /**
39
+ * Whether the account published a loaded comment: it is in the account's local history (pending
40
+ * comments included), it is signed by the account's key, or the community that aliased it on a
41
+ * pseudonymous board tagged it as the account's (`pseudonymityAuthorTag`). The last two work on any
42
+ * device holding the account key. Defaults to the active account. Use it outside React, e.g. to
43
+ * check every reply of a thread.
44
+ *
45
+ * The signature and the tag are read, not verified: pass comments loaded through the hooks or
46
+ * pkc-js, which verify them, or a comment from another source only after validateComment.
47
+ */
48
+ export declare function isAccountComment(comment: Comment | undefined, options?: Pick<UseIsAccountCommentOptions, "accountName">): boolean;
49
+ /**
50
+ * Whether the account published `comment`, see isAccountComment. Rerenders when the account or
51
+ * its history changes whether the comment is the account's.
52
+ */
53
+ export declare function useIsAccountComment(options?: UseIsAccountCommentOptions): boolean;
38
54
  /**
39
55
  * Returns the own user's votes stored locally, even those not yet published by the community owner.
40
56
  * Check UseAccountCommentsOptions type in types.tsx to filter them, e.g. filter = {communityAddresses: ['memes.eth']}.
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../src/hooks/accounts/accounts.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,OAAO,EAKP,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,sBAAs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ACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,OAAO,CAAC,EAAE,IAAI,CAAC,0BAA0B,EAAE,aAAa,CAAC,GACxD,OAAO,CAYT;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAajF;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,CA2BpF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,qBAAqB,CAqFvF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,sBAAsB,CAuK1F;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,wBAAwB,CA+ChG"}
@@ -19,6 +19,7 @@ import { useAccountsWithCalculatedProperties, useAccountWithCalculatedProperties
19
19
  import { COMMENT_MODERATION_AUTHOR_SUMMARY_KEY, getAccountEditPropertySummary, addShortCommunityAddressToAccountPublication, } from "../../stores/accounts/utils.js";
20
20
  import { getCanonicalCommunityAddress, getEquivalentCommunityAddressGroupKey, pickPreferredEquivalentCommunityAddress, } from "../../lib/community-address.js";
21
21
  import { addCommentModeration } from "../../lib/utils/comment-moderation.js";
22
+ import { isCommentBySigner } from "../../lib/pseudonymity-author-tag.js";
22
23
  import useInterval from "../utils/use-interval.js";
23
24
  import PkcJs from "../../lib/pkc-js/index.js";
24
25
  const getCommentEditPropertyValue = (comment, propertyName) => {
@@ -488,6 +489,62 @@ export function useAccountComment(options) {
488
489
  return Object.assign(Object.assign({}, accountComment), { state, error: accountComment.error, errors: accountComment.errors || [] });
489
490
  }, [storedAccountComment, account, accountId, state]);
490
491
  }
492
+ // A pending account comment has no cid yet, only its index in the account's history. For a cid,
493
+ // commentCidsToAccountsComments names only the last account holding the comment, so the history
494
+ // is scanned only when another account holds the same cid, e.g. a backup imported next to the
495
+ // account it was exported from. A cid nobody holds costs one lookup.
496
+ const isInAccountComments = (state, accountId, comment) => {
497
+ var _a, _b;
498
+ if (!accountId || !comment) {
499
+ return false;
500
+ }
501
+ const commentCid = comment.cid;
502
+ if (typeof commentCid !== "string") {
503
+ return (typeof comment.index === "number" &&
504
+ comment.accountId === accountId &&
505
+ ((_b = (_a = state.accountsComments[accountId]) === null || _a === void 0 ? void 0 : _a[comment.index]) === null || _b === void 0 ? void 0 : _b.accountId) === accountId);
506
+ }
507
+ const mapping = state.commentCidsToAccountsComments[commentCid];
508
+ if (!mapping) {
509
+ return false;
510
+ }
511
+ return (mapping.accountId === accountId ||
512
+ (state.accountsComments[accountId] || []).some((accountComment) => (accountComment === null || accountComment === void 0 ? void 0 : accountComment.cid) === commentCid));
513
+ };
514
+ /**
515
+ * Whether the account published a loaded comment: it is in the account's local history (pending
516
+ * comments included), it is signed by the account's key, or the community that aliased it on a
517
+ * pseudonymous board tagged it as the account's (`pseudonymityAuthorTag`). The last two work on any
518
+ * device holding the account key. Defaults to the active account. Use it outside React, e.g. to
519
+ * check every reply of a thread.
520
+ *
521
+ * The signature and the tag are read, not verified: pass comments loaded through the hooks or
522
+ * pkc-js, which verify them, or a comment from another source only after validateComment.
523
+ */
524
+ export function isAccountComment(comment, options) {
525
+ const state = useAccountsStore.getState();
526
+ const accountId = (options === null || options === void 0 ? void 0 : options.accountName)
527
+ ? state.accountNamesToAccountIds[options.accountName]
528
+ : state.activeAccountId;
529
+ const account = state.accounts[accountId || ""];
530
+ if (!comment || !account) {
531
+ return false;
532
+ }
533
+ return (isInAccountComments(state, accountId, comment) || isCommentBySigner(comment, account.signer));
534
+ }
535
+ /**
536
+ * Whether the account published `comment`, see isAccountComment. Rerenders when the account or
537
+ * its history changes whether the comment is the account's.
538
+ */
539
+ export function useIsAccountComment(options) {
540
+ assert(!options || typeof options === "object", `useIsAccountComment options argument '${options}' not an object`);
541
+ const { comment, accountName } = options !== null && options !== void 0 ? options : {};
542
+ const accountId = useAccountId(accountName) || undefined;
543
+ const signer = useAccountsStore((state) => { var _a; return (_a = state.accounts[accountId || ""]) === null || _a === void 0 ? void 0 : _a.signer; });
544
+ const inAccountComments = useAccountsStore((state) => isInAccountComments(state, accountId, comment));
545
+ const bySigner = useMemo(() => isCommentBySigner(comment, signer), [comment, signer]);
546
+ return inAccountComments || bySigner;
547
+ }
491
548
  /**
492
549
  * Returns the own user's votes stored locally, even those not yet published by the community owner.
493
550
  * Check UseAccountCommentsOptions type in types.tsx to filter them, e.g. filter = {communityAddresses: ['memes.eth']}.
@@ -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,oBAAoB,CAAC;AACzC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAC3D,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA8BpE,OAAO,EACL,mCAAmC,EACnC,kCAAkC,EAClC,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,qCAAqC,EACrC,6BAA6B,EAC7B,4CAA4C,GAC7C,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,4BAA4B,EAC5B,qCAAqC,EACrC,uCAAuC,GACxC,MAAM,6BAA6B,CAAC;AACr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AAC,QAAQ,CAAC,CAAC;YACnB,GAAG,CAAC,KAAK,CAAC,8CAA8C,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;QAEL,6BAA6B;QAC7B,OAAO;YACL,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAU,EAAE,EAAE;gBACnE,SAAS,CAAC,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;gBAC9B,GAAG,CAAC,KAAK,CAAC,gDAAgD,EAAE;oBAC1D,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 \"../../lib/is-equal\";\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 \"../../lib/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 addShortCommunityAddressToAccountPublication,\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\n// A commentModeration.author.banExpiresAt of 0 only removes the ban mark (authorBanExpiresAt) from the comment it\n// is published on (pkc-js 0.0.158+), so it is applied once that comment has no mark\nconst isCommentEditPropertyApplied = (comment: any, propertyName: string, value: any) =>\n propertyName === COMMENT_MODERATION_AUTHOR_SUMMARY_KEY && value?.banExpiresAt === 0\n ? comment?.authorBanExpiresAt === undefined\n : isEqual(getCommentEditPropertyValue(comment, propertyName), value);\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 // 0 removes this comment's ban mark and leaves the author's ban as it is\n if (value?.banExpiresAt === 0) {\n delete comment.authorBanExpiresAt;\n return;\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 // pkc-js marks the comment a ban was published on with authorBanExpiresAt, and keeps the mark after an unban\n if (typeof value?.banExpiresAt === \"number\" && value.banExpiresAt > 0) {\n comment.authorBanExpiresAt = 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\n// a pending comment or edit that nothing resolved within this time is considered failed\nconst pendingExpirySeconds = 60 * 20;\n\n/** Calls onTime once Date.now() reaches time (in seconds), for states derived from the clock. */\nconst useTimeoutAt = (time: number | undefined, onTime: () => void) => {\n useEffect(() => {\n if (time === undefined) return;\n const timeout = setTimeout(onTime, Math.max(time * 1000 - Date.now(), 0));\n return () => clearTimeout(timeout);\n }, [time]);\n};\n\nconst getAccountCommentsStates = (accountComments: AccountComment[]) => {\n // Without a cid, the account comment is still a local pending publish. It failed once its\n // publication stopped with `publishingState === \"failed\"`, or stopped without succeeding after a\n // publish error. pkc-js also emits errors it recovers from, while the publication keeps\n // publishing, so a recorded error alone does not make it failed. A final error that pkc-js left\n // publishing, like a rejected publish(), is recorded with state \"stopped\". A succeeded comment\n // has no cid only until its cid is saved.\n const now = Math.round(Date.now() / 1000);\n const expiryTime = now - pendingExpirySeconds;\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 hasPublishError =\n ac.error != null || (Array.isArray(ac.errors) && ac.errors.length > 0);\n const resolvedPublishFailed =\n ac.state === \"stopped\" &&\n (ac.publishingState === \"failed\" ||\n (hasPublishError && ac.publishingState !== \"succeeded\"));\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 // rerender when a pending comment expires, even if no store update rerenders the hook\n const [, setPendingExpiryRerenders] = useState(0);\n useTimeoutAt(\n state === \"pending\" ? storedAccountComment!.timestamp + pendingExpirySeconds : undefined,\n () => setPendingExpiryRerenders((rerenders) => rerenders + 1),\n );\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(addShortCommunityAddressToAccountPublication(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 = addShortCommunityAddressToAccountPublication(\n accountVotes?.[commentCidKey],\n );\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 // the edit history of this account failed to load from the database\n const [loadError, setLoadError] = useState<{ accountId: string; error: Error }>();\n // another account loads its own edits, and coming back to this one loads them again\n if (loadError && loadError.accountId !== accountId) {\n setLoadError(undefined);\n }\n\n useEffect(() => {\n if (!accountId || accountEditsLoaded) {\n return;\n }\n // a new load replaces the failure of the previous one\n setLoadError(undefined);\n // a load the hook moved on from, e.g. of the previous account, doesn't report its failure\n let isCurrentLoad = true;\n ensureAccountEditsLoaded(accountId).catch((error: unknown) => {\n log.error(\"useAccountEdits ensureAccountEditsLoaded error\", { accountId, error });\n if (isCurrentLoad) {\n setLoadError({ accountId, error: error instanceof Error ? error : Error(String(error)) });\n }\n });\n return () => {\n isCurrentLoad = false;\n };\n }, [accountEditsLoaded, accountId, ensureAccountEditsLoaded]);\n\n const accountEditsArray = useMemo(() => {\n const accountEditsArray = [];\n for (const i in accountEdits || {}) {\n accountEditsArray.push(...accountEdits[i].map(addShortCommunityAddressToAccountPublication));\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 the pending and failed publishing states of each edit, see docs/TODO.md\n\n const error =\n accountId && !accountEditsLoaded && loadError?.accountId === accountId\n ? loadError.error\n : undefined;\n const state = !accountId\n ? \"initializing\"\n : accountEditsLoaded\n ? \"succeeded\"\n : error\n ? \"failed\"\n : \"initializing\";\n\n return useMemo(\n () => ({\n accountEdits: filteredAccountEditsArray,\n state,\n error,\n errors: error ? [error] : [],\n }),\n [filteredAccountEditsArray, state, error],\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 // bumped when an edit stops being too recent to evaluate, so the memo below evaluates it again\n const [pendingExpiryRerenders, setPendingExpiryRerenders] = useState(0);\n const { editedResult, pendingEditsExpireAt } = useMemo(() => {\n const editedResult: any = {\n editedComment: undefined,\n succeededEdits: {},\n pendingEdits: {},\n failedEdits: {},\n state: undefined,\n };\n // when the earliest edit that is pending only because it is recent expires\n let pendingEditsExpireAt: number | undefined;\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, pendingEditsExpireAt };\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 = pendingExpirySeconds;\n const expirePendingEditLater = (propertyNameEdit: any) => {\n const expireAt = propertyNameEdit.timestamp + expiryTime;\n pendingEditsExpireAt = Math.min(pendingEditsExpireAt ?? expireAt, expireAt);\n };\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 (isCommentEditPropertyApplied(comment, propertyName, propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n } else if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n expirePendingEditLater(propertyNameEdit);\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 (isCommentEditPropertyApplied(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 expirePendingEditLater(propertyNameEdit);\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, pendingEditsExpireAt };\n }, [comment, commentEditSummary, commentEdits, pendingExpiryRerenders]);\n useTimeoutAt(pendingEditsExpireAt, () => setPendingExpiryRerenders((rerenders) => rerenders + 1));\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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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 \"../../lib/is-equal\";\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 \"../../lib/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 UseIsAccountCommentOptions,\n Comment,\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 addShortCommunityAddressToAccountPublication,\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 { isCommentBySigner } from \"../../lib/pseudonymity-author-tag\";\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\n// A commentModeration.author.banExpiresAt of 0 only removes the ban mark (authorBanExpiresAt) from the comment it\n// is published on (pkc-js 0.0.158+), so it is applied once that comment has no mark\nconst isCommentEditPropertyApplied = (comment: any, propertyName: string, value: any) =>\n propertyName === COMMENT_MODERATION_AUTHOR_SUMMARY_KEY && value?.banExpiresAt === 0\n ? comment?.authorBanExpiresAt === undefined\n : isEqual(getCommentEditPropertyValue(comment, propertyName), value);\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 // 0 removes this comment's ban mark and leaves the author's ban as it is\n if (value?.banExpiresAt === 0) {\n delete comment.authorBanExpiresAt;\n return;\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 // pkc-js marks the comment a ban was published on with authorBanExpiresAt, and keeps the mark after an unban\n if (typeof value?.banExpiresAt === \"number\" && value.banExpiresAt > 0) {\n comment.authorBanExpiresAt = 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\n// a pending comment or edit that nothing resolved within this time is considered failed\nconst pendingExpirySeconds = 60 * 20;\n\n/** Calls onTime once Date.now() reaches time (in seconds), for states derived from the clock. */\nconst useTimeoutAt = (time: number | undefined, onTime: () => void) => {\n useEffect(() => {\n if (time === undefined) return;\n const timeout = setTimeout(onTime, Math.max(time * 1000 - Date.now(), 0));\n return () => clearTimeout(timeout);\n }, [time]);\n};\n\nconst getAccountCommentsStates = (accountComments: AccountComment[]) => {\n // Without a cid, the account comment is still a local pending publish. It failed once its\n // publication stopped with `publishingState === \"failed\"`, or stopped without succeeding after a\n // publish error. pkc-js also emits errors it recovers from, while the publication keeps\n // publishing, so a recorded error alone does not make it failed. A final error that pkc-js left\n // publishing, like a rejected publish(), is recorded with state \"stopped\". A succeeded comment\n // has no cid only until its cid is saved.\n const now = Math.round(Date.now() / 1000);\n const expiryTime = now - pendingExpirySeconds;\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 hasPublishError =\n ac.error != null || (Array.isArray(ac.errors) && ac.errors.length > 0);\n const resolvedPublishFailed =\n ac.state === \"stopped\" &&\n (ac.publishingState === \"failed\" ||\n (hasPublishError && ac.publishingState !== \"succeeded\"));\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 // rerender when a pending comment expires, even if no store update rerenders the hook\n const [, setPendingExpiryRerenders] = useState(0);\n useTimeoutAt(\n state === \"pending\" ? storedAccountComment!.timestamp + pendingExpirySeconds : undefined,\n () => setPendingExpiryRerenders((rerenders) => rerenders + 1),\n );\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\ntype AccountsStoreState = ReturnType<typeof useAccountsStore.getState>;\n\n// A pending account comment has no cid yet, only its index in the account's history. For a cid,\n// commentCidsToAccountsComments names only the last account holding the comment, so the history\n// is scanned only when another account holds the same cid, e.g. a backup imported next to the\n// account it was exported from. A cid nobody holds costs one lookup.\nconst isInAccountComments = (\n state: AccountsStoreState,\n accountId: string | undefined,\n comment: Comment | undefined,\n) => {\n if (!accountId || !comment) {\n return false;\n }\n const commentCid = comment.cid;\n if (typeof commentCid !== \"string\") {\n return (\n typeof comment.index === \"number\" &&\n comment.accountId === accountId &&\n state.accountsComments[accountId]?.[comment.index]?.accountId === accountId\n );\n }\n const mapping = state.commentCidsToAccountsComments[commentCid];\n if (!mapping) {\n return false;\n }\n return (\n mapping.accountId === accountId ||\n (state.accountsComments[accountId] || []).some(\n (accountComment) => accountComment?.cid === commentCid,\n )\n );\n};\n\n/**\n * Whether the account published a loaded comment: it is in the account's local history (pending\n * comments included), it is signed by the account's key, or the community that aliased it on a\n * pseudonymous board tagged it as the account's (`pseudonymityAuthorTag`). The last two work on any\n * device holding the account key. Defaults to the active account. Use it outside React, e.g. to\n * check every reply of a thread.\n *\n * The signature and the tag are read, not verified: pass comments loaded through the hooks or\n * pkc-js, which verify them, or a comment from another source only after validateComment.\n */\nexport function isAccountComment(\n comment: Comment | undefined,\n options?: Pick<UseIsAccountCommentOptions, \"accountName\">,\n): boolean {\n const state = useAccountsStore.getState();\n const accountId = options?.accountName\n ? state.accountNamesToAccountIds[options.accountName]\n : state.activeAccountId;\n const account = state.accounts[accountId || \"\"];\n if (!comment || !account) {\n return false;\n }\n return (\n isInAccountComments(state, accountId, comment) || isCommentBySigner(comment, account.signer)\n );\n}\n\n/**\n * Whether the account published `comment`, see isAccountComment. Rerenders when the account or\n * its history changes whether the comment is the account's.\n */\nexport function useIsAccountComment(options?: UseIsAccountCommentOptions): boolean {\n assert(\n !options || typeof options === \"object\",\n `useIsAccountComment options argument '${options}' not an object`,\n );\n const { comment, accountName } = options ?? {};\n const accountId = useAccountId(accountName) || undefined;\n const signer = useAccountsStore((state) => state.accounts[accountId || \"\"]?.signer);\n const inAccountComments = useAccountsStore((state) =>\n isInAccountComments(state, accountId, comment),\n );\n const bySigner = useMemo(() => isCommentBySigner(comment, signer), [comment, signer]);\n return inAccountComments || bySigner;\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(addShortCommunityAddressToAccountPublication(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 = addShortCommunityAddressToAccountPublication(\n accountVotes?.[commentCidKey],\n );\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 // the edit history of this account failed to load from the database\n const [loadError, setLoadError] = useState<{ accountId: string; error: Error }>();\n // another account loads its own edits, and coming back to this one loads them again\n if (loadError && loadError.accountId !== accountId) {\n setLoadError(undefined);\n }\n\n useEffect(() => {\n if (!accountId || accountEditsLoaded) {\n return;\n }\n // a new load replaces the failure of the previous one\n setLoadError(undefined);\n // a load the hook moved on from, e.g. of the previous account, doesn't report its failure\n let isCurrentLoad = true;\n ensureAccountEditsLoaded(accountId).catch((error: unknown) => {\n log.error(\"useAccountEdits ensureAccountEditsLoaded error\", { accountId, error });\n if (isCurrentLoad) {\n setLoadError({ accountId, error: error instanceof Error ? error : Error(String(error)) });\n }\n });\n return () => {\n isCurrentLoad = false;\n };\n }, [accountEditsLoaded, accountId, ensureAccountEditsLoaded]);\n\n const accountEditsArray = useMemo(() => {\n const accountEditsArray = [];\n for (const i in accountEdits || {}) {\n accountEditsArray.push(...accountEdits[i].map(addShortCommunityAddressToAccountPublication));\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 the pending and failed publishing states of each edit, see docs/TODO.md\n\n const error =\n accountId && !accountEditsLoaded && loadError?.accountId === accountId\n ? loadError.error\n : undefined;\n const state = !accountId\n ? \"initializing\"\n : accountEditsLoaded\n ? \"succeeded\"\n : error\n ? \"failed\"\n : \"initializing\";\n\n return useMemo(\n () => ({\n accountEdits: filteredAccountEditsArray,\n state,\n error,\n errors: error ? [error] : [],\n }),\n [filteredAccountEditsArray, state, error],\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 // bumped when an edit stops being too recent to evaluate, so the memo below evaluates it again\n const [pendingExpiryRerenders, setPendingExpiryRerenders] = useState(0);\n const { editedResult, pendingEditsExpireAt } = useMemo(() => {\n const editedResult: any = {\n editedComment: undefined,\n succeededEdits: {},\n pendingEdits: {},\n failedEdits: {},\n state: undefined,\n };\n // when the earliest edit that is pending only because it is recent expires\n let pendingEditsExpireAt: number | undefined;\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, pendingEditsExpireAt };\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 = pendingExpirySeconds;\n const expirePendingEditLater = (propertyNameEdit: any) => {\n const expireAt = propertyNameEdit.timestamp + expiryTime;\n pendingEditsExpireAt = Math.min(pendingEditsExpireAt ?? expireAt, expireAt);\n };\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 (isCommentEditPropertyApplied(comment, propertyName, propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n } else if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n expirePendingEditLater(propertyNameEdit);\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 (isCommentEditPropertyApplied(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 expirePendingEditLater(propertyNameEdit);\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, pendingEditsExpireAt };\n }, [comment, commentEditSummary, commentEdits, pendingExpiryRerenders]);\n useTimeoutAt(pendingEditsExpireAt, () => setPendingExpiryRerenders((rerenders) => rerenders + 1));\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"]}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { useAccount, useAccounts, useAccountComment, useAccountComments, useAccountVotes, useAccountVote, useAccountEdits, useEditedComment, useNotifications, useAccountCommunities, usePubsubSubscribe } from "./hooks/accounts/index.js";
1
+ import { useAccount, useAccounts, useAccountComment, useAccountComments, useIsAccountComment, isAccountComment, useAccountVotes, useAccountVote, useAccountEdits, useEditedComment, useNotifications, useAccountCommunities, usePubsubSubscribe } from "./hooks/accounts/index.js";
2
2
  import { useComment, useComments, useCrosspost, useValidateComment, validateComment } from "./hooks/comments.js";
3
3
  import { useReplies } from "./hooks/replies.js";
4
4
  import { useCommunity, useCommunities, useCommunityStats, useListCommunities, useResolvedCommunityAddress } from "./hooks/communities.js";
@@ -10,16 +10,19 @@ import { useClientsStates, useCommunitiesStates } from "./hooks/states.js";
10
10
  import { usePkcRpcSettings } from "./hooks/pkc-rpc.js";
11
11
  import { getEthWalletFromPkcPrivateKey, getEthPrivateKeyFromPkcPrivateKey, validateEthWallet } from "./lib/chain/index.js";
12
12
  import { setPkcJs, restorePkcJs } from "./lib/pkc-js/index.js";
13
+ import { setOnlineStatus } from "./lib/online-status.js";
13
14
  import { deleteDatabases, deleteCaches } from "./lib/debug-utils.js";
14
15
  import { createCrosspost } from "./lib/crosspost.js";
15
16
  import { getAvailablePostSortTypes, getAvailableReplySortTypes, getPreloadedPostSortType, getPreloadedReplySortType, getPreloadedPostSortTypes, getPreloadedReplySortTypes, getPostPageSortType, getReplyPageSortType, getSortTimeframeSeconds, isFlatSortType, resolvePostSortType, resolveReplySortType } from "./lib/page-sorts.js";
16
17
  export * from "./types.js";
17
- export { useAccount, useAccounts, useAccountComment, useAccountComments, useAccountVotes, useAccountVote, useAccountEdits, useAccountCommunities, useNotifications, usePubsubSubscribe, useComment, useComments, useCrosspost, useEditedComment, useValidateComment, validateComment, useReplies, useCommunity, useCommunities, useCommunityStats, useListCommunities, useResolvedCommunityAddress, useAuthor, useAuthorComments, useAuthorAvatar, useResolvedAuthorAddress, useAuthorAddress, setAuthorAvatarsWhitelistedTokenAddresses, resetAuthorAddressCacheForTesting, useFeed, useBufferedFeeds, useSubscribe, useBlock, useSaveComment, usePublishComment, usePublishVote, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useCreateCommunity, useExportCommunity, createAccount, deleteAccount, deleteComment, setAccount, setActiveAccount, setAccountsOrder, importAccount, exportAccount, deleteCommunity, useClientsStates, useCommunitiesStates, usePkcRpcSettings, getEthWalletFromPkcPrivateKey, getEthPrivateKeyFromPkcPrivateKey, validateEthWallet, setPkcJs, restorePkcJs, deleteDatabases, deleteCaches, createCrosspost, getAvailablePostSortTypes, getAvailableReplySortTypes, getPreloadedPostSortType, getPreloadedReplySortType, getPreloadedPostSortTypes, getPreloadedReplySortTypes, getPostPageSortType, getReplyPageSortType, getSortTimeframeSeconds, isFlatSortType, resolvePostSortType, resolveReplySortType, };
18
+ export { useAccount, useAccounts, useAccountComment, useAccountComments, useIsAccountComment, isAccountComment, useAccountVotes, useAccountVote, useAccountEdits, useAccountCommunities, useNotifications, usePubsubSubscribe, useComment, useComments, useCrosspost, useEditedComment, useValidateComment, validateComment, useReplies, useCommunity, useCommunities, useCommunityStats, useListCommunities, useResolvedCommunityAddress, useAuthor, useAuthorComments, useAuthorAvatar, useResolvedAuthorAddress, useAuthorAddress, setAuthorAvatarsWhitelistedTokenAddresses, resetAuthorAddressCacheForTesting, useFeed, useBufferedFeeds, useSubscribe, useBlock, useSaveComment, usePublishComment, usePublishVote, usePublishCommentEdit, usePublishCommentModeration, usePublishCommunityEdit, useCreateCommunity, useExportCommunity, createAccount, deleteAccount, deleteComment, setAccount, setActiveAccount, setAccountsOrder, importAccount, exportAccount, deleteCommunity, useClientsStates, useCommunitiesStates, usePkcRpcSettings, getEthWalletFromPkcPrivateKey, getEthPrivateKeyFromPkcPrivateKey, validateEthWallet, setPkcJs, setOnlineStatus, restorePkcJs, deleteDatabases, deleteCaches, createCrosspost, getAvailablePostSortTypes, getAvailableReplySortTypes, getPreloadedPostSortType, getPreloadedReplySortType, getPreloadedPostSortTypes, getPreloadedReplySortTypes, getPostPageSortType, getReplyPageSortType, getSortTimeframeSeconds, isFlatSortType, resolvePostSortType, resolveReplySortType, };
18
19
  declare const hooks: {
19
20
  useAccount: typeof useAccount;
20
21
  useAccounts: typeof useAccounts;
21
22
  useAccountComment: typeof useAccountComment;
22
23
  useAccountComments: typeof useAccountComments;
24
+ useIsAccountComment: typeof useIsAccountComment;
25
+ isAccountComment: typeof isAccountComment;
23
26
  useAccountVotes: typeof useAccountVotes;
24
27
  useAccountVote: typeof useAccountVote;
25
28
  useAccountEdits: typeof useAccountEdits;
@@ -80,6 +83,7 @@ declare const hooks: {
80
83
  getEthPrivateKeyFromPkcPrivateKey: (privateKeyBase64: string, authorAddress?: string) => Promise<string | undefined>;
81
84
  validateEthWallet: (wallet: import("./types.js").Wallet, authorPublicKey: string) => Promise<void>;
82
85
  setPkcJs: typeof setPkcJs;
86
+ setOnlineStatus: (online: boolean | undefined) => void;
83
87
  restorePkcJs: typeof restorePkcJs;
84
88
  deleteDatabases: () => Promise<void>;
85
89
  deleteCaches: () => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,UAAU,EACV,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,EAC5B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,yCAAyC,EACzC,iCAAiC,EAClC,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,eAAe,EAChB,MAA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