@bitsocial/bitsocial-react-hooks 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +2 -0
  3. package/dist/hooks/accounts/accounts.d.ts.map +1 -1
  4. package/dist/hooks/accounts/accounts.js +35 -10
  5. package/dist/hooks/accounts/accounts.js.map +1 -1
  6. package/dist/hooks/actions/actions.d.ts.map +1 -1
  7. package/dist/hooks/actions/actions.js +166 -93
  8. package/dist/hooks/actions/actions.js.map +1 -1
  9. package/dist/hooks/authors/author-avatars.d.ts +2 -2
  10. package/dist/hooks/authors/author-avatars.d.ts.map +1 -1
  11. package/dist/hooks/authors/author-avatars.js +48 -20
  12. package/dist/hooks/authors/author-avatars.js.map +1 -1
  13. package/dist/hooks/authors/authors.d.ts.map +1 -1
  14. package/dist/hooks/authors/authors.js +68 -22
  15. package/dist/hooks/authors/authors.js.map +1 -1
  16. package/dist/hooks/comments.d.ts.map +1 -1
  17. package/dist/hooks/comments.js +54 -3
  18. package/dist/hooks/comments.js.map +1 -1
  19. package/dist/hooks/communities.d.ts.map +1 -1
  20. package/dist/hooks/communities.js +41 -12
  21. package/dist/hooks/communities.js.map +1 -1
  22. package/dist/hooks/feeds/feeds.d.ts.map +1 -1
  23. package/dist/hooks/feeds/feeds.js +47 -11
  24. package/dist/hooks/feeds/feeds.js.map +1 -1
  25. package/dist/hooks/pkc-rpc.d.ts.map +1 -1
  26. package/dist/hooks/pkc-rpc.js +33 -20
  27. package/dist/hooks/pkc-rpc.js.map +1 -1
  28. package/dist/hooks/replies.d.ts.map +1 -1
  29. package/dist/hooks/replies.js +30 -4
  30. package/dist/hooks/replies.js.map +1 -1
  31. package/dist/index.d.ts +6 -4
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +4 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/lib/debug-utils.d.ts +4 -4
  36. package/dist/lib/debug-utils.d.ts.map +1 -1
  37. package/dist/lib/debug-utils.js +56 -11
  38. package/dist/lib/debug-utils.js.map +1 -1
  39. package/dist/lib/localforage-lru/localforage-lru.d.ts +1 -0
  40. package/dist/lib/localforage-lru/localforage-lru.d.ts.map +1 -1
  41. package/dist/lib/localforage-lru/localforage-lru.js +48 -10
  42. package/dist/lib/localforage-lru/localforage-lru.js.map +1 -1
  43. package/dist/lib/page-sorts.d.ts +6 -0
  44. package/dist/lib/page-sorts.d.ts.map +1 -1
  45. package/dist/lib/page-sorts.js +45 -9
  46. package/dist/lib/page-sorts.js.map +1 -1
  47. package/dist/lib/pkc-js/pkc-js-mock-content.d.ts.map +1 -1
  48. package/dist/lib/pkc-js/pkc-js-mock-content.js +5 -1
  49. package/dist/lib/pkc-js/pkc-js-mock-content.js.map +1 -1
  50. package/dist/lib/utils/utils.d.ts.map +1 -1
  51. package/dist/lib/utils/utils.js +24 -16
  52. package/dist/lib/utils/utils.js.map +1 -1
  53. package/dist/lib/validator.d.ts +1 -1
  54. package/dist/lib/validator.d.ts.map +1 -1
  55. package/dist/lib/validator.js +7 -1
  56. package/dist/lib/validator.js.map +1 -1
  57. package/dist/stores/accounts/account-generator.d.ts +1 -0
  58. package/dist/stores/accounts/account-generator.d.ts.map +1 -1
  59. package/dist/stores/accounts/account-generator.js +12 -4
  60. package/dist/stores/accounts/account-generator.js.map +1 -1
  61. package/dist/stores/accounts/accounts-actions-internal.d.ts.map +1 -1
  62. package/dist/stores/accounts/accounts-actions-internal.js +24 -6
  63. package/dist/stores/accounts/accounts-actions-internal.js.map +1 -1
  64. package/dist/stores/accounts/accounts-actions.d.ts.map +1 -1
  65. package/dist/stores/accounts/accounts-actions.js +339 -98
  66. package/dist/stores/accounts/accounts-actions.js.map +1 -1
  67. package/dist/stores/accounts/accounts-database.d.ts +1 -0
  68. package/dist/stores/accounts/accounts-database.d.ts.map +1 -1
  69. package/dist/stores/accounts/accounts-database.js +82 -15
  70. package/dist/stores/accounts/accounts-database.js.map +1 -1
  71. package/dist/stores/accounts/accounts-store.d.ts +1 -1
  72. package/dist/stores/accounts/accounts-store.d.ts.map +1 -1
  73. package/dist/stores/accounts/accounts-store.js +1 -1
  74. package/dist/stores/accounts/accounts-store.js.map +1 -1
  75. package/dist/stores/accounts/utils.d.ts +5 -1
  76. package/dist/stores/accounts/utils.d.ts.map +1 -1
  77. package/dist/stores/accounts/utils.js +58 -0
  78. package/dist/stores/accounts/utils.js.map +1 -1
  79. package/dist/stores/authors-comments/authors-comments-store.d.ts.map +1 -1
  80. package/dist/stores/authors-comments/authors-comments-store.js +39 -12
  81. package/dist/stores/authors-comments/authors-comments-store.js.map +1 -1
  82. package/dist/stores/comments/comments-store.d.ts +2 -0
  83. package/dist/stores/comments/comments-store.d.ts.map +1 -1
  84. package/dist/stores/comments/comments-store.js +170 -21
  85. package/dist/stores/comments/comments-store.js.map +1 -1
  86. package/dist/stores/communities/communities-store.d.ts.map +1 -1
  87. package/dist/stores/communities/communities-store.js +27 -7
  88. package/dist/stores/communities/communities-store.js.map +1 -1
  89. package/dist/stores/communities-pages/communities-pages-store.d.ts.map +1 -1
  90. package/dist/stores/communities-pages/communities-pages-store.js +131 -12
  91. package/dist/stores/communities-pages/communities-pages-store.js.map +1 -1
  92. package/dist/stores/feeds/feed-sorter.d.ts +5 -2
  93. package/dist/stores/feeds/feed-sorter.d.ts.map +1 -1
  94. package/dist/stores/feeds/feed-sorter.js +15 -4
  95. package/dist/stores/feeds/feed-sorter.js.map +1 -1
  96. package/dist/stores/feeds/feeds-store.d.ts +3 -0
  97. package/dist/stores/feeds/feeds-store.d.ts.map +1 -1
  98. package/dist/stores/feeds/feeds-store.js +36 -26
  99. package/dist/stores/feeds/feeds-store.js.map +1 -1
  100. package/dist/stores/feeds/utils.d.ts +16 -0
  101. package/dist/stores/feeds/utils.d.ts.map +1 -1
  102. package/dist/stores/feeds/utils.js +82 -26
  103. package/dist/stores/feeds/utils.js.map +1 -1
  104. package/dist/stores/replies/replies-store.d.ts.map +1 -1
  105. package/dist/stores/replies/replies-store.js +32 -6
  106. package/dist/stores/replies/replies-store.js.map +1 -1
  107. package/dist/stores/replies/utils.d.ts +3 -2
  108. package/dist/stores/replies/utils.d.ts.map +1 -1
  109. package/dist/stores/replies/utils.js +38 -5
  110. package/dist/stores/replies/utils.js.map +1 -1
  111. package/dist/stores/replies-pages/replies-pages-store.d.ts.map +1 -1
  112. package/dist/stores/replies-pages/replies-pages-store.js +68 -13
  113. package/dist/stores/replies-pages/replies-pages-store.js.map +1 -1
  114. package/dist/types.d.ts +11 -2
  115. package/dist/types.d.ts.map +1 -1
  116. package/dist/types.js.map +1 -1
  117. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"account-generator.js","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,qCAAqC,CAAC;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,mBAAmB;IACnB,sBAAsB;IACtB,iCAAiC;IACjC,2BAA2B;IAC3B,qBAAqB;IACrB,6BAA6B;CAC9B,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,wBAAwB;IACxB,qBAAqB;IACrB,8BAA8B;IAC9B,8BAA8B;IAC9B,+BA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GAAG,CAAC,CAAC;IACtB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,GAAG,kBAAkB,IAAI,aAAa,EAAE,CAAC;QAC7D,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACtC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,aAAa,EAAE,CAAC;IAClB,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,sBAAsB;IACtB,uBAAuB;IACvB,oBAAoB;CACrB,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import PkcJs from \"../../lib/pkc-js\";\nimport validator from \"../../lib/validator\";\nimport chain from \"../../lib/chain\";\nimport { v4 as uuid } from \"uuid\";\nimport accountsDatabase from \"./accounts-database\";\nimport { Accounts, AccountCommunity, ChainProviders } from \"../../types\";\nimport {\n getPkcClientOptions,\n normalizeAccountProtocolConfig,\n withProtocolAliases,\n} from \"../../lib/pkc-compat\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\n\nexport const DEFAULT_ETH_RPC_URL = \"https://ethereum-rpc.publicnode.com\";\nexport const DEFAULT_ETH_RPC_URLS = [\n DEFAULT_ETH_RPC_URL,\n \"https://eth.drpc.org\",\n \"https://ethereum.publicnode.com\",\n \"https://rpc.mevblocker.io\",\n \"https://1rpc.io/eth\",\n \"https://eth-pokt.nodies.app\",\n];\nexport const DEFAULT_HTTP_ROUTER_URLS = [\n \"https://peers.pleb.bot\",\n \"https://routing.lol\",\n \"https://peers.forumindex.com\",\n \"https://peers.plebpubsub.xyz\",\n \"https://routerofbitsocial.xyz\",\n \"https://bsotracker.online\",\n];\n\n// default chain providers\nconst chainProviders: ChainProviders = {\n eth: {\n // Use explicit RPCs for default name resolution; viem's default transport is opt-in.\n urls: [...DEFAULT_ETH_RPC_URLS, \"ethers.js\"],\n chainId: 1,\n },\n matic: {\n urls: [\"https://polygon-rpc.com\"],\n chainId: 137,\n },\n};\n\n// force using these options or can cause bugs\nexport const overwritePkcOptions = {\n resolveAuthorNames: false,\n resolveAuthorAddresses: false,\n validatePages: false,\n};\n\nconst aliasProtocolOptions = (options: Record<string, any>) => ({\n ...options,\n resolveAuthorNames: options.resolveAuthorNames ?? options.resolveAuthorAddresses ?? false,\n resolveAuthorAddresses: options.resolveAuthorAddresses ?? options.resolveAuthorNames ?? false,\n});\n\nconst addMissingChainProviders = (options: Record<string, any>) => {\n const optionsWithChainProviders = { ...options };\n if (!optionsWithChainProviders.chainProviders) {\n optionsWithChainProviders.chainProviders = {};\n }\n for (const chainTicker in chainProviders) {\n if (!optionsWithChainProviders.chainProviders[chainTicker]) {\n optionsWithChainProviders.chainProviders[chainTicker] = chainProviders[chainTicker];\n }\n }\n return optionsWithChainProviders;\n};\n\nexport const getDefaultChainProviders = () => {\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n const windowChainProviders = defaultWindowOptions?.chainProviders\n ? JSON.parse(JSON.stringify(defaultWindowOptions.chainProviders))\n : undefined;\n return addMissingChainProviders({\n chainProviders: windowChainProviders,\n }).chainProviders as ChainProviders;\n};\n\n// default options aren't saved to database so they can be changed\nexport const getDefaultPkcOptions = () => {\n // default PKC options defined by the electron process\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n if (defaultWindowOptions) {\n // @ts-ignore\n const defaultPkcOptions: any = JSON.parse(\n JSON.stringify({ ...defaultWindowOptions, libp2pJsClientsOptions: undefined }),\n );\n delete defaultPkcOptions.chainProviders;\n delete defaultPkcOptions.nameResolversChainProviders;\n // @ts-ignore\n defaultPkcOptions.libp2pJsClientsOptions = defaultWindowOptions.libp2pJsClientsOptions; // libp2pJsClientsOptions is not always just json\n return aliasProtocolOptions({ ...defaultPkcOptions, ...overwritePkcOptions });\n }\n // default PKC options for web client\n return aliasProtocolOptions({\n libp2pJsClientsOptions: [{ key: \"libp2pjs\" }],\n ipfsGatewayUrls: undefined,\n kuboRpcClientsOptions: undefined,\n pubsubKuboRpcClientsOptions: undefined,\n httpRoutersOptions: [...DEFAULT_HTTP_ROUTER_URLS],\n ...overwritePkcOptions,\n });\n};\n\n// the gateway to use in <img src> for nft avatars\n// @ts-ignore\nconst defaultMediaIpfsGatewayUrl = window.defaultMediaIpfsGatewayUrl || \"https://ipfs.io\";\n\nexport const getDefaultAccountFields = () => ({\n subscriptions: [],\n blockedAddresses: {},\n blockedCids: {},\n savedComments: [],\n communities: {},\n mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,\n});\n\nconst generateDefaultAccount = async () => {\n const pkcOptions = getDefaultPkcOptions();\n const chainProviders = getDefaultChainProviders();\n const pkc = await PkcJs.PKC(\n await getPkcClientOptions(\n {\n chainProviders,\n pkcOptions,\n },\n pkcOptions,\n ),\n );\n // handle errors or error events are uncaught\n // no need to log them because pkc-js already logs them\n pkc.on(\"error\", (error: any) =>\n log.error(\"uncaught pkc instance error, should never happen\", { error }),\n );\n\n const signer = await pkc.createSigner();\n const author = {\n address: signer.address,\n wallets: {\n eth: await chain.getEthWalletFromPkcPrivateKey(signer.privateKey, signer.address),\n },\n };\n\n const accountName = await getNextAvailableDefaultAccountName(author.address);\n\n // communities where the account has a role, like moderator, admin, owner, etc.\n const communities: { [communityAddress: string]: AccountCommunity } = {};\n\n const account = normalizeAccountProtocolConfig(\n withProtocolAliases(\n {\n id: uuid(),\n version: accountsDatabase.accountVersion,\n name: accountName,\n author,\n signer,\n chainProviders,\n pkcOptions,\n ...getDefaultAccountFields(),\n communities,\n },\n pkc,\n pkcOptions,\n ),\n chainProviders,\n );\n return account;\n};\n\nconst getNextAvailableDefaultAccountName = async (authorAddress: string) => {\n const shortAddress = PkcJs.PKC.getShortAddress?.({ address: authorAddress }) || authorAddress;\n const defaultAccountName = `Account ${shortAddress}`;\n const accountIds: string[] | null =\n await accountsDatabase.accountsMetadataDatabase.getItem(\"accountIds\");\n const accountNames = [];\n if (accountIds?.length) {\n const accounts: Accounts | null = await accountsDatabase.getAccounts(accountIds);\n for (const accountId of accountIds) {\n accountNames.push(accounts[accountId].name);\n }\n }\n if (!accountNames?.length) {\n return defaultAccountName;\n }\n validator.validateAccountsDatabaseAccountNames(accountNames);\n\n const accountNamesSet = new Set(accountNames);\n if (!accountNamesSet.has(defaultAccountName)) {\n return defaultAccountName;\n }\n\n let accountNumber = 2;\n while (true) {\n const accountName = `${defaultAccountName} ${accountNumber}`;\n if (!accountNamesSet.has(accountName)) {\n return accountName;\n }\n accountNumber++;\n }\n};\n\nconst accountGenerator = {\n generateDefaultAccount,\n getDefaultAccountFields,\n getDefaultPkcOptions,\n};\n\nexport default accountGenerator;\n"]}
