@bitsocial/bitsocial-react-hooks 0.1.15 → 0.1.17
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 +20 -0
- package/dist/hooks/accounts/accounts.d.ts.map +1 -1
- package/dist/hooks/accounts/accounts.js +41 -5
- package/dist/hooks/accounts/accounts.js.map +1 -1
- package/dist/hooks/actions/actions.js.map +1 -1
- package/dist/lib/pkc-compat.d.ts +7 -0
- package/dist/lib/pkc-compat.d.ts.map +1 -1
- package/dist/lib/pkc-compat.js +18 -0
- package/dist/lib/pkc-compat.js.map +1 -1
- package/dist/lib/pkc-js/pkc-js-mock-content.js +1 -1
- package/dist/lib/pkc-js/pkc-js-mock-content.js.map +1 -1
- package/dist/lib/pkc-js/pkc-js-mock.d.ts +3 -1
- package/dist/lib/pkc-js/pkc-js-mock.d.ts.map +1 -1
- package/dist/lib/pkc-js/pkc-js-mock.js +1 -1
- package/dist/lib/pkc-js/pkc-js-mock.js.map +1 -1
- package/dist/stores/accounts/accounts-actions.d.ts.map +1 -1
- package/dist/stores/accounts/accounts-actions.js +30 -10
- package/dist/stores/accounts/accounts-actions.js.map +1 -1
- package/dist/stores/accounts/utils.d.ts +1 -0
- package/dist/stores/accounts/utils.d.ts.map +1 -1
- package/dist/stores/accounts/utils.js +21 -3
- package/dist/stores/accounts/utils.js.map +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +17 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## [0.1.17](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.16...v0.1.17) (2026-06-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **actions:** adapt challenge answers for pkc-js ([20d89f0](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/20d89f07363f54c38b83e0f9425bd77174854f9f))
|
|
7
|
+
* **deps:** upgrade pkc-js and kubo ([9cb56c2](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/9cb56c298fbf02bde4ef1a881eee60687ae2a1dd))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [0.1.16](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.15...v0.1.16) (2026-06-07)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **accounts:** preserve comment moderation author edits ([#63](https://github.com/bitsocialnet/bitsocial-react-hooks/issues/63)) ([722b244](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/722b2446277868597ea0cc6875d92919d42a4d21))
|
|
17
|
+
* **deps:** resolve dependabot alerts ([e92ae1c](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/e92ae1ca08bf3624f38f0e49890d72eabd318da7))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
1
21
|
## [0.1.15](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.14...v0.1.15) (2026-06-07)
|
|
2
22
|
|
|
3
23
|
|
|
@@ -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,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../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e,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,qBAAqB,CA0DvF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,sBAAsB,CA4J1F;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,wBAAwB,CA+ChG"}
|
|
@@ -16,10 +16,46 @@ const log = Logger("bitsocial-react-hooks:accounts:hooks");
|
|
|
16
16
|
import assert from "assert";
|
|
17
17
|
import { useListCommunities, useCommunities } from "../communities.js";
|
|
18
18
|
import { useAccountsWithCalculatedProperties, useAccountWithCalculatedProperties, useCalculatedNotifications, } from "./utils.js";
|
|
19
|
-
import { getAccountEditPropertySummary } from "../../stores/accounts/utils.js";
|
|
19
|
+
import { COMMENT_MODERATION_AUTHOR_SUMMARY_KEY, getAccountEditPropertySummary, } 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
22
|
import useInterval from "../utils/use-interval.js";
|
|
23
|
+
const getCommentEditPropertyValue = (comment, propertyName) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {
|
|
26
|
+
return comment === null || comment === void 0 ? void 0 : comment[propertyName];
|
|
27
|
+
}
|
|
28
|
+
const commentModeration = comment === null || comment === void 0 ? void 0 : comment.commentModeration;
|
|
29
|
+
if (commentModeration &&
|
|
30
|
+
typeof commentModeration === "object" &&
|
|
31
|
+
Object.prototype.hasOwnProperty.call(commentModeration, "author")) {
|
|
32
|
+
return commentModeration.author;
|
|
33
|
+
}
|
|
34
|
+
return ((_b = (_a = comment === null || comment === void 0 ? void 0 : comment.author) === null || _a === void 0 ? void 0 : _a.community) === null || _b === void 0 ? void 0 : _b.banExpiresAt) !== undefined
|
|
35
|
+
? { banExpiresAt: comment.author.community.banExpiresAt }
|
|
36
|
+
: undefined;
|
|
37
|
+
};
|
|
38
|
+
const applyEditedCommentProperty = (comment, propertyName, value) => {
|
|
39
|
+
if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {
|
|
40
|
+
comment[propertyName] = value;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
comment.commentModeration = comment.commentModeration ? Object.assign({}, comment.commentModeration) : {};
|
|
44
|
+
if (value === undefined) {
|
|
45
|
+
delete comment.commentModeration.author;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
comment.commentModeration.author = value;
|
|
49
|
+
}
|
|
50
|
+
comment.author = comment.author ? Object.assign({}, comment.author) : {};
|
|
51
|
+
comment.author.community = comment.author.community ? Object.assign({}, comment.author.community) : {};
|
|
52
|
+
if ((value === null || value === void 0 ? void 0 : value.banExpiresAt) === undefined) {
|
|
53
|
+
delete comment.author.community.banExpiresAt;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
comment.author.community.banExpiresAt = value.banExpiresAt;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
23
59
|
/**
|
|
24
60
|
* @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return
|
|
25
61
|
* the active account id.
|
|
@@ -589,7 +625,7 @@ export function useEditedComment(options) {
|
|
|
589
625
|
// Without a newer update we can only treat recent edits as pending. Older edits that never
|
|
590
626
|
// produced any update are effectively stale and should stop shadowing the live comment.
|
|
591
627
|
if (!(comment === null || comment === void 0 ? void 0 : comment.updatedAt)) {
|
|
592
|
-
if (isEqual(comment
|
|
628
|
+
if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {
|
|
593
629
|
setPropertyNameEditState("succeeded");
|
|
594
630
|
}
|
|
595
631
|
else if (propertyNameEdit.timestamp > now - expiryTime) {
|
|
@@ -610,7 +646,7 @@ export function useEditedComment(options) {
|
|
|
610
646
|
// has been received after the edit was published so we can evaluate
|
|
611
647
|
else {
|
|
612
648
|
// comment has propertyNameEdit, propertyNameEdit succeeded
|
|
613
|
-
if (isEqual(comment
|
|
649
|
+
if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {
|
|
614
650
|
setPropertyNameEditState("succeeded");
|
|
615
651
|
continue;
|
|
616
652
|
}
|
|
@@ -646,10 +682,10 @@ export function useEditedComment(options) {
|
|
|
646
682
|
// add pending and succeeded props so the editor can see his changes right away
|
|
647
683
|
// don't add failed edits to reflect the current state of the edited comment
|
|
648
684
|
for (const propertyName in editedResult.pendingEdits) {
|
|
649
|
-
editedResult.editedComment
|
|
685
|
+
applyEditedCommentProperty(editedResult.editedComment, propertyName, editedResult.pendingEdits[propertyName]);
|
|
650
686
|
}
|
|
651
687
|
for (const propertyName in editedResult.succeededEdits) {
|
|
652
|
-
editedResult.editedComment
|
|
688
|
+
applyEditedCommentProperty(editedResult.editedComment, propertyName, editedResult.succeededEdits[propertyName]);
|
|
653
689
|
}
|
|
654
690
|
editedResult.editedComment = addCommentModeration(editedResult.editedComment);
|
|
655
691
|
return editedResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/hooks/accounts/accounts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAC3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gB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AAC;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 \"lodash.isequal\";\nimport useAccountsStore from \"../../stores/accounts\";\nimport useCommunitiesStore from \"../../stores/communities\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:hooks\");\nimport assert from \"assert\";\nimport { useListCommunities, useCommunities } from \"../communities\";\nimport type {\n AccountComment,\n AccountComments,\n Account,\n Accounts,\n AccountVote,\n AccountsComments,\n AccountsCommentsReplies,\n UseAccountCommunitiesOptions,\n UseAccountCommunitiesResult,\n UseAccountVoteOptions,\n UseAccountVoteResult,\n UseAccountVotesOptions,\n UseAccountVotesResult,\n UseAccountCommentsOptions,\n UseAccountCommentsResult,\n UseAccountCommentOptions,\n UseAccountCommentResult,\n UseNotificationsOptions,\n UseNotificationsResult,\n UseAccountEditsOptions,\n UseAccountEditsResult,\n UseEditedCommentOptions,\n UseEditedCommentResult,\n UseAccountOptions,\n UseAccountResult,\n UsePubsubSubscribeOptions,\n UsePubsubSubscribeResult,\n} from \"../../types\";\nimport {\n useAccountsWithCalculatedProperties,\n useAccountWithCalculatedProperties,\n useCalculatedNotifications,\n} from \"./utils\";\nimport { getAccountEditPropertySummary } 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\";\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account 1'. 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 1'. 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 1'. If no accountName is provided, return\n * the active account's notifications.\n */\nexport function useNotifications(options?: UseNotificationsOptions): UseNotificationsResult {\n assert(\n !options || typeof options === \"object\",\n `useNotifications options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const accountsActionsInternal = useAccountsStore((state) => state.accountsActionsInternal);\n const notifications = useCalculatedNotifications(account, accountCommentsReplies);\n const [errors, setErrors] = useState<Error[]>([]);\n\n const markAsRead = async () => {\n try {\n if (!account) {\n throw Error(\"useNotifications cannot mark as read accounts not initalized yet\");\n }\n accountsActionsInternal.markNotificationsAsRead(account);\n } catch (e: any) {\n setErrors([...errors, e]);\n }\n };\n\n if (account) {\n log(\"useNotifications\", { notifications });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n notifications,\n markAsRead,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [notifications, errors],\n );\n}\n\nconst getAccountCommentsStates = (accountComments: AccountComment[]) => {\n // Without a cid, the account comment is still a local pending publish. pkc-js marks\n // terminal publish failures when `publishingState === \"failed\"` and publication `state`\n // is `\"stopped\"`, so we derive failed from that terminal pair or recorded publish errors.\n const now = Math.round(Date.now() / 1000);\n const expiryTime = now - 60 * 20;\n\n const states: string[] = [];\n for (const accountComment of accountComments) {\n let state = \"succeeded\";\n if (!accountComment.cid) {\n const ac = accountComment as AccountComment & {\n error?: Error;\n errors?: Error[];\n publishingState?: string;\n state?: string;\n };\n const resolvedPublishFailed =\n (ac.publishingState === \"failed\" && ac.state === \"stopped\") ||\n ac.error != null ||\n (Array.isArray(ac.errors) && ac.errors.length > 0);\n\n if (resolvedPublishFailed) {\n state = \"failed\";\n } else if (accountComment.timestamp > expiryTime) {\n state = \"pending\";\n } else {\n state = \"failed\";\n }\n }\n states.push(state);\n }\n\n return states;\n};\n\nexport const haveAccountCommentStatesChanged = (nextStates: string[], previousStates: string[]) =>\n nextStates.toString() !== previousStates.toString();\n\nconst getAccountHistorySortType = (\n sortType?: \"new\" | \"old\",\n order?: \"asc\" | \"desc\",\n): \"new\" | \"old\" => {\n if (sortType === \"new\" || sortType === \"old\") {\n return sortType;\n }\n return order === \"desc\" ? \"new\" : \"old\";\n};\n\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 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 ...comment,\n state: states[i],\n }));\n }, [filteredAccountComments, accountCommentStates]);\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 accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const normalizedCommentIndex = commentIndex === undefined ? undefined : Number(commentIndex);\n const resolvedCommentIndex =\n typeof normalizedCommentIndex === \"number\" && !Number.isNaN(normalizedCommentIndex)\n ? normalizedCommentIndex\n : 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 accountComment = (storedAccountComment || {}) as Partial<AccountComment> & {\n error?: Error;\n errors?: Error[];\n };\n const state = storedAccountComment\n ? getAccountCommentsStates([storedAccountComment])[0]\n : \"initializing\";\n\n return useMemo(\n () =>\n ({\n ...accountComment,\n state,\n error: accountComment.error,\n errors: accountComment.errors || [],\n }) as UseAccountCommentResult,\n [accountComment, state],\n );\n}\n\n/**\n * Returns the own user's votes stored locally, even those not yet published by the community owner.\n * Check UseAccountCommentsOptions type in types.tsx to filter them, e.g. filter = {communityAddresses: ['memes.eth']}.\n */\nexport function useAccountVotes(options?: UseAccountVotesOptions): UseAccountVotesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVotes options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const {\n accountName,\n filter,\n vote,\n commentCid,\n communityAddress,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountVotes options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountId || \"\"]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountVotesArray = useMemo(() => {\n let accountVotesArray: AccountVote[] = [];\n if (!accountVotes) {\n return accountVotesArray;\n }\n for (const i in accountVotes) {\n accountVotesArray.push(accountVotes[i]);\n }\n if (typeof vote === \"number\") {\n accountVotesArray = accountVotesArray.filter((accountVote) => accountVote.vote === vote);\n }\n if (commentCid) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.commentCid === commentCid,\n );\n }\n if (communityAddress) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.communityAddress === communityAddress,\n );\n }\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n accountVotesArray = accountVotesArray.filter(filter);\n }\n accountVotesArray = [...accountVotesArray].sort(\n (firstVote, secondVote) => (firstVote.timestamp || 0) - (secondVote.timestamp || 0),\n );\n if (accountHistorySortType === \"new\") {\n accountVotesArray = [...accountVotesArray].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n accountVotesArray = accountVotesArray.slice(startIndex, startIndex + pageSize);\n }\n return accountVotesArray;\n }, [\n accountVotes,\n accountHistorySortType,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n page,\n pageSize,\n vote,\n ]);\n\n if (accountVotes && options) {\n log(\"useAccountVotes\", {\n accountId,\n filteredAccountVotesArray,\n accountVotes,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n vote,\n });\n }\n\n // TODO: add failed / pending states\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountVotes: filteredAccountVotesArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountVotesArray, state],\n );\n}\n\n/**\n * Returns an account's single vote on a comment, e.g. to know if you already voted on a comment.\n */\nexport function useAccountVote(options?: UseAccountVoteOptions): UseAccountVoteResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVote options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = commentCid || \"\";\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountIdKey]);\n const accountVote: any = accountVotes?.[commentCidKey];\n const state = accountId && commentCid ? \"succeeded\" : \"initializing\";\n\n // TODO: add failed / pending state\n\n return useMemo(\n () => ({\n ...accountVote,\n state,\n error: undefined,\n errors: [],\n }),\n [accountVote, state],\n );\n}\n\n/**\n * Returns all the comment and community edits published by an account.\n */\nexport function useAccountEdits(options?: UseAccountEditsOptions): UseAccountEditsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountEdits options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { filter, accountName } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountEdits options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const ensureAccountEditsLoaded = useAccountsStore(\n (state) => state.accountsActionsInternal.ensureAccountEditsLoaded,\n );\n const accountEdits = useAccountsStore((state) => state.accountsEdits[accountId || \"\"]);\n const accountEditsLoaded = useAccountsStore(\n (state) => state.accountsEditsLoaded[accountId || \"\"],\n );\n\n useEffect(() => {\n if (!accountId || accountEditsLoaded) {\n return;\n }\n ensureAccountEditsLoaded(accountId).catch((error: unknown) =>\n log.error(\"useAccountEdits ensureAccountEditsLoaded error\", { accountId, error }),\n );\n }, [accountEditsLoaded, accountId, ensureAccountEditsLoaded]);\n\n const accountEditsArray = useMemo(() => {\n const accountEditsArray = [];\n for (const i in accountEdits || {}) {\n accountEditsArray.push(...accountEdits[i]);\n }\n // sort by oldest first\n return accountEditsArray.sort((a, b) => a.timestamp - b.timestamp);\n }, [accountEdits]);\n\n const filteredAccountEditsArray = useMemo(() => {\n if (!filter) {\n return accountEditsArray;\n }\n return accountEditsArray.filter(filter);\n }, [accountEditsArray, filter]);\n\n // TODO: add failed / pending states\n\n const state = accountId ? (accountEditsLoaded ? \"succeeded\" : \"initializing\") : \"initializing\";\n\n return useMemo(\n () => ({\n accountEdits: filteredAccountEditsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountEditsArray, state],\n );\n}\n\n/**\n * Returns the comment edited (if has any edits), as well as the pending, succeeded or failed state of the edit.\n */\nexport function useEditedComment(options?: UseEditedCommentOptions): UseEditedCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useEditedComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { comment, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = (comment && comment.cid) || \"\";\n const commentEdits = useAccountsStore(\n (state) => state.accountsEdits[accountIdKey]?.[commentCidKey],\n );\n const commentEditSummary = useAccountsStore(\n (state) => state.accountsEditsSummaries[accountIdKey]?.[commentCidKey],\n );\n\n let initialState = \"initializing\";\n if (accountId && comment && comment.cid) {\n initialState = \"unedited\";\n }\n\n const editedResult = useMemo(() => {\n const editedResult: any = {\n editedComment: undefined,\n succeededEdits: {},\n pendingEdits: {},\n failedEdits: {},\n state: undefined,\n };\n\n // there are no edits\n const propertyNameEdits: any =\n commentEdits?.length > 0 ? getAccountEditPropertySummary(commentEdits) : commentEditSummary;\n\n if (!propertyNameEdits || Object.keys(propertyNameEdits).length === 0) {\n return editedResult;\n }\n\n const now = Math.round(Date.now() / 1000);\n // no longer consider an edit pending ater an expiry time of 20 minutes\n const expiryTime = 60 * 20;\n\n // iterate over propertyNameEdits and find if succeeded, pending or failed\n for (const propertyName in propertyNameEdits) {\n const propertyNameEdit = propertyNameEdits[propertyName];\n\n const setPropertyNameEditState = (state: \"succeeded\" | \"pending\" | \"failed\") => {\n // set propertyNameEdit e.g. editedResult.succeededEdits.removed = true\n editedResult[`${state}Edits`][propertyName] = propertyNameEdit.value;\n\n // if any propertyNameEdit failed, consider the commentEdit failed\n if (state === \"failed\") {\n editedResult.state = \"failed\";\n }\n // if all propertyNameEdit succeeded, consider the commentEdit succeeded\n if (state === \"succeeded\" && !editedResult.state) {\n editedResult.state = \"succeeded\";\n }\n // if any propertyNameEdit are pending, and none have failed, consider the commentEdit pending\n if (state === \"pending\" && editedResult.state !== \"failed\") {\n editedResult.state = \"pending\";\n }\n };\n\n // Without a newer update we can only treat recent edits as pending. Older edits that never\n // produced any update are effectively stale and should stop shadowing the live comment.\n if (!comment?.updatedAt) {\n if (isEqual(comment?.[propertyName], propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n } else if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n } else {\n setPropertyNameEditState(\"failed\");\n }\n continue;\n }\n\n // comment.updatedAt is older than propertyNameEdit, propertyNameEdit is pending\n // because we haven't received the update yet and can't evaluate\n if (comment.updatedAt < propertyNameEdit.timestamp) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment.updatedAt is newer than propertyNameEdit, a comment update\n // has been received after the edit was published so we can evaluate\n else {\n // comment has propertyNameEdit, propertyNameEdit succeeded\n if (isEqual(comment[propertyName], propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n continue;\n }\n\n // comment does not have propertyNameEdit\n else {\n // propertyNameEdit is newer than 20min, it is too recent to evaluate\n // so we should assume pending\n if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // propertyNameEdit is older than 20min, we can evaluate it\n else {\n // comment update was received too shortly after propertyNameEdit was\n // published, assume pending until a more recent comment update is received\n const timeSinceUpdate = comment.updatedAt - propertyNameEdit.timestamp;\n if (timeSinceUpdate < expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment update time is sufficiently distanced from propertyNameEdit\n // and comment doesn't have propertyNameEdit, assume failed\n else {\n setPropertyNameEditState(\"failed\");\n continue;\n }\n }\n }\n }\n }\n\n // define editedComment\n editedResult.editedComment = { ...comment };\n // add pending and succeeded props so the editor can see his changes right away\n // don't add failed edits to reflect the current state of the edited comment\n for (const propertyName in editedResult.pendingEdits) {\n editedResult.editedComment[propertyName] = editedResult.pendingEdits[propertyName];\n }\n for (const propertyName in editedResult.succeededEdits) {\n editedResult.editedComment[propertyName] = editedResult.succeededEdits[propertyName];\n }\n editedResult.editedComment = addCommentModeration(editedResult.editedComment);\n\n return editedResult;\n }, [comment, commentEditSummary, commentEdits]);\n\n return useMemo(\n () => ({\n ...editedResult,\n state: editedResult.state || initialState,\n error: undefined,\n errors: [],\n }),\n [editedResult, initialState],\n );\n}\n\n/**\n * This hook should be added to pages where the user is likely to publish something, i,e. the\n * submit page and the /c/<commentCid> page, it improves the speed of publishing to the pubsub\n * by subscribing to the pubsub right away.\n *\n * @param accountName - The nickname of the account, e.g. 'Account 1'.\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 );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AC,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 \"lodash.isequal\";\nimport useAccountsStore from \"../../stores/accounts\";\nimport useCommunitiesStore from \"../../stores/communities\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:hooks\");\nimport assert from \"assert\";\nimport { useListCommunities, useCommunities } from \"../communities\";\nimport type {\n AccountComment,\n AccountComments,\n Account,\n Accounts,\n AccountVote,\n AccountsComments,\n AccountsCommentsReplies,\n UseAccountCommunitiesOptions,\n UseAccountCommunitiesResult,\n UseAccountVoteOptions,\n UseAccountVoteResult,\n UseAccountVotesOptions,\n UseAccountVotesResult,\n UseAccountCommentsOptions,\n UseAccountCommentsResult,\n UseAccountCommentOptions,\n UseAccountCommentResult,\n UseNotificationsOptions,\n UseNotificationsResult,\n UseAccountEditsOptions,\n UseAccountEditsResult,\n UseEditedCommentOptions,\n UseEditedCommentResult,\n UseAccountOptions,\n UseAccountResult,\n UsePubsubSubscribeOptions,\n UsePubsubSubscribeResult,\n} from \"../../types\";\nimport {\n useAccountsWithCalculatedProperties,\n useAccountWithCalculatedProperties,\n useCalculatedNotifications,\n} from \"./utils\";\nimport {\n COMMENT_MODERATION_AUTHOR_SUMMARY_KEY,\n getAccountEditPropertySummary,\n} from \"../../stores/accounts/utils\";\nimport {\n getCanonicalCommunityAddress,\n getEquivalentCommunityAddressGroupKey,\n pickPreferredEquivalentCommunityAddress,\n} from \"../../lib/community-address\";\nimport { addCommentModeration } from \"../../lib/utils/comment-moderation\";\nimport useInterval from \"../utils/use-interval\";\n\nconst getCommentEditPropertyValue = (comment: any, propertyName: string) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n return comment?.[propertyName];\n }\n\n const commentModeration = comment?.commentModeration;\n if (\n commentModeration &&\n typeof commentModeration === \"object\" &&\n Object.prototype.hasOwnProperty.call(commentModeration, \"author\")\n ) {\n return commentModeration.author;\n }\n\n return comment?.author?.community?.banExpiresAt !== undefined\n ? { banExpiresAt: comment.author.community.banExpiresAt }\n : undefined;\n};\n\nconst applyEditedCommentProperty = (comment: any, propertyName: string, value: any) => {\n if (propertyName !== COMMENT_MODERATION_AUTHOR_SUMMARY_KEY) {\n comment[propertyName] = value;\n return;\n }\n\n comment.commentModeration = comment.commentModeration ? { ...comment.commentModeration } : {};\n if (value === undefined) {\n delete comment.commentModeration.author;\n } else {\n comment.commentModeration.author = value;\n }\n\n comment.author = comment.author ? { ...comment.author } : {};\n comment.author.community = comment.author.community ? { ...comment.author.community } : {};\n if (value?.banExpiresAt === undefined) {\n delete comment.author.community.banExpiresAt;\n } else {\n comment.author.community.banExpiresAt = value.banExpiresAt;\n }\n};\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account 1'. 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 1'. 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 1'. If no accountName is provided, return\n * the active account's notifications.\n */\nexport function useNotifications(options?: UseNotificationsOptions): UseNotificationsResult {\n assert(\n !options || typeof options === \"object\",\n `useNotifications options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const accountsActionsInternal = useAccountsStore((state) => state.accountsActionsInternal);\n const notifications = useCalculatedNotifications(account, accountCommentsReplies);\n const [errors, setErrors] = useState<Error[]>([]);\n\n const markAsRead = async () => {\n try {\n if (!account) {\n throw Error(\"useNotifications cannot mark as read accounts not initalized yet\");\n }\n accountsActionsInternal.markNotificationsAsRead(account);\n } catch (e: any) {\n setErrors([...errors, e]);\n }\n };\n\n if (account) {\n log(\"useNotifications\", { notifications });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n notifications,\n markAsRead,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [notifications, errors],\n );\n}\n\nconst getAccountCommentsStates = (accountComments: AccountComment[]) => {\n // Without a cid, the account comment is still a local pending publish. pkc-js marks\n // terminal publish failures when `publishingState === \"failed\"` and publication `state`\n // is `\"stopped\"`, so we derive failed from that terminal pair or recorded publish errors.\n const now = Math.round(Date.now() / 1000);\n const expiryTime = now - 60 * 20;\n\n const states: string[] = [];\n for (const accountComment of accountComments) {\n let state = \"succeeded\";\n if (!accountComment.cid) {\n const ac = accountComment as AccountComment & {\n error?: Error;\n errors?: Error[];\n publishingState?: string;\n state?: string;\n };\n const resolvedPublishFailed =\n (ac.publishingState === \"failed\" && ac.state === \"stopped\") ||\n ac.error != null ||\n (Array.isArray(ac.errors) && ac.errors.length > 0);\n\n if (resolvedPublishFailed) {\n state = \"failed\";\n } else if (accountComment.timestamp > expiryTime) {\n state = \"pending\";\n } else {\n state = \"failed\";\n }\n }\n states.push(state);\n }\n\n return states;\n};\n\nexport const haveAccountCommentStatesChanged = (nextStates: string[], previousStates: string[]) =>\n nextStates.toString() !== previousStates.toString();\n\nconst getAccountHistorySortType = (\n sortType?: \"new\" | \"old\",\n order?: \"asc\" | \"desc\",\n): \"new\" | \"old\" => {\n if (sortType === \"new\" || sortType === \"old\") {\n return sortType;\n }\n return order === \"desc\" ? \"new\" : \"old\";\n};\n\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 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 ...comment,\n state: states[i],\n }));\n }, [filteredAccountComments, accountCommentStates]);\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 accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const normalizedCommentIndex = commentIndex === undefined ? undefined : Number(commentIndex);\n const resolvedCommentIndex =\n typeof normalizedCommentIndex === \"number\" && !Number.isNaN(normalizedCommentIndex)\n ? normalizedCommentIndex\n : 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 accountComment = (storedAccountComment || {}) as Partial<AccountComment> & {\n error?: Error;\n errors?: Error[];\n };\n const state = storedAccountComment\n ? getAccountCommentsStates([storedAccountComment])[0]\n : \"initializing\";\n\n return useMemo(\n () =>\n ({\n ...accountComment,\n state,\n error: accountComment.error,\n errors: accountComment.errors || [],\n }) as UseAccountCommentResult,\n [accountComment, state],\n );\n}\n\n/**\n * Returns the own user's votes stored locally, even those not yet published by the community owner.\n * Check UseAccountCommentsOptions type in types.tsx to filter them, e.g. filter = {communityAddresses: ['memes.eth']}.\n */\nexport function useAccountVotes(options?: UseAccountVotesOptions): UseAccountVotesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVotes options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const {\n accountName,\n filter,\n vote,\n commentCid,\n communityAddress,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountVotes options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountId || \"\"]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountVotesArray = useMemo(() => {\n let accountVotesArray: AccountVote[] = [];\n if (!accountVotes) {\n return accountVotesArray;\n }\n for (const i in accountVotes) {\n accountVotesArray.push(accountVotes[i]);\n }\n if (typeof vote === \"number\") {\n accountVotesArray = accountVotesArray.filter((accountVote) => accountVote.vote === vote);\n }\n if (commentCid) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.commentCid === commentCid,\n );\n }\n if (communityAddress) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.communityAddress === communityAddress,\n );\n }\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n accountVotesArray = accountVotesArray.filter(filter);\n }\n accountVotesArray = [...accountVotesArray].sort(\n (firstVote, secondVote) => (firstVote.timestamp || 0) - (secondVote.timestamp || 0),\n );\n if (accountHistorySortType === \"new\") {\n accountVotesArray = [...accountVotesArray].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n accountVotesArray = accountVotesArray.slice(startIndex, startIndex + pageSize);\n }\n return accountVotesArray;\n }, [\n accountVotes,\n accountHistorySortType,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n page,\n pageSize,\n vote,\n ]);\n\n if (accountVotes && options) {\n log(\"useAccountVotes\", {\n accountId,\n filteredAccountVotesArray,\n accountVotes,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n vote,\n });\n }\n\n // TODO: add failed / pending states\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountVotes: filteredAccountVotesArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountVotesArray, state],\n );\n}\n\n/**\n * Returns an account's single vote on a comment, e.g. to know if you already voted on a comment.\n */\nexport function useAccountVote(options?: UseAccountVoteOptions): UseAccountVoteResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVote options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = commentCid || \"\";\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountIdKey]);\n const accountVote: any = accountVotes?.[commentCidKey];\n const state = accountId && commentCid ? \"succeeded\" : \"initializing\";\n\n // TODO: add failed / pending state\n\n return useMemo(\n () => ({\n ...accountVote,\n state,\n error: undefined,\n errors: [],\n }),\n [accountVote, state],\n );\n}\n\n/**\n * Returns all the comment and community edits published by an account.\n */\nexport function useAccountEdits(options?: UseAccountEditsOptions): UseAccountEditsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountEdits options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { filter, accountName } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountEdits options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const ensureAccountEditsLoaded = useAccountsStore(\n (state) => state.accountsActionsInternal.ensureAccountEditsLoaded,\n );\n const accountEdits = useAccountsStore((state) => state.accountsEdits[accountId || \"\"]);\n const accountEditsLoaded = useAccountsStore(\n (state) => state.accountsEditsLoaded[accountId || \"\"],\n );\n\n useEffect(() => {\n if (!accountId || accountEditsLoaded) {\n return;\n }\n ensureAccountEditsLoaded(accountId).catch((error: unknown) =>\n log.error(\"useAccountEdits ensureAccountEditsLoaded error\", { accountId, error }),\n );\n }, [accountEditsLoaded, accountId, ensureAccountEditsLoaded]);\n\n const accountEditsArray = useMemo(() => {\n const accountEditsArray = [];\n for (const i in accountEdits || {}) {\n accountEditsArray.push(...accountEdits[i]);\n }\n // sort by oldest first\n return accountEditsArray.sort((a, b) => a.timestamp - b.timestamp);\n }, [accountEdits]);\n\n const filteredAccountEditsArray = useMemo(() => {\n if (!filter) {\n return accountEditsArray;\n }\n return accountEditsArray.filter(filter);\n }, [accountEditsArray, filter]);\n\n // TODO: add failed / pending states\n\n const state = accountId ? (accountEditsLoaded ? \"succeeded\" : \"initializing\") : \"initializing\";\n\n return useMemo(\n () => ({\n accountEdits: filteredAccountEditsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountEditsArray, state],\n );\n}\n\n/**\n * Returns the comment edited (if has any edits), as well as the pending, succeeded or failed state of the edit.\n */\nexport function useEditedComment(options?: UseEditedCommentOptions): UseEditedCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useEditedComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { comment, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = (comment && comment.cid) || \"\";\n const commentEdits = useAccountsStore(\n (state) => state.accountsEdits[accountIdKey]?.[commentCidKey],\n );\n const commentEditSummary = useAccountsStore(\n (state) => state.accountsEditsSummaries[accountIdKey]?.[commentCidKey],\n );\n\n let initialState = \"initializing\";\n if (accountId && comment && comment.cid) {\n initialState = \"unedited\";\n }\n\n const editedResult = useMemo(() => {\n const editedResult: any = {\n editedComment: undefined,\n succeededEdits: {},\n pendingEdits: {},\n failedEdits: {},\n state: undefined,\n };\n\n // there are no edits\n const propertyNameEdits: any =\n commentEdits?.length > 0 ? getAccountEditPropertySummary(commentEdits) : commentEditSummary;\n\n if (!propertyNameEdits || Object.keys(propertyNameEdits).length === 0) {\n return editedResult;\n }\n\n const now = Math.round(Date.now() / 1000);\n // no longer consider an edit pending ater an expiry time of 20 minutes\n const expiryTime = 60 * 20;\n\n // iterate over propertyNameEdits and find if succeeded, pending or failed\n for (const propertyName in propertyNameEdits) {\n const propertyNameEdit = propertyNameEdits[propertyName];\n\n const setPropertyNameEditState = (state: \"succeeded\" | \"pending\" | \"failed\") => {\n // set propertyNameEdit e.g. editedResult.succeededEdits.removed = true\n editedResult[`${state}Edits`][propertyName] = propertyNameEdit.value;\n\n // if any propertyNameEdit failed, consider the commentEdit failed\n if (state === \"failed\") {\n editedResult.state = \"failed\";\n }\n // if all propertyNameEdit succeeded, consider the commentEdit succeeded\n if (state === \"succeeded\" && !editedResult.state) {\n editedResult.state = \"succeeded\";\n }\n // if any propertyNameEdit are pending, and none have failed, consider the commentEdit pending\n if (state === \"pending\" && editedResult.state !== \"failed\") {\n editedResult.state = \"pending\";\n }\n };\n\n // Without a newer update we can only treat recent edits as pending. Older edits that never\n // produced any update are effectively stale and should stop shadowing the live comment.\n if (!comment?.updatedAt) {\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n } else if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n } else {\n setPropertyNameEditState(\"failed\");\n }\n continue;\n }\n\n // comment.updatedAt is older than propertyNameEdit, propertyNameEdit is pending\n // because we haven't received the update yet and can't evaluate\n if (comment.updatedAt < propertyNameEdit.timestamp) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment.updatedAt is newer than propertyNameEdit, a comment update\n // has been received after the edit was published so we can evaluate\n else {\n // comment has propertyNameEdit, propertyNameEdit succeeded\n if (isEqual(getCommentEditPropertyValue(comment, propertyName), propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n continue;\n }\n\n // comment does not have propertyNameEdit\n else {\n // propertyNameEdit is newer than 20min, it is too recent to evaluate\n // so we should assume pending\n if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // propertyNameEdit is older than 20min, we can evaluate it\n else {\n // comment update was received too shortly after propertyNameEdit was\n // published, assume pending until a more recent comment update is received\n const timeSinceUpdate = comment.updatedAt - propertyNameEdit.timestamp;\n if (timeSinceUpdate < expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment update time is sufficiently distanced from propertyNameEdit\n // and comment doesn't have propertyNameEdit, assume failed\n else {\n setPropertyNameEditState(\"failed\");\n continue;\n }\n }\n }\n }\n }\n\n // define editedComment\n editedResult.editedComment = { ...comment };\n // add pending and succeeded props so the editor can see his changes right away\n // don't add failed edits to reflect the current state of the edited comment\n for (const propertyName in editedResult.pendingEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.pendingEdits[propertyName],\n );\n }\n for (const propertyName in editedResult.succeededEdits) {\n applyEditedCommentProperty(\n editedResult.editedComment,\n propertyName,\n editedResult.succeededEdits[propertyName],\n );\n }\n editedResult.editedComment = addCommentModeration(editedResult.editedComment);\n\n return editedResult;\n }, [comment, commentEditSummary, commentEdits]);\n\n return useMemo(\n () => ({\n ...editedResult,\n state: editedResult.state || initialState,\n error: undefined,\n errors: [],\n }),\n [editedResult, initialState],\n );\n}\n\n/**\n * This hook should be added to pages where the user is likely to publish something, i,e. the\n * submit page and the /c/<commentCid> page, it improves the speed of publishing to the pubsub\n * by subscribing to the pubsub right away.\n *\n * @param accountName - The nickname of the account, e.g. 'Account 1'.\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"]}
|