@bitsocial/bitsocial-react-hooks 0.1.53 → 0.1.55
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 +23 -0
- package/dist/hooks/accounts/accounts.js +2 -2
- package/dist/hooks/accounts/accounts.js.map +1 -1
- package/dist/hooks/accounts/utils.d.ts.map +1 -1
- package/dist/hooks/accounts/utils.js +3 -12
- package/dist/hooks/accounts/utils.js.map +1 -1
- package/dist/hooks/actions/actions.js +1 -1
- package/dist/hooks/actions/actions.js.map +1 -1
- package/dist/hooks/authors/author-avatars.js +1 -1
- package/dist/hooks/authors/author-avatars.js.map +1 -1
- package/dist/hooks/authors/authors.js +1 -1
- package/dist/hooks/authors/authors.js.map +1 -1
- package/dist/hooks/authors/utils.d.ts.map +1 -1
- package/dist/hooks/authors/utils.js +1 -13
- package/dist/hooks/authors/utils.js.map +1 -1
- package/dist/hooks/comments.d.ts +7 -1
- package/dist/hooks/comments.d.ts.map +1 -1
- package/dist/hooks/comments.js +31 -1
- package/dist/hooks/comments.js.map +1 -1
- package/dist/hooks/communities.js +1 -1
- package/dist/hooks/communities.js.map +1 -1
- package/dist/hooks/feeds/feeds.js +1 -1
- package/dist/hooks/feeds/feeds.js.map +1 -1
- package/dist/hooks/pkc-rpc.js +1 -1
- package/dist/hooks/pkc-rpc.js.map +1 -1
- package/dist/hooks/replies.js +1 -1
- package/dist/hooks/replies.js.map +1 -1
- package/dist/hooks/states.js +1 -1
- package/dist/hooks/states.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/assert.d.ts +6 -0
- package/dist/lib/assert.d.ts.map +1 -0
- package/dist/lib/assert.js +17 -0
- package/dist/lib/assert.js.map +1 -0
- package/dist/lib/chain/chain.js +1 -1
- package/dist/lib/chain/chain.js.map +1 -1
- package/dist/lib/community-ref.js +1 -1
- package/dist/lib/community-ref.js.map +1 -1
- package/dist/lib/crosspost.js +1 -1
- package/dist/lib/crosspost.js.map +1 -1
- package/dist/lib/is-equal.d.ts +6 -0
- package/dist/lib/is-equal.d.ts.map +1 -0
- package/dist/lib/is-equal.js +100 -0
- package/dist/lib/is-equal.js.map +1 -0
- package/dist/lib/memoize.d.ts +9 -0
- package/dist/lib/memoize.d.ts.map +1 -0
- package/dist/lib/memoize.js +24 -0
- package/dist/lib/memoize.js.map +1 -0
- package/dist/lib/pkc-address.d.ts +2 -0
- package/dist/lib/pkc-address.d.ts.map +1 -0
- package/dist/lib/pkc-address.js +16 -0
- package/dist/lib/pkc-address.js.map +1 -0
- package/dist/lib/pkc-compat.js +1 -1
- package/dist/lib/pkc-compat.js.map +1 -1
- package/dist/lib/pkc-js/index.d.ts.map +1 -1
- package/dist/lib/pkc-js/index.js +23 -12
- package/dist/lib/pkc-js/index.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/protocol-compat.js +1 -1
- package/dist/lib/protocol-compat.js.map +1 -1
- package/dist/lib/utils/utils.js +1 -1
- package/dist/lib/utils/utils.js.map +1 -1
- package/dist/lib/validate-comment.d.ts +11 -0
- package/dist/lib/validate-comment.d.ts.map +1 -0
- package/dist/lib/validate-comment.js +133 -0
- package/dist/lib/validate-comment.js.map +1 -0
- package/dist/lib/validator.js +1 -1
- package/dist/lib/validator.js.map +1 -1
- package/dist/stores/accounts/accounts-actions-internal.js +2 -2
- package/dist/stores/accounts/accounts-actions-internal.js.map +1 -1
- package/dist/stores/accounts/accounts-actions.js +2 -2
- package/dist/stores/accounts/accounts-actions.js.map +1 -1
- package/dist/stores/accounts/accounts-database.js +2 -2
- package/dist/stores/accounts/accounts-database.js.map +1 -1
- package/dist/stores/accounts/accounts-store.js +1 -1
- package/dist/stores/accounts/accounts-store.js.map +1 -1
- package/dist/stores/accounts/utils.js +1 -1
- package/dist/stores/accounts/utils.js.map +1 -1
- package/dist/stores/authors-comments/authors-comments-store.js +1 -1
- package/dist/stores/authors-comments/authors-comments-store.js.map +1 -1
- package/dist/stores/authors-comments/utils.js.map +1 -1
- package/dist/stores/communities/communities-store.d.ts.map +1 -1
- package/dist/stores/communities/communities-store.js +53 -11
- package/dist/stores/communities/communities-store.js.map +1 -1
- package/dist/stores/communities-pages/communities-pages-store.js +1 -1
- package/dist/stores/communities-pages/communities-pages-store.js.map +1 -1
- package/dist/stores/feeds/feeds-store.js +1 -1
- package/dist/stores/feeds/feeds-store.js.map +1 -1
- package/dist/stores/feeds/utils.js.map +1 -1
- package/dist/stores/replies/replies-store.js +1 -1
- package/dist/stores/replies/replies-store.js.map +1 -1
- package/dist/stores/replies/utils.js.map +1 -1
- package/dist/stores/replies-pages/replies-pages-store.js +1 -1
- package/dist/stores/replies-pages/replies-pages-store.js.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts-actions-internal.js","sourceRoot":"","sources":["../../../src/stores/accounts/accounts-actions-internal.ts"],"names":[],"mappings":"AAAA,4DAA4D;;;;;;;;;;AAE5D,OAAO,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAS5D,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EACL,mCAAmC,EACnC,0BAA0B,EAC1B,iCAAiC,EACjC,mCAAmC,GACpC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iCAAiC,EACjC,0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C,kCAAO,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,KAAE,IAAI,MACvE,CAAC;YACF,YAAY,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;YAClC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,MAAM,SAAS,IAAI,QAAQ,EAAE,CAAC;YACjC,MAAM,OAAO,qBAAQ,YAAY,CAAC,SAAS,CAAC,CAAE,CAAC;YAC/C,OAAO,CAAC,WAAW,qBAAQ,OAAO,CAAC,WAAW,CAAE,CAAC;YACjD,OAAO,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC9C,YAAY,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;YAClC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,GAAG,CAAC,uDAAuD,EAAE;YAC3D,SAAS;YACT,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;QACH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAA,CAAC","sourcesContent":["// internal accounts actions that are not called by the user\n\nimport accountsStore, { listeners } from \"./accounts-store\";\nimport accountsDatabase from \"./accounts-database\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nimport assert from \"assert\";\nimport isEqual from \"lodash.isequal\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\nimport {\n Account,\n AccountCommentReply,\n Comment,\n AccountsComments,\n AccountCommentsReplies,\n Community,\n} from \"../../types\";\nimport utils from \"../../lib/utils\";\nimport {\n backfillPublicationCommunityAddress,\n getCommentCommunityAddress,\n normalizePublicationOptionsForPkc,\n normalizePublicationOptionsForStore,\n} from \"../../lib/pkc-compat\";\nimport {\n addShortAddressesToAccountComment,\n getAccountsCommentsIndexes,\n sanitizeStoredAccountComment,\n} from \"./utils\";\n\nconst accountEditsLoadPromises = new Map<string, Promise<void>>();\n\nconst doesStoredAccountEditMatch = (storedAccountEdit: any, targetStoredAccountEdit: any) =>\n storedAccountEdit?.clientId && targetStoredAccountEdit?.clientId\n ? storedAccountEdit.clientId === targetStoredAccountEdit.clientId\n : isEqual(storedAccountEdit, targetStoredAccountEdit);\n\nconst mergeLoadedAccountEdits = (\n loadedAccountEdits: Record<string, any[]> | undefined,\n currentAccountEdits: Record<string, any[]> | undefined,\n) => {\n const mergedAccountEdits: Record<string, any[]> = { ...(loadedAccountEdits || {}) };\n const editTargets = new Set([\n ...Object.keys(loadedAccountEdits || {}),\n ...Object.keys(currentAccountEdits || {}),\n ]);\n\n for (const editTarget of editTargets) {\n const mergedTargetEdits = [...(loadedAccountEdits?.[editTarget] || [])];\n for (const currentAccountEdit of currentAccountEdits?.[editTarget] || []) {\n const alreadyLoaded = mergedTargetEdits.some((loadedAccountEdit) =>\n doesStoredAccountEditMatch(loadedAccountEdit, currentAccountEdit),\n );\n if (!alreadyLoaded) {\n mergedTargetEdits.push(currentAccountEdit);\n }\n }\n if (mergedTargetEdits.length > 0) {\n mergedAccountEdits[editTarget] = mergedTargetEdits.sort(\n (a, b) => (a?.timestamp || 0) - (b?.timestamp || 0),\n );\n }\n }\n\n return mergedAccountEdits;\n};\n\nconst backfillLiveCommentCommunityAddress = (\n comment: Comment | undefined,\n communityAddress: string | undefined,\n) => {\n if (!comment || comment.communityAddress || !communityAddress) {\n return;\n }\n\n try {\n Object.defineProperty(comment, \"communityAddress\", {\n value: communityAddress,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n } catch (error) {\n try {\n comment.communityAddress = communityAddress;\n } catch (assignmentError) {\n log.trace(\"backfillLiveCommentCommunityAddress failed\", {\n cid: comment.cid,\n error,\n assignmentError,\n });\n }\n }\n};\n\n// TODO: we currently subscribe to updates for every single comment\n// in the user's account history. This probably does not scale, we\n// need to eventually schedule and queue older comments to look\n// for updates at a lower priority.\nexport const startUpdatingAccountCommentOnCommentUpdateEvents = async (\n comment: Comment,\n account: Account,\n accountCommentIndex: number,\n) => {\n assert(\n typeof accountCommentIndex === \"number\",\n `startUpdatingAccountCommentOnCommentUpdateEvents accountCommentIndex '${accountCommentIndex}' not a number`,\n );\n assert(\n typeof account?.id === \"string\",\n `startUpdatingAccountCommentOnCommentUpdateEvents account '${account}' account.id '${account?.id}' not a string`,\n );\n const commentArgument = comment;\n\n // comment doesn't have a cid yet, so can't receive updates\n if (!comment.cid) {\n return;\n }\n\n // account comment already updating\n if (accountsStore.getState().accountsCommentsUpdating[comment.cid]) {\n return;\n }\n accountsStore.setState(({ accountsCommentsUpdating }) => ({\n accountsCommentsUpdating: { ...accountsCommentsUpdating, [comment.cid]: true },\n }));\n\n // comment is not a `Comment` instance\n if (!comment.on) {\n comment = backfillPublicationCommunityAddress(\n await account.pkc.createComment(normalizePublicationOptionsForPkc(account.pkc, comment)),\n comment,\n );\n }\n\n const initialStoredComment =\n accountsStore.getState().accountsComments[account.id]?.[accountCommentIndex];\n backfillLiveCommentCommunityAddress(\n comment,\n getCommentCommunityAddress(commentArgument) ||\n initialStoredComment?.communityAddress ||\n initialStoredComment?.communityAddress,\n );\n\n comment.on(\"update\", async (updatedComment: Comment) => {\n const mapping =\n accountsStore.getState().commentCidsToAccountsComments[updatedComment.cid || \"\"];\n if (!mapping || mapping.accountId !== account.id) {\n accountsStore.setState(({ accountsCommentsUpdating }) => {\n const next = { ...accountsCommentsUpdating };\n delete next[updatedComment.cid || \"\"];\n return { accountsCommentsUpdating: next };\n });\n try {\n if (typeof comment.removeAllListeners === \"function\") comment.removeAllListeners();\n if (typeof (comment as any).stop === \"function\") (comment as any).stop();\n } catch (e) {\n log.trace(\"startUpdatingAccountCommentOnCommentUpdateEvents stop/removeAllListeners\", {\n cid: updatedComment.cid,\n error: e,\n });\n }\n return;\n }\n const currentIndex = mapping.accountCommentIndex;\n\n // merge should not be needed if pkc-js is implemented properly, but no harm in fixing potential errors\n const storedComment = accountsStore.getState().accountsComments[account.id]?.[currentIndex];\n updatedComment = utils.merge(commentArgument, comment, updatedComment);\n updatedComment.communityAddress =\n getCommentCommunityAddress(updatedComment) ||\n getCommentCommunityAddress(comment) ||\n getCommentCommunityAddress(commentArgument) ||\n storedComment?.communityAddress ||\n storedComment?.communityAddress;\n const normalizedUpdatedComment = addShortAddressesToAccountComment(\n normalizePublicationOptionsForStore(updatedComment) as Comment,\n ) as Comment;\n const storedUpdatedComment = sanitizeStoredAccountComment(normalizedUpdatedComment) as Comment;\n await accountsDatabase.addAccountComment(account.id, storedUpdatedComment, currentIndex);\n log(\"startUpdatingAccountCommentOnCommentUpdateEvents comment update\", {\n commentCid: comment.cid,\n accountCommentIndex: currentIndex,\n updatedComment: storedUpdatedComment,\n account,\n });\n accountsStore.setState(({ accountsComments, accountsCommentsIndexes }) => {\n // account no longer exists\n if (!accountsComments[account.id]) {\n log.error(\n `startUpdatingAccountCommentOnCommentUpdateEvents comment.on('update') invalid accountsStore.accountsComments['${account.id}'] '${\n accountsComments[account.id]\n }', account may have been deleted`,\n );\n return {};\n }\n\n const updatedAccountComments = [...accountsComments[account.id]];\n const previousComment = updatedAccountComments[currentIndex];\n const updatedAccountComment = utils.clone({\n ...storedUpdatedComment,\n index: currentIndex,\n accountId: account.id,\n });\n updatedAccountComments[currentIndex] = updatedAccountComment;\n const nextAccountsComments = {\n ...accountsComments,\n [account.id]: updatedAccountComments,\n };\n return {\n accountsComments: nextAccountsComments,\n accountsCommentsIndexes: {\n ...accountsCommentsIndexes,\n [account.id]: getAccountsCommentsIndexes({\n [account.id]: updatedAccountComments,\n } as AccountsComments)[account.id],\n },\n };\n });\n\n // update AccountCommentsReplies with new replies if has any new replies\n const replyPageArray: any[] = Object.values(normalizedUpdatedComment.replies?.pages || {});\n const getReplyCount = (replyPage: any) => replyPage?.comments?.length ?? 0;\n const replyCount =\n replyPageArray.length > 0\n ? replyPageArray.map(getReplyCount).reduce((prev, curr) => prev + curr)\n : 0;\n const hasReplies = replyCount > 0;\n const repliesAreValid = await utils.repliesAreValid(\n normalizedUpdatedComment,\n { validateReplies: false, blockCommunity: true },\n account.pkc,\n );\n\n if (hasReplies && repliesAreValid) {\n accountsStore.setState(({ accountsCommentsReplies }) => {\n // account no longer exists\n if (!accountsCommentsReplies[account.id]) {\n log.error(\n `startUpdatingAccountCommentOnCommentUpdateEvents comment.on('update') invalid accountsStore.accountsCommentsReplies['${account.id}'] '${\n accountsCommentsReplies[account.id]\n }', account may have been deleted`,\n );\n return {};\n }\n\n // check which replies are read or not\n const updatedAccountCommentsReplies: { [replyCid: string]: AccountCommentReply } = {};\n for (const replyPage of replyPageArray) {\n for (const reply of replyPage?.comments || []) {\n const normalizedReply = normalizePublicationOptionsForStore(reply) as Comment;\n normalizedReply.communityAddress =\n getCommentCommunityAddress(normalizedReply) ||\n normalizedUpdatedComment.communityAddress ||\n storedUpdatedComment.communityAddress;\n const markedAsRead =\n accountsCommentsReplies[account.id]?.[reply.cid]?.markedAsRead === true\n ? true\n : false;\n updatedAccountCommentsReplies[normalizedReply.cid] = {\n ...normalizedReply,\n markedAsRead,\n };\n }\n }\n\n // add all to database\n const promises = [];\n for (const replyCid in updatedAccountCommentsReplies) {\n promises.push(\n accountsDatabase.addAccountCommentReply(\n account.id,\n updatedAccountCommentsReplies[replyCid],\n ),\n );\n }\n Promise.all(promises);\n\n // set new store\n const newAccountCommentsReplies = {\n ...accountsCommentsReplies[account.id],\n ...updatedAccountCommentsReplies,\n };\n return {\n accountsCommentsReplies: {\n ...accountsCommentsReplies,\n [account.id]: newAccountCommentsReplies,\n },\n };\n });\n }\n });\n listeners.push(comment);\n comment.update().catch((error: unknown) => log.trace(\"comment.update error\", { comment, error }));\n};\n\n// internal accounts action: the comment CID is not known at the time of publishing, so every time\n// we fetch a new comment, check if its our own, and attempt to add the CID\nexport const addCidToAccountComment = async (comment: Comment) => {\n const { accounts } = accountsStore.getState();\n assert(accounts, `can't use accountsStore.accountActions before initialized`);\n const accountCommentsWithoutCids = getAccountsCommentsWithoutCids()[comment?.author?.address];\n if (!accountCommentsWithoutCids) {\n return;\n }\n for (const accountComment of accountCommentsWithoutCids) {\n // if author address and timestamp is the same, we assume it's the right comment\n if (accountComment.timestamp && accountComment.timestamp === comment.timestamp) {\n const commentWithCid = utils.merge(accountComment, comment);\n await accountsDatabase.addAccountComment(\n accountComment.accountId,\n commentWithCid,\n accountComment.index,\n );\n log(\"accountsActions.addCidToAccountComment\", {\n commentCid: comment.cid,\n accountCommentIndex: accountComment.index,\n accountComment: commentWithCid,\n });\n accountsStore.setState(\n ({ accountsComments, accountsCommentsIndexes, commentCidsToAccountsComments }) => {\n const updatedAccountComments = [...accountsComments[accountComment.accountId]];\n updatedAccountComments[accountComment.index] = commentWithCid;\n const newAccountsComments = {\n ...accountsComments,\n [accountComment.accountId]: updatedAccountComments,\n };\n return {\n accountsComments: newAccountsComments,\n accountsCommentsIndexes: {\n ...accountsCommentsIndexes,\n [accountComment.accountId]: getAccountsCommentsIndexes({\n [accountComment.accountId]: updatedAccountComments,\n } as AccountsComments)[accountComment.accountId],\n },\n commentCidsToAccountsComments: {\n ...commentCidsToAccountsComments,\n [comment.cid]: {\n accountId: accountComment.accountId,\n accountCommentIndex: accountComment.index,\n },\n },\n };\n },\n );\n\n startUpdatingAccountCommentOnCommentUpdateEvents(\n comment,\n accounts[accountComment.accountId],\n accountComment.index,\n ).catch((error: unknown) =>\n log.error(\n \"accountsActions.addCidToAccountComment startUpdatingAccountCommentOnCommentUpdateEvents error\",\n {\n comment,\n account: accounts[accountComment.accountId],\n accountCommentIndex: accountComment.index,\n error,\n },\n ),\n );\n break;\n }\n }\n};\n\n// cache the last result of this function\nlet previousAccountsCommentsJson: string;\nlet previousAccountsCommentsWithoutCids: any = {};\nconst getAccountsCommentsWithoutCids = () => {\n const { accounts, accountsComments } = accountsStore.getState();\n\n // same accounts comments as last time, return cached value\n const accountsCommentsJson = JSON.stringify(accountsComments);\n if (accountsCommentsJson === previousAccountsCommentsJson) {\n return previousAccountsCommentsWithoutCids;\n }\n previousAccountsCommentsJson = accountsCommentsJson;\n\n const accountsCommentsWithoutCids: AccountsComments = {};\n if (!accounts || !accountsComments) {\n return accountsCommentsWithoutCids;\n }\n for (const accountId in accountsComments) {\n const accountComments = accountsComments[accountId];\n const account = accounts[accountId];\n for (const accountCommentIndex in accountComments) {\n const accountComment = accountComments[accountCommentIndex];\n if (!accountComment.cid) {\n const authorAddress = account?.author?.address;\n if (!authorAddress) {\n continue;\n }\n if (!accountsCommentsWithoutCids[authorAddress]) {\n accountsCommentsWithoutCids[authorAddress] = [];\n }\n accountsCommentsWithoutCids[authorAddress].push(accountComment);\n }\n }\n }\n previousAccountsCommentsWithoutCids = accountsCommentsWithoutCids;\n return accountsCommentsWithoutCids;\n};\n\nexport const ensureAccountEditsLoaded = async (accountId: string) => {\n assert(\n accountId && typeof accountId === \"string\",\n `ensureAccountEditsLoaded invalid '${accountId}'`,\n );\n\n if (accountsStore.getState().accountsEditsLoaded[accountId]) {\n return;\n }\n const existingPromise = accountEditsLoadPromises.get(accountId);\n if (existingPromise) {\n return existingPromise;\n }\n\n const loadPromise = accountsDatabase\n .getAccountEdits(accountId)\n .then((loadedAccountEdits) => {\n accountsStore.setState(({ accountsEdits, accountsEditsLoaded }) => ({\n accountsEdits: {\n ...accountsEdits,\n [accountId]: mergeLoadedAccountEdits(loadedAccountEdits, accountsEdits[accountId]),\n },\n accountsEditsLoaded: { ...accountsEditsLoaded, [accountId]: true },\n }));\n })\n .finally(() => {\n accountEditsLoadPromises.delete(accountId);\n });\n accountEditsLoadPromises.set(accountId, loadPromise);\n return loadPromise;\n};\n\nexport const resetLazyAccountHistoryLoaders = () => {\n accountEditsLoadPromises.clear();\n};\n\n// internal accounts action: mark an account's notifications as read\nexport const markNotificationsAsRead = async (account: Account) => {\n const { accountsCommentsReplies } = accountsStore.getState();\n assert(\n typeof account?.id === \"string\",\n `accountsStore.markNotificationsAsRead invalid account argument '${account}'`,\n );\n\n // find all unread replies\n const repliesToMarkAsRead: AccountCommentsReplies = {};\n for (const replyCid in accountsCommentsReplies[account.id]) {\n if (!accountsCommentsReplies[account.id][replyCid].markedAsRead) {\n repliesToMarkAsRead[replyCid] = {\n ...accountsCommentsReplies[account.id][replyCid],\n markedAsRead: true,\n };\n }\n }\n\n // add all to database\n const promises = [];\n for (const replyCid in repliesToMarkAsRead) {\n promises.push(\n accountsDatabase.addAccountCommentReply(account.id, repliesToMarkAsRead[replyCid]),\n );\n }\n await Promise.all(promises);\n\n // add all to react store\n log(\"accountsActions.markNotificationsAsRead\", { account, repliesToMarkAsRead });\n accountsStore.setState(({ accountsCommentsReplies }) => {\n const updatedAccountCommentsReplies = {\n ...accountsCommentsReplies[account.id],\n ...repliesToMarkAsRead,\n };\n return {\n accountsCommentsReplies: {\n ...accountsCommentsReplies,\n [account.id]: updatedAccountCommentsReplies,\n },\n };\n });\n};\n\n// internal accounts action: if a community has a role with an account's address\n// add it to the account.communities database\nexport const addCommunityRoleToAccountsCommunities = async (community: Community) => {\n if (!community) {\n return;\n }\n const { accounts } = accountsStore.getState();\n assert(accounts, `can't use accountsStore.accountActions before initialized`);\n\n // find community roles to add and remove\n const getRole = (community: any, authorAddress: string) =>\n community.roles && community.roles[authorAddress];\n const getChange = (accounts: any, community: any) => {\n const toUpsert: string[] = [];\n const toRemove: string[] = [];\n for (const accountId in accounts) {\n const account = accounts[accountId];\n const role = getRole(community, account.author.address);\n if (!role) {\n if (account.communities[community.address]) {\n toRemove.push(accountId);\n }\n } else {\n const currentRole = account.communities[community.address]?.role;\n if (!currentRole || currentRole.role !== role.role) {\n toUpsert.push(accountId);\n }\n }\n }\n return {\n toUpsert,\n toRemove,\n hasChange: toUpsert.length !== 0 || toRemove.length !== 0,\n };\n };\n\n const { hasChange } = getChange(accounts, community);\n if (!hasChange) {\n return;\n }\n\n accountsStore.setState(({ accounts }) => {\n const { toUpsert, toRemove } = getChange(accounts, community);\n const nextAccounts = { ...accounts };\n\n // edit databases and build next accounts (toUpsert implies role exists from getChange)\n for (const accountId of toUpsert) {\n const account = { ...nextAccounts[accountId] };\n const role = community.roles![account.author.address];\n account.communities = {\n ...account.communities,\n [community.address]: { ...account.communities[community.address], role },\n };\n nextAccounts[accountId] = account;\n accountsDatabase.addAccount(account);\n }\n for (const accountId of toRemove) {\n const account = { ...nextAccounts[accountId] };\n account.communities = { ...account.communities };\n delete account.communities[community.address];\n nextAccounts[accountId] = account;\n accountsDatabase.addAccount(account);\n }\n\n log(\"accountsActions.addCommunityRoleToAccountsCommunities\", {\n community,\n toUpsert,\n toRemove,\n });\n return { accounts: nextAccounts };\n });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"accounts-actions-internal.js","sourceRoot":"","sources":["../../../src/stores/accounts/accounts-actions-internal.ts"],"names":[],"mappings":"AAAA,4DAA4D;;;;;;;;;;AAE5D,OAAO,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAS5D,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EACL,mCAAmC,EACnC,0BAA0B,EAC1B,iCAAiC,EACjC,mCAAmC,GACpC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iCAAiC,EACjC,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,SAAS,CAAC;AAEjB,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAAyB,CAAC;AAElE,MAAM,0BAA0B,GAAG,CAAC,iBAAsB,EAAE,uBAA4B,EAAE,EAAE,CAC1F,CAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,QAAQ,MAAI,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAE,QAAQ,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CAAC;YAC/C,OAAO,CAAC,WAAW,qBAAQ,OAAO,CAAC,WAAW,CAAE,CAAC;YACjD,OAAO,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC9C,YAAY,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;YAClC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,GAAG,CAAC,uDAAuD,EAAE;YAC3D,SAAS;YACT,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;QACH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAA,CAAC","sourcesContent":["// internal accounts actions that are not called by the user\n\nimport accountsStore, { listeners } from \"./accounts-store\";\nimport accountsDatabase from \"./accounts-database\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nimport assert from \"../../lib/assert\";\nimport isEqual from \"../../lib/is-equal\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\nimport {\n Account,\n AccountCommentReply,\n Comment,\n AccountsComments,\n AccountCommentsReplies,\n Community,\n} from \"../../types\";\nimport utils from \"../../lib/utils\";\nimport {\n backfillPublicationCommunityAddress,\n getCommentCommunityAddress,\n normalizePublicationOptionsForPkc,\n normalizePublicationOptionsForStore,\n} from \"../../lib/pkc-compat\";\nimport {\n addShortAddressesToAccountComment,\n getAccountsCommentsIndexes,\n sanitizeStoredAccountComment,\n} from \"./utils\";\n\nconst accountEditsLoadPromises = new Map<string, Promise<void>>();\n\nconst doesStoredAccountEditMatch = (storedAccountEdit: any, targetStoredAccountEdit: any) =>\n storedAccountEdit?.clientId && targetStoredAccountEdit?.clientId\n ? storedAccountEdit.clientId === targetStoredAccountEdit.clientId\n : isEqual(storedAccountEdit, targetStoredAccountEdit);\n\nconst mergeLoadedAccountEdits = (\n loadedAccountEdits: Record<string, any[]> | undefined,\n currentAccountEdits: Record<string, any[]> | undefined,\n) => {\n const mergedAccountEdits: Record<string, any[]> = { ...(loadedAccountEdits || {}) };\n const editTargets = new Set([\n ...Object.keys(loadedAccountEdits || {}),\n ...Object.keys(currentAccountEdits || {}),\n ]);\n\n for (const editTarget of editTargets) {\n const mergedTargetEdits = [...(loadedAccountEdits?.[editTarget] || [])];\n for (const currentAccountEdit of currentAccountEdits?.[editTarget] || []) {\n const alreadyLoaded = mergedTargetEdits.some((loadedAccountEdit) =>\n doesStoredAccountEditMatch(loadedAccountEdit, currentAccountEdit),\n );\n if (!alreadyLoaded) {\n mergedTargetEdits.push(currentAccountEdit);\n }\n }\n if (mergedTargetEdits.length > 0) {\n mergedAccountEdits[editTarget] = mergedTargetEdits.sort(\n (a, b) => (a?.timestamp || 0) - (b?.timestamp || 0),\n );\n }\n }\n\n return mergedAccountEdits;\n};\n\nconst backfillLiveCommentCommunityAddress = (\n comment: Comment | undefined,\n communityAddress: string | undefined,\n) => {\n if (!comment || comment.communityAddress || !communityAddress) {\n return;\n }\n\n try {\n Object.defineProperty(comment, \"communityAddress\", {\n value: communityAddress,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n } catch (error) {\n try {\n comment.communityAddress = communityAddress;\n } catch (assignmentError) {\n log.trace(\"backfillLiveCommentCommunityAddress failed\", {\n cid: comment.cid,\n error,\n assignmentError,\n });\n }\n }\n};\n\n// TODO: we currently subscribe to updates for every single comment\n// in the user's account history. This probably does not scale, we\n// need to eventually schedule and queue older comments to look\n// for updates at a lower priority.\nexport const startUpdatingAccountCommentOnCommentUpdateEvents = async (\n comment: Comment,\n account: Account,\n accountCommentIndex: number,\n) => {\n assert(\n typeof accountCommentIndex === \"number\",\n `startUpdatingAccountCommentOnCommentUpdateEvents accountCommentIndex '${accountCommentIndex}' not a number`,\n );\n assert(\n typeof account?.id === \"string\",\n `startUpdatingAccountCommentOnCommentUpdateEvents account '${account}' account.id '${account?.id}' not a string`,\n );\n const commentArgument = comment;\n\n // comment doesn't have a cid yet, so can't receive updates\n if (!comment.cid) {\n return;\n }\n\n // account comment already updating\n if (accountsStore.getState().accountsCommentsUpdating[comment.cid]) {\n return;\n }\n accountsStore.setState(({ accountsCommentsUpdating }) => ({\n accountsCommentsUpdating: { ...accountsCommentsUpdating, [comment.cid]: true },\n }));\n\n // comment is not a `Comment` instance\n if (!comment.on) {\n comment = backfillPublicationCommunityAddress(\n await account.pkc.createComment(normalizePublicationOptionsForPkc(account.pkc, comment)),\n comment,\n );\n }\n\n const initialStoredComment =\n accountsStore.getState().accountsComments[account.id]?.[accountCommentIndex];\n backfillLiveCommentCommunityAddress(\n comment,\n getCommentCommunityAddress(commentArgument) ||\n initialStoredComment?.communityAddress ||\n initialStoredComment?.communityAddress,\n );\n\n comment.on(\"update\", async (updatedComment: Comment) => {\n const mapping =\n accountsStore.getState().commentCidsToAccountsComments[updatedComment.cid || \"\"];\n if (!mapping || mapping.accountId !== account.id) {\n accountsStore.setState(({ accountsCommentsUpdating }) => {\n const next = { ...accountsCommentsUpdating };\n delete next[updatedComment.cid || \"\"];\n return { accountsCommentsUpdating: next };\n });\n try {\n if (typeof comment.removeAllListeners === \"function\") comment.removeAllListeners();\n if (typeof (comment as any).stop === \"function\") (comment as any).stop();\n } catch (e) {\n log.trace(\"startUpdatingAccountCommentOnCommentUpdateEvents stop/removeAllListeners\", {\n cid: updatedComment.cid,\n error: e,\n });\n }\n return;\n }\n const currentIndex = mapping.accountCommentIndex;\n\n // merge should not be needed if pkc-js is implemented properly, but no harm in fixing potential errors\n const storedComment = accountsStore.getState().accountsComments[account.id]?.[currentIndex];\n updatedComment = utils.merge(commentArgument, comment, updatedComment);\n updatedComment.communityAddress =\n getCommentCommunityAddress(updatedComment) ||\n getCommentCommunityAddress(comment) ||\n getCommentCommunityAddress(commentArgument) ||\n storedComment?.communityAddress ||\n storedComment?.communityAddress;\n const normalizedUpdatedComment = addShortAddressesToAccountComment(\n normalizePublicationOptionsForStore(updatedComment) as Comment,\n ) as Comment;\n const storedUpdatedComment = sanitizeStoredAccountComment(normalizedUpdatedComment) as Comment;\n await accountsDatabase.addAccountComment(account.id, storedUpdatedComment, currentIndex);\n log(\"startUpdatingAccountCommentOnCommentUpdateEvents comment update\", {\n commentCid: comment.cid,\n accountCommentIndex: currentIndex,\n updatedComment: storedUpdatedComment,\n account,\n });\n accountsStore.setState(({ accountsComments, accountsCommentsIndexes }) => {\n // account no longer exists\n if (!accountsComments[account.id]) {\n log.error(\n `startUpdatingAccountCommentOnCommentUpdateEvents comment.on('update') invalid accountsStore.accountsComments['${account.id}'] '${\n accountsComments[account.id]\n }', account may have been deleted`,\n );\n return {};\n }\n\n const updatedAccountComments = [...accountsComments[account.id]];\n const previousComment = updatedAccountComments[currentIndex];\n const updatedAccountComment = utils.clone({\n ...storedUpdatedComment,\n index: currentIndex,\n accountId: account.id,\n });\n updatedAccountComments[currentIndex] = updatedAccountComment;\n const nextAccountsComments = {\n ...accountsComments,\n [account.id]: updatedAccountComments,\n };\n return {\n accountsComments: nextAccountsComments,\n accountsCommentsIndexes: {\n ...accountsCommentsIndexes,\n [account.id]: getAccountsCommentsIndexes({\n [account.id]: updatedAccountComments,\n } as AccountsComments)[account.id],\n },\n };\n });\n\n // update AccountCommentsReplies with new replies if has any new replies\n const replyPageArray: any[] = Object.values(normalizedUpdatedComment.replies?.pages || {});\n const getReplyCount = (replyPage: any) => replyPage?.comments?.length ?? 0;\n const replyCount =\n replyPageArray.length > 0\n ? replyPageArray.map(getReplyCount).reduce((prev, curr) => prev + curr)\n : 0;\n const hasReplies = replyCount > 0;\n const repliesAreValid = await utils.repliesAreValid(\n normalizedUpdatedComment,\n { validateReplies: false, blockCommunity: true },\n account.pkc,\n );\n\n if (hasReplies && repliesAreValid) {\n accountsStore.setState(({ accountsCommentsReplies }) => {\n // account no longer exists\n if (!accountsCommentsReplies[account.id]) {\n log.error(\n `startUpdatingAccountCommentOnCommentUpdateEvents comment.on('update') invalid accountsStore.accountsCommentsReplies['${account.id}'] '${\n accountsCommentsReplies[account.id]\n }', account may have been deleted`,\n );\n return {};\n }\n\n // check which replies are read or not\n const updatedAccountCommentsReplies: { [replyCid: string]: AccountCommentReply } = {};\n for (const replyPage of replyPageArray) {\n for (const reply of replyPage?.comments || []) {\n const normalizedReply = normalizePublicationOptionsForStore(reply) as Comment;\n normalizedReply.communityAddress =\n getCommentCommunityAddress(normalizedReply) ||\n normalizedUpdatedComment.communityAddress ||\n storedUpdatedComment.communityAddress;\n const markedAsRead =\n accountsCommentsReplies[account.id]?.[reply.cid]?.markedAsRead === true\n ? true\n : false;\n updatedAccountCommentsReplies[normalizedReply.cid] = {\n ...normalizedReply,\n markedAsRead,\n };\n }\n }\n\n // add all to database\n const promises = [];\n for (const replyCid in updatedAccountCommentsReplies) {\n promises.push(\n accountsDatabase.addAccountCommentReply(\n account.id,\n updatedAccountCommentsReplies[replyCid],\n ),\n );\n }\n Promise.all(promises);\n\n // set new store\n const newAccountCommentsReplies = {\n ...accountsCommentsReplies[account.id],\n ...updatedAccountCommentsReplies,\n };\n return {\n accountsCommentsReplies: {\n ...accountsCommentsReplies,\n [account.id]: newAccountCommentsReplies,\n },\n };\n });\n }\n });\n listeners.push(comment);\n comment.update().catch((error: unknown) => log.trace(\"comment.update error\", { comment, error }));\n};\n\n// internal accounts action: the comment CID is not known at the time of publishing, so every time\n// we fetch a new comment, check if its our own, and attempt to add the CID\nexport const addCidToAccountComment = async (comment: Comment) => {\n const { accounts } = accountsStore.getState();\n assert(accounts, `can't use accountsStore.accountActions before initialized`);\n const accountCommentsWithoutCids = getAccountsCommentsWithoutCids()[comment?.author?.address];\n if (!accountCommentsWithoutCids) {\n return;\n }\n for (const accountComment of accountCommentsWithoutCids) {\n // if author address and timestamp is the same, we assume it's the right comment\n if (accountComment.timestamp && accountComment.timestamp === comment.timestamp) {\n const commentWithCid = utils.merge(accountComment, comment);\n await accountsDatabase.addAccountComment(\n accountComment.accountId,\n commentWithCid,\n accountComment.index,\n );\n log(\"accountsActions.addCidToAccountComment\", {\n commentCid: comment.cid,\n accountCommentIndex: accountComment.index,\n accountComment: commentWithCid,\n });\n accountsStore.setState(\n ({ accountsComments, accountsCommentsIndexes, commentCidsToAccountsComments }) => {\n const updatedAccountComments = [...accountsComments[accountComment.accountId]];\n updatedAccountComments[accountComment.index] = commentWithCid;\n const newAccountsComments = {\n ...accountsComments,\n [accountComment.accountId]: updatedAccountComments,\n };\n return {\n accountsComments: newAccountsComments,\n accountsCommentsIndexes: {\n ...accountsCommentsIndexes,\n [accountComment.accountId]: getAccountsCommentsIndexes({\n [accountComment.accountId]: updatedAccountComments,\n } as AccountsComments)[accountComment.accountId],\n },\n commentCidsToAccountsComments: {\n ...commentCidsToAccountsComments,\n [comment.cid]: {\n accountId: accountComment.accountId,\n accountCommentIndex: accountComment.index,\n },\n },\n };\n },\n );\n\n startUpdatingAccountCommentOnCommentUpdateEvents(\n comment,\n accounts[accountComment.accountId],\n accountComment.index,\n ).catch((error: unknown) =>\n log.error(\n \"accountsActions.addCidToAccountComment startUpdatingAccountCommentOnCommentUpdateEvents error\",\n {\n comment,\n account: accounts[accountComment.accountId],\n accountCommentIndex: accountComment.index,\n error,\n },\n ),\n );\n break;\n }\n }\n};\n\n// cache the last result of this function\nlet previousAccountsCommentsJson: string;\nlet previousAccountsCommentsWithoutCids: any = {};\nconst getAccountsCommentsWithoutCids = () => {\n const { accounts, accountsComments } = accountsStore.getState();\n\n // same accounts comments as last time, return cached value\n const accountsCommentsJson = JSON.stringify(accountsComments);\n if (accountsCommentsJson === previousAccountsCommentsJson) {\n return previousAccountsCommentsWithoutCids;\n }\n previousAccountsCommentsJson = accountsCommentsJson;\n\n const accountsCommentsWithoutCids: AccountsComments = {};\n if (!accounts || !accountsComments) {\n return accountsCommentsWithoutCids;\n }\n for (const accountId in accountsComments) {\n const accountComments = accountsComments[accountId];\n const account = accounts[accountId];\n for (const accountCommentIndex in accountComments) {\n const accountComment = accountComments[accountCommentIndex];\n if (!accountComment.cid) {\n const authorAddress = account?.author?.address;\n if (!authorAddress) {\n continue;\n }\n if (!accountsCommentsWithoutCids[authorAddress]) {\n accountsCommentsWithoutCids[authorAddress] = [];\n }\n accountsCommentsWithoutCids[authorAddress].push(accountComment);\n }\n }\n }\n previousAccountsCommentsWithoutCids = accountsCommentsWithoutCids;\n return accountsCommentsWithoutCids;\n};\n\nexport const ensureAccountEditsLoaded = async (accountId: string) => {\n assert(\n accountId && typeof accountId === \"string\",\n `ensureAccountEditsLoaded invalid '${accountId}'`,\n );\n\n if (accountsStore.getState().accountsEditsLoaded[accountId]) {\n return;\n }\n const existingPromise = accountEditsLoadPromises.get(accountId);\n if (existingPromise) {\n return existingPromise;\n }\n\n const loadPromise = accountsDatabase\n .getAccountEdits(accountId)\n .then((loadedAccountEdits) => {\n accountsStore.setState(({ accountsEdits, accountsEditsLoaded }) => ({\n accountsEdits: {\n ...accountsEdits,\n [accountId]: mergeLoadedAccountEdits(loadedAccountEdits, accountsEdits[accountId]),\n },\n accountsEditsLoaded: { ...accountsEditsLoaded, [accountId]: true },\n }));\n })\n .finally(() => {\n accountEditsLoadPromises.delete(accountId);\n });\n accountEditsLoadPromises.set(accountId, loadPromise);\n return loadPromise;\n};\n\nexport const resetLazyAccountHistoryLoaders = () => {\n accountEditsLoadPromises.clear();\n};\n\n// internal accounts action: mark an account's notifications as read\nexport const markNotificationsAsRead = async (account: Account) => {\n const { accountsCommentsReplies } = accountsStore.getState();\n assert(\n typeof account?.id === \"string\",\n `accountsStore.markNotificationsAsRead invalid account argument '${account}'`,\n );\n\n // find all unread replies\n const repliesToMarkAsRead: AccountCommentsReplies = {};\n for (const replyCid in accountsCommentsReplies[account.id]) {\n if (!accountsCommentsReplies[account.id][replyCid].markedAsRead) {\n repliesToMarkAsRead[replyCid] = {\n ...accountsCommentsReplies[account.id][replyCid],\n markedAsRead: true,\n };\n }\n }\n\n // add all to database\n const promises = [];\n for (const replyCid in repliesToMarkAsRead) {\n promises.push(\n accountsDatabase.addAccountCommentReply(account.id, repliesToMarkAsRead[replyCid]),\n );\n }\n await Promise.all(promises);\n\n // add all to react store\n log(\"accountsActions.markNotificationsAsRead\", { account, repliesToMarkAsRead });\n accountsStore.setState(({ accountsCommentsReplies }) => {\n const updatedAccountCommentsReplies = {\n ...accountsCommentsReplies[account.id],\n ...repliesToMarkAsRead,\n };\n return {\n accountsCommentsReplies: {\n ...accountsCommentsReplies,\n [account.id]: updatedAccountCommentsReplies,\n },\n };\n });\n};\n\n// internal accounts action: if a community has a role with an account's address\n// add it to the account.communities database\nexport const addCommunityRoleToAccountsCommunities = async (community: Community) => {\n if (!community) {\n return;\n }\n const { accounts } = accountsStore.getState();\n assert(accounts, `can't use accountsStore.accountActions before initialized`);\n\n // find community roles to add and remove\n const getRole = (community: any, authorAddress: string) =>\n community.roles && community.roles[authorAddress];\n const getChange = (accounts: any, community: any) => {\n const toUpsert: string[] = [];\n const toRemove: string[] = [];\n for (const accountId in accounts) {\n const account = accounts[accountId];\n const role = getRole(community, account.author.address);\n if (!role) {\n if (account.communities[community.address]) {\n toRemove.push(accountId);\n }\n } else {\n const currentRole = account.communities[community.address]?.role;\n if (!currentRole || currentRole.role !== role.role) {\n toUpsert.push(accountId);\n }\n }\n }\n return {\n toUpsert,\n toRemove,\n hasChange: toUpsert.length !== 0 || toRemove.length !== 0,\n };\n };\n\n const { hasChange } = getChange(accounts, community);\n if (!hasChange) {\n return;\n }\n\n accountsStore.setState(({ accounts }) => {\n const { toUpsert, toRemove } = getChange(accounts, community);\n const nextAccounts = { ...accounts };\n\n // edit databases and build next accounts (toUpsert implies role exists from getChange)\n for (const accountId of toUpsert) {\n const account = { ...nextAccounts[accountId] };\n const role = community.roles![account.author.address];\n account.communities = {\n ...account.communities,\n [community.address]: { ...account.communities[community.address], role },\n };\n nextAccounts[accountId] = account;\n accountsDatabase.addAccount(account);\n }\n for (const accountId of toRemove) {\n const account = { ...nextAccounts[accountId] };\n account.communities = { ...account.communities };\n delete account.communities[community.address];\n nextAccounts[accountId] = account;\n accountsDatabase.addAccount(account);\n }\n\n log(\"accountsActions.addCommunityRoleToAccountsCommunities\", {\n community,\n toUpsert,\n toRemove,\n });\n return { accounts: nextAccounts };\n });\n};\n"]}
|
|
@@ -26,12 +26,12 @@ import accountGenerator from "./account-generator.js";
|
|
|
26
26
|
import Logger from "@pkcprotocol/pkc-logger";
|
|
27
27
|
import validator from "../../lib/validator.js";
|
|
28
28
|
import chain from "../../lib/chain/index.js";
|
|
29
|
-
import assert from "assert";
|
|
29
|
+
import assert from "../../lib/assert.js";
|
|
30
30
|
const log = Logger("bitsocial-react-hooks:accounts:stores");
|
|
31
31
|
import * as accountsActionsInternal from "./accounts-actions-internal.js";
|
|
32
32
|
import { backfillPublicationCommunityAddress, createPkcCommunity, createPkcCommunityEdit, getPkcCommunityAddresses, normalizeCommunityEditOptionsForPkc, normalizePublicationOptionsForStore, normalizePublicationOptionsForPkc, withPublishChallengeAnswersCompat, } from "../../lib/pkc-compat.js";
|
|
33
33
|
import { getAccountCommentsIndex, getAccountCommunities, getCommentCidsToAccountsComments, COMMENT_MODERATION_AUTHOR_SUMMARY_KEY, getAccountEditPropertySummary, fetchCommentLinkDimensions, getAccountCommentDepth, addShortAddressesToAccountComment, sanitizeAccountCommentForState, sanitizeStoredAccountComment, getFreshestLoadedComment, getInitAccountCommentsToUpdate, } from "./utils.js";
|
|
34
|
-
import isEqual from "
|
|
34
|
+
import isEqual from "../../lib/is-equal.js";
|
|
35
35
|
import { v4 as uuid } from "uuid";
|
|
36
36
|
import utils from "../../lib/utils/index.js";
|
|
37
37
|
import { addOptimisticVoteMetadata } from "../../lib/utils/optimistic-vote-counts.js";
|