1
+ {"version":3,"file":"account-generator.js","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,qCAAqC,CAAC;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,mBAAmB;IACnB,sBAAsB;IACtB,iCAAiC;IACjC,2BAA2B;IAC3B,qBAAqB;IACrB,6BAA6B;CAC9B,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,wBAAwB;IACxB,qBAAqB;IACrB,8BAA8B;IAC9B,8BAA8B;IAC9B,+BAA+B;IAC/B,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AAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,SAAS,CAAC,oCAAoC,CAAC,YAAY,CAAC,CAAC;IAE7D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC7C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,GAAG,kBAAkB,IAAI,aAAa,EAAE,CAAC;QAC7D,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACtC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,aAAa,EAAE,CAAC;IAClB,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,sBAAsB;IACtB,uBAAuB;IACvB,oBAAoB;CACrB,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import PkcJs from \"../../lib/pkc-js\";\nimport validator from \"../../lib/validator\";\nimport chain from \"../../lib/chain\";\nimport { v4 as uuid } from \"uuid\";\nimport accountsDatabase from \"./accounts-database\";\nimport { Account, AccountCommunity, ChainProviders } from \"../../types\";\nimport {\n getPkcClientOptions,\n normalizeAccountProtocolConfig,\n withProtocolAliases,\n} from \"../../lib/pkc-compat\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\n\nexport const DEFAULT_ETH_RPC_URL = \"https://ethereum-rpc.publicnode.com\";\nexport const DEFAULT_ETH_RPC_URLS = [\n DEFAULT_ETH_RPC_URL,\n \"https://eth.drpc.org\",\n \"https://ethereum.publicnode.com\",\n \"https://rpc.mevblocker.io\",\n \"https://1rpc.io/eth\",\n \"https://eth-pokt.nodies.app\",\n];\nexport const DEFAULT_HTTP_ROUTER_URLS = [\n \"https://peers.pleb.bot\",\n \"https://routing.lol\",\n \"https://peers.forumindex.com\",\n \"https://peers.plebpubsub.xyz\",\n \"https://routerofbitsocial.xyz\",\n \"https://bsotracker.online\",\n];\n\n// default chain providers\nconst chainProviders: ChainProviders = {\n eth: {\n // Use explicit RPCs for default name resolution; viem's default transport is opt-in.\n urls: [...DEFAULT_ETH_RPC_URLS, \"ethers.js\"],\n chainId: 1,\n },\n matic: {\n urls: [\"https://polygon-rpc.com\"],\n chainId: 137,\n },\n};\n\n// force using these options or can cause bugs\nexport const overwritePkcOptions = {\n resolveAuthorNames: false,\n resolveAuthorAddresses: false,\n validatePages: false,\n};\n\nconst aliasProtocolOptions = (options: Record<string, any>) => ({\n ...options,\n resolveAuthorNames: options.resolveAuthorNames ?? options.resolveAuthorAddresses ?? false,\n resolveAuthorAddresses: options.resolveAuthorAddresses ?? options.resolveAuthorNames ?? false,\n});\n\nconst addMissingChainProviders = (options: Record<string, any>) => {\n const optionsWithChainProviders = { ...options };\n if (!optionsWithChainProviders.chainProviders) {\n optionsWithChainProviders.chainProviders = {};\n }\n for (const chainTicker in chainProviders) {\n if (!optionsWithChainProviders.chainProviders[chainTicker]) {\n optionsWithChainProviders.chainProviders[chainTicker] = chainProviders[chainTicker];\n }\n }\n return optionsWithChainProviders;\n};\n\nexport const getDefaultChainProviders = () => {\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n const windowChainProviders = defaultWindowOptions?.chainProviders\n ? JSON.parse(JSON.stringify(defaultWindowOptions.chainProviders))\n : undefined;\n return addMissingChainProviders({\n chainProviders: windowChainProviders,\n }).chainProviders as ChainProviders;\n};\n\n// default options aren't saved to database so they can be changed\nexport const getDefaultPkcOptions = () => {\n // default PKC options defined by the electron process\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n if (defaultWindowOptions) {\n // @ts-ignore\n const defaultPkcOptions: any = JSON.parse(\n JSON.stringify({ ...defaultWindowOptions, libp2pJsClientsOptions: undefined }),\n );\n delete defaultPkcOptions.chainProviders;\n delete defaultPkcOptions.nameResolversChainProviders;\n // @ts-ignore\n defaultPkcOptions.libp2pJsClientsOptions = defaultWindowOptions.libp2pJsClientsOptions; // libp2pJsClientsOptions is not always just json\n return aliasProtocolOptions({ ...defaultPkcOptions, ...overwritePkcOptions });\n }\n // default PKC options for web client\n return aliasProtocolOptions({\n libp2pJsClientsOptions: [{ key: \"libp2pjs\" }],\n ipfsGatewayUrls: undefined,\n kuboRpcClientsOptions: undefined,\n pubsubKuboRpcClientsOptions: undefined,\n httpRoutersOptions: [...DEFAULT_HTTP_ROUTER_URLS],\n ...overwritePkcOptions,\n });\n};\n\n// the gateway to use in <img src> for nft avatars\n// @ts-ignore\nconst defaultMediaIpfsGatewayUrl = window.defaultMediaIpfsGatewayUrl || \"https://ipfs.io\";\n\nexport const getDefaultAccountFields = () => ({\n subscriptions: [],\n blockedAddresses: {},\n blockedCids: {},\n savedComments: [],\n communities: {},\n mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,\n});\n\nconst generateDefaultAccount = async () => {\n const pkcOptions = getDefaultPkcOptions();\n const chainProviders = getDefaultChainProviders();\n const pkc = await PkcJs.PKC(\n await getPkcClientOptions(\n {\n chainProviders,\n pkcOptions,\n },\n pkcOptions,\n ),\n );\n // handle errors or error events are uncaught\n // no need to log them because pkc-js already logs them\n pkc.on(\"error\", (error: any) =>\n log.error(\"uncaught pkc instance error, should never happen\", { error }),\n );\n\n const signer = await pkc.createSigner();\n const author = {\n address: signer.address,\n wallets: {\n eth: await chain.getEthWalletFromPkcPrivateKey(signer.privateKey, signer.address),\n },\n };\n\n const accountName = await getNextAvailableDefaultAccountName(author.address);\n\n // communities where the account has a role, like moderator, admin, owner, etc.\n const communities: { [communityAddress: string]: AccountCommunity } = {};\n\n const account = normalizeAccountProtocolConfig(\n withProtocolAliases(\n {\n id: uuid(),\n version: accountsDatabase.accountVersion,\n name: accountName,\n author,\n signer,\n chainProviders,\n pkcOptions,\n ...getDefaultAccountFields(),\n communities,\n // unix timestamp in seconds, like community.createdAt. Only set when an account is\n // generated (not in getDefaultAccountFields): accounts created before this field existed\n // and their imports keep it undefined instead of an invented date\n createdAt: Math.floor(Date.now() / 1000),\n },\n pkc,\n pkcOptions,\n ),\n chainProviders,\n );\n return account;\n};\n\nconst getNextAvailableDefaultAccountName = async (authorAddress: string) => {\n const shortAddress = PkcJs.PKC.getShortAddress?.({ address: authorAddress }) || authorAddress;\n const defaultAccountName = `Account ${shortAddress}`;\n const accountIds: string[] | null =\n await accountsDatabase.accountsMetadataDatabase.getItem(\"accountIds\");\n const accountNames = [];\n if (accountIds?.length) {\n // read the stored records: hydrating the accounts would create a pkc client per account that\n // nothing destroys\n const storedAccounts = await Promise.all(\n accountIds.map((accountId) => accountsDatabase.accountsDatabase.getItem<Account>(accountId)),\n );\n for (const storedAccount of storedAccounts) {\n if (storedAccount) {\n accountNames.push(storedAccount.name);\n }\n }\n }\n if (!accountNames?.length) {\n return defaultAccountName;\n }\n validator.validateAccountsDatabaseAccountNames(accountNames);\n\n const accountNamesSet = new Set(accountNames);\n if (!accountNamesSet.has(defaultAccountName)) {\n return defaultAccountName;\n }\n\n let accountNumber = 2;\n while (true) {\n const accountName = `${defaultAccountName} ${accountNumber}`;\n if (!accountNamesSet.has(accountName)) {\n return accountName;\n }\n accountNumber++;\n }\n};\n\nconst accountGenerator = {\n generateDefaultAccount,\n getDefaultAccountFields,\n getDefaultPkcOptions,\n};\n\nexport default accountGenerator;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-actions-internal.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/accounts-actions-internal.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,OAAO,EAEP,OAAO,EAGP,SAAS,EACV,MAAM,aAAa,CAAC;AAmFrB,eAAO,MAAM,gDAAgD,GAC3D,SAAS,OAAO,EAChB,SAAS,OAAO,EAChB,qBAAqB,MAAM,kBAgM5B,CAAC;AAIF,eAAO,MAAM,sBAAsB,GAAU,SAAS,OAAO,kBAkE5D,CAAC;AAwCF,eAAO,MAAM,wBAAwB,GAAU,WAAW,MAAM,kBA8B/D,CAAC;AAEF,eAAO,MAAM,8BAA8B,YAE1C,CAAC;AAGF,eAAO,MAAM,uBAAuB,GAAU,SAAS,OAAO,kBAyC7D,CAAC;AAIF,eAAO,MAAM,qCAAqC,GAAU,WAAW,SAAS,kBAqE/E,CAAC"}
1
+ {"version":3,"file":"accounts-actions-internal.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/accounts-actions-internal.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,OAAO,EAEP,OAAO,EAGP,SAAS,EACV,MAAM,aAAa,CAAC;AAyGrB,eAAO,MAAM,gDAAgD,GAC3D,SAAS,OAAO,EAChB,SAAS,OAAO,EAChB,qBAAqB,MAAM,kBAgM5B,CAAC;AAIF,eAAO,MAAM,sBAAsB,GAAU,SAAS,OAAO,kBAkE5D,CAAC;AAwCF,eAAO,MAAM,wBAAwB,GAAU,WAAW,MAAM,kBA8B/D,CAAC;AAEF,eAAO,MAAM,8BAA8B,YAE1C,CAAC;AAGF,eAAO,MAAM,uBAAuB,GAAU,SAAS,OAAO,kBAyC7D,CAAC;AAIF,eAAO,MAAM,qCAAqC,GAAU,WAAW,SAAS,kBAqE/E,CAAC"}
@@ -66,6 +66,23 @@ const backfillLiveCommentCommunityAddress = (comment, communityAddress) => {
66
66
  }
67
67
  }
68
68
  };
69
+ // two accounts can hold the same comment, e.g. a backup of an identity imported next to the account
70
+ // it was exported from, so each account updates its own copy
71
+ const getAccountCommentUpdatingKey = (accountId, commentCid) => `${accountId}:${commentCid}`;
72
+ // commentCidsToAccountsComments names only the last account holding a comment, so another account
73
+ // holding it finds its own row by cid. Undefined once the account no longer has the comment.
74
+ const getAccountCommentIndexByCid = (accountId, commentCid) => {
75
+ if (!commentCid) {
76
+ return;
77
+ }
78
+ const { commentCidsToAccountsComments, accountsComments } = accountsStore.getState();
79
+ const mapping = commentCidsToAccountsComments[commentCid];
80
+ if ((mapping === null || mapping === void 0 ? void 0 : mapping.accountId) === accountId) {
81
+ return mapping.accountCommentIndex;
82
+ }
83
+ const accountCommentIndex = (accountsComments[accountId] || []).findIndex((accountComment) => (accountComment === null || accountComment === void 0 ? void 0 : accountComment.cid) === commentCid);
84
+ return accountCommentIndex === -1 ? undefined : accountCommentIndex;
85
+ };
69
86
  // TODO: we currently subscribe to updates for every single comment
70
87
  // in the user's account history. This probably does not scale, we
71
88
  // need to eventually schedule and queue older comments to look
@@ -80,11 +97,12 @@ export const startUpdatingAccountCommentOnCommentUpdateEvents = (comment, accoun
80
97
  return;
81
98
  }
82
99
  // account comment already updating
83
- if (accountsStore.getState().accountsCommentsUpdating[comment.cid]) {
100
+ const updatingKey = getAccountCommentUpdatingKey(account.id, comment.cid);
101
+ if (accountsStore.getState().accountsCommentsUpdating[updatingKey]) {
84
102
  return;
85
103
  }
86
104
  accountsStore.setState(({ accountsCommentsUpdating }) => ({
87
- accountsCommentsUpdating: Object.assign(Object.assign({}, accountsCommentsUpdating), { [comment.cid]: true }),
105
+ accountsCommentsUpdating: Object.assign(Object.assign({}, accountsCommentsUpdating), { [updatingKey]: true }),
88
106
  }));
89
107
  // comment is not a `Comment` instance
90
108
  if (!comment.on) {
@@ -96,11 +114,12 @@ export const startUpdatingAccountCommentOnCommentUpdateEvents = (comment, accoun
96
114
  (initialStoredComment === null || initialStoredComment === void 0 ? void 0 : initialStoredComment.communityAddress));
97
115
  comment.on("update", (updatedComment) => __awaiter(void 0, void 0, void 0, function* () {
98
116
  var _a, _b;
99
- const mapping = accountsStore.getState().commentCidsToAccountsComments[updatedComment.cid || ""];
100
- if (!mapping || mapping.accountId !== account.id) {
117
+ const currentIndex = getAccountCommentIndexByCid(account.id, updatedComment.cid);
118
+ // the account no longer has the comment, e.g. it was deleted
119
+ if (currentIndex === undefined) {
101
120
  accountsStore.setState(({ accountsCommentsUpdating }) => {
102
121
  const next = Object.assign({}, accountsCommentsUpdating);
103
- delete next[updatedComment.cid || ""];
122
+ delete next[updatingKey];
104
123
  return { accountsCommentsUpdating: next };
105
124
  });
106
125
  try {
@@ -117,7 +136,6 @@ export const startUpdatingAccountCommentOnCommentUpdateEvents = (comment, accoun
117
136
  }
118
137
  return;
119
138
  }
120
- const currentIndex = mapping.accountCommentIndex;
121
139
  // merge should not be needed if pkc-js is implemented properly, but no harm in fixing potential errors
122
140
  const storedComment = (_a = accountsStore.getState().accountsComments[account.id]) === null || _a === void 0 ? void 0 : _a[currentIndex];
123
141
  updatedComment = utils.merge(commentArgument, comment, updatedComment);
@@ -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,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,CAAA;I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AC/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"]}
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,CAAA;IAC9D,CAAC,CAAC,iBAAiB,CAAC,QAAQ,KAAK,uBAAuB,CAAC,QAAQ;IACjE,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC;AAE1D,MAAM,uBAAuB,GAAG,CAC9B,kBAAqD,EACrD,mBAAsD,EACtD,EAAE;IACF,MAAM,kBAAkB,qBAA+B,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAE,CAAC;IACpF,MAAM,WAAW,GA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C,MAAM,OAAO,qBAAQ,YAAY,CAAC,SAAS,CAAC,CAAE,CAAC;YAC/C,MAAM,IAAI,GAAG,SAAS,CAAC,KAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACtD,OAAO,CAAC,WAAW,mCACd,OAAO,CAAC,WAAW,KACtB,CAAC,SAAS,CAAC,OAAO,CAAC,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 \"../../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// two accounts can hold the same comment, e.g. a backup of an identity imported next to the account\n// it was exported from, so each account updates its own copy\nconst getAccountCommentUpdatingKey = (accountId: string, commentCid: string) =>\n `${accountId}:${commentCid}`;\n\n// commentCidsToAccountsComments names only the last account holding a comment, so another account\n// holding it finds its own row by cid. Undefined once the account no longer has the comment.\nconst getAccountCommentIndexByCid = (accountId: string, commentCid: string | undefined) => {\n if (!commentCid) {\n return;\n }\n const { commentCidsToAccountsComments, accountsComments } = accountsStore.getState();\n const mapping = commentCidsToAccountsComments[commentCid];\n if (mapping?.accountId === accountId) {\n return mapping.accountCommentIndex;\n }\n const accountCommentIndex = (accountsComments[accountId] || []).findIndex(\n (accountComment) => accountComment?.cid === commentCid,\n );\n return accountCommentIndex === -1 ? undefined : accountCommentIndex;\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 const updatingKey = getAccountCommentUpdatingKey(account.id, comment.cid);\n if (accountsStore.getState().accountsCommentsUpdating[updatingKey]) {\n return;\n }\n accountsStore.setState(({ accountsCommentsUpdating }) => ({\n accountsCommentsUpdating: { ...accountsCommentsUpdating, [updatingKey]: 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 currentIndex = getAccountCommentIndexByCid(account.id, updatedComment.cid);\n // the account no longer has the comment, e.g. it was deleted\n if (currentIndex === undefined) {\n accountsStore.setState(({ accountsCommentsUpdating }) => {\n const next = { ...accountsCommentsUpdating };\n delete next[updatingKey];\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\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 +1 @@
1
- {"version":3,"file":"accounts-actions.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/accounts-actions.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,OAAO,EAEP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