@bitsocial/bitsocial-react-hooks 0.1.0

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 (269) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +1365 -0
  3. package/dist/hooks/accounts/accounts.d.ts +64 -0
  4. package/dist/hooks/accounts/accounts.d.ts.map +1 -0
  5. package/dist/hooks/accounts/accounts.js +706 -0
  6. package/dist/hooks/accounts/accounts.js.map +1 -0
  7. package/dist/hooks/accounts/index.d.ts +2 -0
  8. package/dist/hooks/accounts/index.d.ts.map +1 -0
  9. package/dist/hooks/accounts/index.js +2 -0
  10. package/dist/hooks/accounts/index.js.map +1 -0
  11. package/dist/hooks/accounts/utils.d.ts +6 -0
  12. package/dist/hooks/accounts/utils.d.ts.map +1 -0
  13. package/dist/hooks/accounts/utils.js +226 -0
  14. package/dist/hooks/accounts/utils.js.map +1 -0
  15. package/dist/hooks/actions/actions.d.ts +19 -0
  16. package/dist/hooks/actions/actions.d.ts.map +1 -0
  17. package/dist/hooks/actions/actions.js +552 -0
  18. package/dist/hooks/actions/actions.js.map +1 -0
  19. package/dist/hooks/actions/index.d.ts +2 -0
  20. package/dist/hooks/actions/index.d.ts.map +1 -0
  21. package/dist/hooks/actions/index.js +2 -0
  22. package/dist/hooks/actions/index.js.map +1 -0
  23. package/dist/hooks/authors/author-avatars.d.ts +28 -0
  24. package/dist/hooks/authors/author-avatars.d.ts.map +1 -0
  25. package/dist/hooks/authors/author-avatars.js +191 -0
  26. package/dist/hooks/authors/author-avatars.js.map +1 -0
  27. package/dist/hooks/authors/authors.d.ts +37 -0
  28. package/dist/hooks/authors/authors.d.ts.map +1 -0
  29. package/dist/hooks/authors/authors.js +509 -0
  30. package/dist/hooks/authors/authors.js.map +1 -0
  31. package/dist/hooks/authors/index.d.ts +2 -0
  32. package/dist/hooks/authors/index.d.ts.map +1 -0
  33. package/dist/hooks/authors/index.js +2 -0
  34. package/dist/hooks/authors/index.js.map +1 -0
  35. package/dist/hooks/authors/utils.d.ts +4 -0
  36. package/dist/hooks/authors/utils.d.ts.map +1 -0
  37. package/dist/hooks/authors/utils.js +21 -0
  38. package/dist/hooks/authors/utils.js.map +1 -0
  39. package/dist/hooks/comments.d.ts +17 -0
  40. package/dist/hooks/comments.d.ts.map +1 -0
  41. package/dist/hooks/comments.js +351 -0
  42. package/dist/hooks/comments.js.map +1 -0
  43. package/dist/hooks/communities.d.ts +31 -0
  44. package/dist/hooks/communities.d.ts.map +1 -0
  45. package/dist/hooks/communities.js +389 -0
  46. package/dist/hooks/communities.js.map +1 -0
  47. package/dist/hooks/feeds/feeds.d.ts +18 -0
  48. package/dist/hooks/feeds/feeds.d.ts.map +1 -0
  49. package/dist/hooks/feeds/feeds.js +315 -0
  50. package/dist/hooks/feeds/feeds.js.map +1 -0
  51. package/dist/hooks/feeds/index.d.ts +2 -0
  52. package/dist/hooks/feeds/index.d.ts.map +1 -0
  53. package/dist/hooks/feeds/index.js +2 -0
  54. package/dist/hooks/feeds/index.js.map +1 -0
  55. package/dist/hooks/pkc-rpc.d.ts +7 -0
  56. package/dist/hooks/pkc-rpc.d.ts.map +1 -0
  57. package/dist/hooks/pkc-rpc.js +88 -0
  58. package/dist/hooks/pkc-rpc.js.map +1 -0
  59. package/dist/hooks/replies.d.ts +5 -0
  60. package/dist/hooks/replies.d.ts.map +1 -0
  61. package/dist/hooks/replies.js +155 -0
  62. package/dist/hooks/replies.js.map +1 -0
  63. package/dist/hooks/states.d.ts +15 -0
  64. package/dist/hooks/states.d.ts.map +1 -0
  65. package/dist/hooks/states.js +213 -0
  66. package/dist/hooks/states.js.map +1 -0
  67. package/dist/hooks/utils/use-interval.d.ts +3 -0
  68. package/dist/hooks/utils/use-interval.d.ts.map +1 -0
  69. package/dist/hooks/utils/use-interval.js +36 -0
  70. package/dist/hooks/utils/use-interval.js.map +1 -0
  71. package/dist/hooks/utils/use-previous.d.ts +1 -0
  72. package/dist/hooks/utils/use-previous.js +10 -0
  73. package/dist/index.d.ts +82 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +128 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/lib/chain/chain.d.ts +36 -0
  78. package/dist/lib/chain/chain.d.ts.map +1 -0
  79. package/dist/lib/chain/chain.js +195 -0
  80. package/dist/lib/chain/chain.js.map +1 -0
  81. package/dist/lib/chain/index.d.ts +4 -0
  82. package/dist/lib/chain/index.d.ts.map +1 -0
  83. package/dist/lib/chain/index.js +4 -0
  84. package/dist/lib/chain/index.js.map +1 -0
  85. package/dist/lib/community-address.d.ts +6 -0
  86. package/dist/lib/community-address.d.ts.map +1 -0
  87. package/dist/lib/community-address.js +26 -0
  88. package/dist/lib/community-address.js.map +1 -0
  89. package/dist/lib/community-ref.d.ts +23 -0
  90. package/dist/lib/community-ref.d.ts.map +1 -0
  91. package/dist/lib/community-ref.js +113 -0
  92. package/dist/lib/community-ref.js.map +1 -0
  93. package/dist/lib/debug-utils.d.ts +9 -0
  94. package/dist/lib/debug-utils.d.ts.map +1 -0
  95. package/dist/lib/debug-utils.js +21 -0
  96. package/dist/lib/debug-utils.js.map +1 -0
  97. package/dist/lib/feed-sort-type.d.ts +2 -0
  98. package/dist/lib/feed-sort-type.d.ts.map +1 -0
  99. package/dist/lib/feed-sort-type.js +22 -0
  100. package/dist/lib/feed-sort-type.js.map +1 -0
  101. package/dist/lib/localforage-lru/index.d.ts +3 -0
  102. package/dist/lib/localforage-lru/index.d.ts.map +1 -0
  103. package/dist/lib/localforage-lru/index.js +46 -0
  104. package/dist/lib/localforage-lru/index.js.map +1 -0
  105. package/dist/lib/localforage-lru/localforage-lru.d.ts +6 -0
  106. package/dist/lib/localforage-lru/localforage-lru.d.ts.map +1 -0
  107. package/dist/lib/localforage-lru/localforage-lru.js +182 -0
  108. package/dist/lib/localforage-lru/localforage-lru.js.map +1 -0
  109. package/dist/lib/pkc-compat.d.ts +25 -0
  110. package/dist/lib/pkc-compat.d.ts.map +1 -0
  111. package/dist/lib/pkc-compat.js +131 -0
  112. package/dist/lib/pkc-compat.js.map +1 -0
  113. package/dist/lib/pkc-js/fixtures/markdown-example.d.ts +3 -0
  114. package/dist/lib/pkc-js/fixtures/markdown-example.d.ts.map +1 -0
  115. package/dist/lib/pkc-js/fixtures/markdown-example.js +280 -0
  116. package/dist/lib/pkc-js/fixtures/markdown-example.js.map +1 -0
  117. package/dist/lib/pkc-js/index.d.ts +11 -0
  118. package/dist/lib/pkc-js/index.d.ts.map +1 -0
  119. package/dist/lib/pkc-js/index.js +85 -0
  120. package/dist/lib/pkc-js/index.js.map +1 -0
  121. package/dist/lib/pkc-js/pkc-js-mock-content.d.ts +3 -0
  122. package/dist/lib/pkc-js/pkc-js-mock-content.d.ts.map +1 -0
  123. package/dist/lib/pkc-js/pkc-js-mock-content.js +1235 -0
  124. package/dist/lib/pkc-js/pkc-js-mock-content.js.map +1 -0
  125. package/dist/lib/pkc-js/pkc-js-mock.d.ts +137 -0
  126. package/dist/lib/pkc-js/pkc-js-mock.d.ts.map +1 -0
  127. package/dist/lib/pkc-js/pkc-js-mock.js +644 -0
  128. package/dist/lib/pkc-js/pkc-js-mock.js.map +1 -0
  129. package/dist/lib/polyfill.d.ts +3 -0
  130. package/dist/lib/polyfill.d.ts.map +1 -0
  131. package/dist/lib/polyfill.js +14 -0
  132. package/dist/lib/polyfill.js.map +1 -0
  133. package/dist/lib/protocol-compat.d.ts +14 -0
  134. package/dist/lib/protocol-compat.d.ts.map +1 -0
  135. package/dist/lib/protocol-compat.js +67 -0
  136. package/dist/lib/protocol-compat.js.map +1 -0
  137. package/dist/lib/test-utils.d.ts +29 -0
  138. package/dist/lib/test-utils.d.ts.map +1 -0
  139. package/dist/lib/test-utils.js +184 -0
  140. package/dist/lib/test-utils.js.map +1 -0
  141. package/dist/lib/utils/comment-moderation.d.ts +4 -0
  142. package/dist/lib/utils/comment-moderation.d.ts.map +1 -0
  143. package/dist/lib/utils/comment-moderation.js +56 -0
  144. package/dist/lib/utils/comment-moderation.js.map +1 -0
  145. package/dist/lib/utils/index.d.ts +4 -0
  146. package/dist/lib/utils/index.d.ts.map +1 -0
  147. package/dist/lib/utils/index.js +4 -0
  148. package/dist/lib/utils/index.js.map +1 -0
  149. package/dist/lib/utils/utils.d.ts +23 -0
  150. package/dist/lib/utils/utils.d.ts.map +1 -0
  151. package/dist/lib/utils/utils.js +375 -0
  152. package/dist/lib/utils/utils.js.map +1 -0
  153. package/dist/lib/validator.d.ts +30 -0
  154. package/dist/lib/validator.d.ts.map +1 -0
  155. package/dist/lib/validator.js +307 -0
  156. package/dist/lib/validator.js.map +1 -0
  157. package/dist/stores/accounts/account-generator.d.ts +51 -0
  158. package/dist/stores/accounts/account-generator.d.ts.map +1 -0
  159. package/dist/stores/accounts/account-generator.js +160 -0
  160. package/dist/stores/accounts/account-generator.js.map +1 -0
  161. package/dist/stores/accounts/accounts-actions-internal.d.ts +8 -0
  162. package/dist/stores/accounts/accounts-actions-internal.d.ts.map +1 -0
  163. package/dist/stores/accounts/accounts-actions-internal.js +403 -0
  164. package/dist/stores/accounts/accounts-actions-internal.js.map +1 -0
  165. package/dist/stores/accounts/accounts-actions.d.ts +46 -0
  166. package/dist/stores/accounts/accounts-actions.d.ts.map +1 -0
  167. package/dist/stores/accounts/accounts-actions.js +1341 -0
  168. package/dist/stores/accounts/accounts-actions.js.map +1 -0
  169. package/dist/stores/accounts/accounts-database.d.ts +34 -0
  170. package/dist/stores/accounts/accounts-database.d.ts.map +1 -0
  171. package/dist/stores/accounts/accounts-database.js +685 -0
  172. package/dist/stores/accounts/accounts-database.js.map +1 -0
  173. package/dist/stores/accounts/accounts-store.d.ts +32 -0
  174. package/dist/stores/accounts/accounts-store.d.ts.map +1 -0
  175. package/dist/stores/accounts/accounts-store.js +169 -0
  176. package/dist/stores/accounts/accounts-store.js.map +1 -0
  177. package/dist/stores/accounts/index.d.ts +4 -0
  178. package/dist/stores/accounts/index.d.ts.map +1 -0
  179. package/dist/stores/accounts/index.js +4 -0
  180. package/dist/stores/accounts/index.js.map +1 -0
  181. package/dist/stores/accounts/utils.d.ts +49 -0
  182. package/dist/stores/accounts/utils.d.ts.map +1 -0
  183. package/dist/stores/accounts/utils.js +419 -0
  184. package/dist/stores/accounts/utils.js.map +1 -0
  185. package/dist/stores/authors-comments/authors-comments-store.d.ts +37 -0
  186. package/dist/stores/authors-comments/authors-comments-store.d.ts.map +1 -0
  187. package/dist/stores/authors-comments/authors-comments-store.js +338 -0
  188. package/dist/stores/authors-comments/authors-comments-store.js.map +1 -0
  189. package/dist/stores/authors-comments/index.d.ts +4 -0
  190. package/dist/stores/authors-comments/index.d.ts.map +1 -0
  191. package/dist/stores/authors-comments/index.js +4 -0
  192. package/dist/stores/authors-comments/index.js.map +1 -0
  193. package/dist/stores/authors-comments/utils.d.ts +14 -0
  194. package/dist/stores/authors-comments/utils.d.ts.map +1 -0
  195. package/dist/stores/authors-comments/utils.js +81 -0
  196. package/dist/stores/authors-comments/utils.js.map +1 -0
  197. package/dist/stores/comments/comments-store.d.ts +19 -0
  198. package/dist/stores/comments/comments-store.d.ts.map +1 -0
  199. package/dist/stores/comments/comments-store.js +385 -0
  200. package/dist/stores/comments/comments-store.js.map +1 -0
  201. package/dist/stores/comments/index.d.ts +4 -0
  202. package/dist/stores/comments/index.d.ts.map +1 -0
  203. package/dist/stores/comments/index.js +4 -0
  204. package/dist/stores/comments/index.js.map +1 -0
  205. package/dist/stores/communities/communities-store.d.ts +17 -0
  206. package/dist/stores/communities/communities-store.d.ts.map +1 -0
  207. package/dist/stores/communities/communities-store.js +304 -0
  208. package/dist/stores/communities/communities-store.js.map +1 -0
  209. package/dist/stores/communities/index.d.ts +4 -0
  210. package/dist/stores/communities/index.d.ts.map +1 -0
  211. package/dist/stores/communities/index.js +4 -0
  212. package/dist/stores/communities/index.js.map +1 -0
  213. package/dist/stores/communities-pages/communities-pages-store.d.ts +23 -0
  214. package/dist/stores/communities-pages/communities-pages-store.d.ts.map +1 -0
  215. package/dist/stores/communities-pages/communities-pages-store.js +316 -0
  216. package/dist/stores/communities-pages/communities-pages-store.js.map +1 -0
  217. package/dist/stores/communities-pages/index.d.ts +4 -0
  218. package/dist/stores/communities-pages/index.d.ts.map +1 -0
  219. package/dist/stores/communities-pages/index.js +4 -0
  220. package/dist/stores/communities-pages/index.js.map +1 -0
  221. package/dist/stores/feeds/feed-sorter.d.ts +5 -0
  222. package/dist/stores/feeds/feed-sorter.d.ts.map +1 -0
  223. package/dist/stores/feeds/feed-sorter.js +135 -0
  224. package/dist/stores/feeds/feed-sorter.js.map +1 -0
  225. package/dist/stores/feeds/feeds-store.d.ts +25 -0
  226. package/dist/stores/feeds/feeds-store.d.ts.map +1 -0
  227. package/dist/stores/feeds/feeds-store.js +459 -0
  228. package/dist/stores/feeds/feeds-store.js.map +1 -0
  229. package/dist/stores/feeds/index.d.ts +4 -0
  230. package/dist/stores/feeds/index.d.ts.map +1 -0
  231. package/dist/stores/feeds/index.js +4 -0
  232. package/dist/stores/feeds/index.js.map +1 -0
  233. package/dist/stores/feeds/utils.d.ts +43 -0
  234. package/dist/stores/feeds/utils.d.ts.map +1 -0
  235. package/dist/stores/feeds/utils.js +736 -0
  236. package/dist/stores/feeds/utils.js.map +1 -0
  237. package/dist/stores/replies/index.d.ts +4 -0
  238. package/dist/stores/replies/index.d.ts.map +1 -0
  239. package/dist/stores/replies/index.js +4 -0
  240. package/dist/stores/replies/index.js.map +1 -0
  241. package/dist/stores/replies/replies-comments-store.d.ts +8 -0
  242. package/dist/stores/replies/replies-comments-store.d.ts.map +1 -0
  243. package/dist/stores/replies/replies-comments-store.js +23 -0
  244. package/dist/stores/replies/replies-comments-store.js.map +1 -0
  245. package/dist/stores/replies/replies-store.d.ts +29 -0
  246. package/dist/stores/replies/replies-store.d.ts.map +1 -0
  247. package/dist/stores/replies/replies-store.js +413 -0
  248. package/dist/stores/replies/replies-store.js.map +1 -0
  249. package/dist/stores/replies/utils.d.ts +25 -0
  250. package/dist/stores/replies/utils.d.ts.map +1 -0
  251. package/dist/stores/replies/utils.js +549 -0
  252. package/dist/stores/replies/utils.js.map +1 -0
  253. package/dist/stores/replies-pages/index.d.ts +4 -0
  254. package/dist/stores/replies-pages/index.d.ts.map +1 -0
  255. package/dist/stores/replies-pages/index.js +4 -0
  256. package/dist/stores/replies-pages/index.js.map +1 -0
  257. package/dist/stores/replies-pages/replies-pages-store.d.ts +20 -0
  258. package/dist/stores/replies-pages/replies-pages-store.d.ts.map +1 -0
  259. package/dist/stores/replies-pages/replies-pages-store.js +270 -0
  260. package/dist/stores/replies-pages/replies-pages-store.js.map +1 -0
  261. package/dist/stores/replies-pages/utils.d.ts +3 -0
  262. package/dist/stores/replies-pages/utils.d.ts.map +1 -0
  263. package/dist/stores/replies-pages/utils.js +43 -0
  264. package/dist/stores/replies-pages/utils.js.map +1 -0
  265. package/dist/types.d.ts +638 -0
  266. package/dist/types.d.ts.map +1 -0
  267. package/dist/types.js +3 -0
  268. package/dist/types.js.map +1 -0
  269. package/package.json +160 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/hooks/accounts/accounts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAC3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA8BpE,OAAO,EACL,mCAAmC,EACnC,kCAAkC,EAClC,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,6BAA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;QAEL,6BAA6B;QAC7B,OAAO;YACL,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAU,EAAE,EAAE;gBACnE,SAAS,CAAC,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;gBAC9B,GAAG,CAAC,KAAK,CAAC,gDAAgD,EAAE;oBAC1D,gBAAgB;oBAChB,KAAK;iBACN,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAErC,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,KAAK;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM;KACP,CAAC,EACF,CAAC,KAAK,EAAE,MAAM,CAAC,CAChB,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo, useState, useEffect } from \"react\";\nimport isEqual from \"lodash.isequal\";\nimport useAccountsStore from \"../../stores/accounts\";\nimport useCommunitiesStore from \"../../stores/communities\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:hooks\");\nimport assert from \"assert\";\nimport { useListCommunities, useCommunities } from \"../communities\";\nimport type {\n AccountComment,\n AccountComments,\n Account,\n Accounts,\n AccountVote,\n AccountsComments,\n AccountsCommentsReplies,\n UseAccountCommunitiesOptions,\n UseAccountCommunitiesResult,\n UseAccountVoteOptions,\n UseAccountVoteResult,\n UseAccountVotesOptions,\n UseAccountVotesResult,\n UseAccountCommentsOptions,\n UseAccountCommentsResult,\n UseAccountCommentOptions,\n UseAccountCommentResult,\n UseNotificationsOptions,\n UseNotificationsResult,\n UseAccountEditsOptions,\n UseAccountEditsResult,\n UseEditedCommentOptions,\n UseEditedCommentResult,\n UseAccountOptions,\n UseAccountResult,\n UsePubsubSubscribeOptions,\n UsePubsubSubscribeResult,\n} from \"../../types\";\nimport {\n useAccountsWithCalculatedProperties,\n useAccountWithCalculatedProperties,\n useCalculatedNotifications,\n} from \"./utils\";\nimport { getAccountEditPropertySummary } from \"../../stores/accounts/utils\";\nimport {\n getCanonicalCommunityAddress,\n getEquivalentCommunityAddressGroupKey,\n pickPreferredEquivalentCommunityAddress,\n} from \"../../lib/community-address\";\nimport { addCommentModeration } from \"../../lib/utils/comment-moderation\";\nimport useInterval from \"../utils/use-interval\";\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return\n * the active account id.\n */\nexport function useAccountId(accountName?: string) {\n const accountId = useAccountsStore((state) => state.accountNamesToAccountIds[accountName || \"\"]);\n // don't consider active account if account name is defined\n const activeAccountId = useAccountsStore((state) => !accountName && state.activeAccountId);\n const accountIdToUse = accountName ? accountId : activeAccountId;\n return accountIdToUse;\n}\n\n/**\n * @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return\n * the active account.\n */\nexport function useAccount(options?: UseAccountOptions): UseAccountResult {\n assert(\n !options || typeof options === \"object\",\n `useAccount options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const accountStore = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const account = useAccountWithCalculatedProperties(\n accountStore,\n accountComments,\n accountCommentsReplies,\n );\n log(\"useAccount\", { accountId, account, accountName });\n return account;\n}\n\n/**\n * Return all accounts in the order of `accountsStore.accountIds`. To reorder, use `accountsActions.setAccountsOrder(accountNames)`.\n */\nexport function useAccounts() {\n const accountIds = useAccountsStore((state) => state.accountIds);\n const accountsStore = useAccountsStore((state) => state.accounts);\n const accountsComments = useAccountsStore((state) => state.accountsComments);\n const accountsCommentsReplies = useAccountsStore((state) => state.accountsCommentsReplies);\n const accounts = useAccountsWithCalculatedProperties(\n accountsStore,\n accountsComments,\n accountsCommentsReplies,\n );\n const accountsArray: Account[] = useMemo(() => {\n const accountsArray = [];\n if (accountIds?.length && accounts) {\n for (const accountId of accountIds) {\n accountsArray.push(accounts[accountId]);\n }\n }\n return accountsArray;\n }, [accounts, accountIds]);\n\n log(\"useAccounts\", { accounts, accountIds });\n\n const state = accountsArray?.length ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accounts: accountsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [accountsArray, state],\n );\n}\n\n/**\n * Returns all communities where the account is a creator or moderator\n */\nexport function useAccountCommunities(\n options?: UseAccountCommunitiesOptions,\n): UseAccountCommunitiesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountCommunities options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, onlyIfCached } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const accountsStoreAccountCommunities = useAccountsStore(\n (state) => state.accounts[accountIdKey]?.communities,\n );\n\n // get all unique account community addresses\n const ownerCommunityAddresses = useListCommunities(accountName);\n const groupedCommunityAddresses = useMemo(() => {\n const accountCommunityAddresses = [];\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n accountCommunityAddresses.push(communityAddress);\n }\n }\n const allCommunityAddresses = [\n ...new Set([...ownerCommunityAddresses, ...accountCommunityAddresses]),\n ].sort();\n const groupedAddresses = new Map<string, string[]>();\n for (const communityAddress of allCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const addresses = groupedAddresses.get(groupKey);\n if (addresses) {\n addresses.push(communityAddress);\n } else {\n groupedAddresses.set(groupKey, [communityAddress]);\n }\n }\n return [...groupedAddresses.entries()].map(([groupKey, addresses]) => ({\n groupKey,\n addresses,\n preferredAddress: pickPreferredEquivalentCommunityAddress(addresses),\n }));\n }, [accountsStoreAccountCommunities, ownerCommunityAddresses]);\n const uniqueCommunityAddresses = useMemo(\n () => groupedCommunityAddresses.map(({ preferredAddress }) => preferredAddress),\n [groupedCommunityAddresses],\n );\n\n // fetch all community data\n const {\n communities: communitiesArray,\n state: communitiesState,\n error: communitiesError,\n errors: communitiesErrors,\n } = useCommunities({\n communities: uniqueCommunityAddresses.map((communityAddress) => ({ name: communityAddress })),\n accountName,\n onlyIfCached,\n });\n const communityFetchErrors = useCommunitiesStore((state: any) =>\n uniqueCommunityAddresses.flatMap((communityAddress) => state.errors[communityAddress] || []),\n );\n const canonicalAddressByGroupKey = useMemo(() => {\n const canonicalAddresses: { [groupKey: string]: string } = {};\n for (const [i, { groupKey, preferredAddress }] of groupedCommunityAddresses.entries()) {\n const fetchedAddress = communitiesArray[i]?.address;\n canonicalAddresses[groupKey] = getCanonicalCommunityAddress(\n fetchedAddress || preferredAddress,\n );\n }\n return canonicalAddresses;\n }, [groupedCommunityAddresses, communitiesArray]);\n const communities: any = useMemo(() => {\n const communities: any = {};\n for (const [i, community] of communitiesArray.entries()) {\n const { groupKey, preferredAddress } = groupedCommunityAddresses[i];\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n communities[canonicalAddress] = {\n ...communities[canonicalAddress],\n ...community,\n // make sure the canonical address is defined even if the community hasn't fetched yet\n address: canonicalAddress,\n };\n }\n return communities;\n }, [communitiesArray, groupedCommunityAddresses, canonicalAddressByGroupKey]);\n\n // merged community data with account.communities data\n const accountCommunities: any = useMemo(() => {\n const accountCommunities: any = { ...communities };\n if (accountsStoreAccountCommunities) {\n for (const communityAddress in accountsStoreAccountCommunities) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n ...accountsStoreAccountCommunities[communityAddress],\n address: canonicalAddress,\n };\n }\n }\n // add pkc.communities data\n for (const communityAddress of ownerCommunityAddresses) {\n const groupKey = getEquivalentCommunityAddressGroupKey(communityAddress);\n const canonicalAddress = canonicalAddressByGroupKey[groupKey];\n accountCommunities[canonicalAddress] = {\n ...accountCommunities[canonicalAddress],\n address: canonicalAddress,\n role: { role: \"owner\" },\n };\n }\n return accountCommunities;\n }, [\n accountsStoreAccountCommunities,\n ownerCommunityAddresses,\n communities,\n canonicalAddressByGroupKey,\n ]);\n\n if (accountId) {\n log(\"useAccountCommunities\", { accountCommunities });\n }\n\n const pendingAccountCommunities = Object.values(accountCommunities).some(\n (community: any) => community?.address && !community?.updatedAt,\n );\n const errors = communityFetchErrors.length ? communityFetchErrors : communitiesErrors;\n const error = communitiesError || errors[errors.length - 1];\n const state = !accountId\n ? \"initializing\"\n : error\n ? \"failed\"\n : pendingAccountCommunities\n ? \"fetching-ipns\"\n : communitiesState;\n\n return useMemo(\n () => ({\n accountCommunities,\n state,\n error,\n errors,\n }),\n [accountCommunities, state, error, errors],\n );\n}\n\n/**\n * Returns an account's notifications in an array. Unread notifications have a field markedAsRead: false.\n *\n * @param accountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, return\n * the active account's notifications.\n */\nexport function useNotifications(options?: UseNotificationsOptions): UseNotificationsResult {\n assert(\n !options || typeof options === \"object\",\n `useNotifications options argument '${options}' not an object`,\n );\n const { accountName } = options || {};\n // get state\n const accountId = useAccountId(accountName);\n const account = useAccountsStore((state) => state.accounts[accountId || \"\"]);\n const accountCommentsReplies = useAccountsStore(\n (state) => state.accountsCommentsReplies[accountId || \"\"],\n );\n const accountsActionsInternal = useAccountsStore((state) => state.accountsActionsInternal);\n const notifications = useCalculatedNotifications(account, accountCommentsReplies);\n const [errors, setErrors] = useState<Error[]>([]);\n\n const markAsRead = async () => {\n try {\n if (!account) {\n throw Error(\"useNotifications cannot mark as read accounts not initalized yet\");\n }\n accountsActionsInternal.markNotificationsAsRead(account);\n } catch (e: any) {\n setErrors([...errors, e]);\n }\n };\n\n if (account) {\n log(\"useNotifications\", { notifications });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n notifications,\n markAsRead,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [notifications, errors],\n );\n}\n\nconst getAccountCommentsStates = (accountComments: AccountComment[]) => {\n // Without a cid, the account comment is still a local pending publish. pkc-js marks\n // terminal publish failures when `publishingState === \"failed\"` and publication `state`\n // is `\"stopped\"`, so we derive failed from that terminal pair or recorded publish errors.\n const now = Math.round(Date.now() / 1000);\n const expiryTime = now - 60 * 20;\n\n const states: string[] = [];\n for (const accountComment of accountComments) {\n let state = \"succeeded\";\n if (!accountComment.cid) {\n const ac = accountComment as AccountComment & {\n error?: Error;\n errors?: Error[];\n publishingState?: string;\n state?: string;\n };\n const resolvedPublishFailed =\n (ac.publishingState === \"failed\" && ac.state === \"stopped\") ||\n ac.error != null ||\n (Array.isArray(ac.errors) && ac.errors.length > 0);\n\n if (resolvedPublishFailed) {\n state = \"failed\";\n } else if (accountComment.timestamp > expiryTime) {\n state = \"pending\";\n } else {\n state = \"failed\";\n }\n }\n states.push(state);\n }\n\n return states;\n};\n\nexport const haveAccountCommentStatesChanged = (nextStates: string[], previousStates: string[]) =>\n nextStates.toString() !== previousStates.toString();\n\nconst getAccountHistorySortType = (\n sortType?: \"new\" | \"old\",\n order?: \"asc\" | \"desc\",\n): \"new\" | \"old\" => {\n if (sortType === \"new\" || sortType === \"old\") {\n return sortType;\n }\n return order === \"desc\" ? \"new\" : \"old\";\n};\n\nexport function useAccountComments(options?: UseAccountCommentsOptions): UseAccountCommentsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComments options argument '${options}' not an object`,\n );\n const {\n accountName,\n filter,\n commentCid,\n commentIndices,\n communityAddress,\n parentCid,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = options || {};\n assert(\n !filter || typeof filter === \"function\",\n `useAccountComments options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountCommentsIndexes = useAccountsStore(\n (state) => state.accountsCommentsIndexes[accountId || \"\"],\n );\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const [accountCommentStates, setAccountCommentStates] = useState<string[]>([]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountComments = useMemo(() => {\n if (!accountComments) {\n return [];\n }\n\n let scopedAccountComments = accountComments;\n if (Array.isArray(commentIndices) && commentIndices.length > 0) {\n const normalizedCommentIndices = commentIndices\n .map((commentIndex) => Number(commentIndex))\n .filter((commentIndex) => Number.isInteger(commentIndex) && commentIndex >= 0);\n scopedAccountComments = normalizedCommentIndices\n .map((commentIndex) => accountComments[commentIndex])\n .filter(Boolean);\n } else if (commentCid) {\n const mappedIndex =\n commentCidToAccountComment?.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n scopedAccountComments =\n typeof mappedIndex === \"number\" ? [accountComments[mappedIndex]].filter(Boolean) : [];\n } else if (parentCid) {\n const parentIndexes = accountCommentsIndexes?.byParentCid?.[parentCid];\n scopedAccountComments = parentIndexes?.length\n ? parentIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter((accountComment) => accountComment.parentCid === parentCid);\n } else if (communityAddress) {\n const communityIndexes = accountCommentsIndexes?.byCommunityAddress?.[communityAddress];\n scopedAccountComments = communityIndexes?.length\n ? communityIndexes.map((index) => accountComments[index]).filter(Boolean)\n : accountComments.filter(\n (accountComment) => accountComment.communityAddress === communityAddress,\n );\n }\n\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n scopedAccountComments = scopedAccountComments.filter(\n (accountComment) => accountComment.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n scopedAccountComments = scopedAccountComments.filter(filter);\n }\n if (accountHistorySortType === \"new\") {\n scopedAccountComments = [...scopedAccountComments].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n return scopedAccountComments.slice(startIndex, startIndex + pageSize);\n }\n return scopedAccountComments;\n }, [\n accountComments,\n accountCommentsIndexes,\n accountId,\n commentCid,\n commentIndices,\n commentCidToAccountComment,\n communityAddress,\n filter,\n newerThan,\n accountHistorySortType,\n page,\n pageSize,\n parentCid,\n ]);\n\n // Recheck periodically so the 20-minute “stale pending → failed” transition updates without other store events\n const delay = 60_000;\n const immediate = false;\n useInterval(\n () => {\n const states = getAccountCommentsStates(filteredAccountComments);\n if (haveAccountCommentStatesChanged(states, accountCommentStates)) {\n setAccountCommentStates(states);\n }\n },\n delay,\n immediate,\n );\n\n const filteredAccountCommentsWithStates = useMemo(() => {\n const states = getAccountCommentsStates(filteredAccountComments);\n return filteredAccountComments.map((comment, i) => ({\n ...comment,\n state: states[i],\n }));\n }, [filteredAccountComments, accountCommentStates]);\n\n if (options) {\n log(\"useAccountComments\", {\n accountId,\n filteredAccountCommentsWithStates,\n accountComments,\n commentCid,\n commentIndices,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n parentCid,\n });\n }\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountComments: filteredAccountCommentsWithStates,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountCommentsWithStates, state],\n );\n}\n\n/**\n * Returns an account's single comment, e.g. a pending comment they published.\n */\nexport function useAccountComment(options?: UseAccountCommentOptions): UseAccountCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentIndex, commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const commentCidToAccountComment = useAccountsStore(\n (state) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const accountComments = useAccountsStore((state) => state.accountsComments[accountId || \"\"]);\n const normalizedCommentIndex = commentIndex === undefined ? undefined : Number(commentIndex);\n const resolvedCommentIndex =\n typeof normalizedCommentIndex === \"number\" && !Number.isNaN(normalizedCommentIndex)\n ? normalizedCommentIndex\n : commentCidToAccountComment?.accountId === accountId\n ? commentCidToAccountComment.accountCommentIndex\n : undefined;\n const storedAccountComment = useMemo(() => {\n if (typeof resolvedCommentIndex !== \"number\") {\n return undefined;\n }\n return accountComments?.[resolvedCommentIndex];\n }, [accountComments, resolvedCommentIndex]);\n const accountComment = (storedAccountComment || {}) as Partial<AccountComment> & {\n error?: Error;\n errors?: Error[];\n };\n const state = storedAccountComment\n ? getAccountCommentsStates([storedAccountComment])[0]\n : \"initializing\";\n\n return useMemo(\n () =>\n ({\n ...accountComment,\n state,\n error: accountComment.error,\n errors: accountComment.errors || [],\n }) as UseAccountCommentResult,\n [accountComment, state],\n );\n}\n\n/**\n * Returns the own user's votes stored locally, even those not yet published by the community owner.\n * Check UseAccountCommentsOptions type in types.tsx to filter them, e.g. filter = {communityAddresses: ['memes.eth']}.\n */\nexport function useAccountVotes(options?: UseAccountVotesOptions): UseAccountVotesResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVotes options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const {\n accountName,\n filter,\n vote,\n commentCid,\n communityAddress,\n newerThan,\n page,\n pageSize,\n sortType,\n order,\n } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountVotes options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountId || \"\"]);\n const accountHistorySortType = getAccountHistorySortType(sortType, order);\n\n const filteredAccountVotesArray = useMemo(() => {\n let accountVotesArray: AccountVote[] = [];\n if (!accountVotes) {\n return accountVotesArray;\n }\n for (const i in accountVotes) {\n accountVotesArray.push(accountVotes[i]);\n }\n if (typeof vote === \"number\") {\n accountVotesArray = accountVotesArray.filter((accountVote) => accountVote.vote === vote);\n }\n if (commentCid) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.commentCid === commentCid,\n );\n }\n if (communityAddress) {\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.communityAddress === communityAddress,\n );\n }\n if (typeof newerThan === \"number\") {\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n accountVotesArray = accountVotesArray.filter(\n (accountVote) => accountVote.timestamp > newerThanTimestamp,\n );\n }\n if (filter) {\n accountVotesArray = accountVotesArray.filter(filter);\n }\n accountVotesArray = [...accountVotesArray].sort(\n (firstVote, secondVote) => (firstVote.timestamp || 0) - (secondVote.timestamp || 0),\n );\n if (accountHistorySortType === \"new\") {\n accountVotesArray = [...accountVotesArray].reverse();\n }\n if (typeof pageSize === \"number\" && pageSize > 0) {\n const pageNumber = Math.max(page || 0, 0);\n const startIndex = pageNumber * pageSize;\n accountVotesArray = accountVotesArray.slice(startIndex, startIndex + pageSize);\n }\n return accountVotesArray;\n }, [\n accountVotes,\n accountHistorySortType,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n page,\n pageSize,\n vote,\n ]);\n\n if (accountVotes && options) {\n log(\"useAccountVotes\", {\n accountId,\n filteredAccountVotesArray,\n accountVotes,\n commentCid,\n communityAddress,\n filter,\n newerThan,\n sortType: accountHistorySortType,\n page,\n pageSize,\n vote,\n });\n }\n\n // TODO: add failed / pending states\n\n const state = accountId ? \"succeeded\" : \"initializing\";\n\n return useMemo(\n () => ({\n accountVotes: filteredAccountVotesArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountVotesArray, state],\n );\n}\n\n/**\n * Returns an account's single vote on a comment, e.g. to know if you already voted on a comment.\n */\nexport function useAccountVote(options?: UseAccountVoteOptions): UseAccountVoteResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountVote options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { commentCid, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = commentCid || \"\";\n const accountVotes = useAccountsStore((state) => state.accountsVotes[accountIdKey]);\n const accountVote: any = accountVotes?.[commentCidKey];\n const state = accountId && commentCid ? \"succeeded\" : \"initializing\";\n\n // TODO: add failed / pending state\n\n return useMemo(\n () => ({\n ...accountVote,\n state,\n error: undefined,\n errors: [],\n }),\n [accountVote, state],\n );\n}\n\n/**\n * Returns all the comment and community edits published by an account.\n */\nexport function useAccountEdits(options?: UseAccountEditsOptions): UseAccountEditsResult {\n assert(\n !options || typeof options === \"object\",\n `useAccountEdits options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { filter, accountName } = opts;\n assert(\n !filter || typeof filter === \"function\",\n `useAccountEdits options.filter argument '${filter}' not an function`,\n );\n const accountId = useAccountId(accountName);\n const ensureAccountEditsLoaded = useAccountsStore(\n (state) => state.accountsActionsInternal.ensureAccountEditsLoaded,\n );\n const accountEdits = useAccountsStore((state) => state.accountsEdits[accountId || \"\"]);\n const accountEditsLoaded = useAccountsStore(\n (state) => state.accountsEditsLoaded[accountId || \"\"],\n );\n\n useEffect(() => {\n if (!accountId || accountEditsLoaded) {\n return;\n }\n ensureAccountEditsLoaded(accountId).catch((error: unknown) =>\n log.error(\"useAccountEdits ensureAccountEditsLoaded error\", { accountId, error }),\n );\n }, [accountEditsLoaded, accountId, ensureAccountEditsLoaded]);\n\n const accountEditsArray = useMemo(() => {\n const accountEditsArray = [];\n for (const i in accountEdits || {}) {\n accountEditsArray.push(...accountEdits[i]);\n }\n // sort by oldest first\n return accountEditsArray.sort((a, b) => a.timestamp - b.timestamp);\n }, [accountEdits]);\n\n const filteredAccountEditsArray = useMemo(() => {\n if (!filter) {\n return accountEditsArray;\n }\n return accountEditsArray.filter(filter);\n }, [accountEditsArray, filter]);\n\n // TODO: add failed / pending states\n\n const state = accountId ? (accountEditsLoaded ? \"succeeded\" : \"initializing\") : \"initializing\";\n\n return useMemo(\n () => ({\n accountEdits: filteredAccountEditsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [filteredAccountEditsArray, state],\n );\n}\n\n/**\n * Returns the comment edited (if has any edits), as well as the pending, succeeded or failed state of the edit.\n */\nexport function useEditedComment(options?: UseEditedCommentOptions): UseEditedCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useEditedComment options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { comment, accountName } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const commentCidKey = (comment && comment.cid) || \"\";\n const commentEdits = useAccountsStore(\n (state) => state.accountsEdits[accountIdKey]?.[commentCidKey],\n );\n const commentEditSummary = useAccountsStore(\n (state) => state.accountsEditsSummaries[accountIdKey]?.[commentCidKey],\n );\n\n let initialState = \"initializing\";\n if (accountId && comment && comment.cid) {\n initialState = \"unedited\";\n }\n\n const editedResult = useMemo(() => {\n const editedResult: any = {\n editedComment: undefined,\n succeededEdits: {},\n pendingEdits: {},\n failedEdits: {},\n state: undefined,\n };\n\n // there are no edits\n const propertyNameEdits: any =\n commentEdits?.length > 0 ? getAccountEditPropertySummary(commentEdits) : commentEditSummary;\n\n if (!propertyNameEdits || Object.keys(propertyNameEdits).length === 0) {\n return editedResult;\n }\n\n const now = Math.round(Date.now() / 1000);\n // no longer consider an edit pending ater an expiry time of 20 minutes\n const expiryTime = 60 * 20;\n\n // iterate over propertyNameEdits and find if succeeded, pending or failed\n for (const propertyName in propertyNameEdits) {\n const propertyNameEdit = propertyNameEdits[propertyName];\n\n const setPropertyNameEditState = (state: \"succeeded\" | \"pending\" | \"failed\") => {\n // set propertyNameEdit e.g. editedResult.succeededEdits.removed = true\n editedResult[`${state}Edits`][propertyName] = propertyNameEdit.value;\n\n // if any propertyNameEdit failed, consider the commentEdit failed\n if (state === \"failed\") {\n editedResult.state = \"failed\";\n }\n // if all propertyNameEdit succeeded, consider the commentEdit succeeded\n if (state === \"succeeded\" && !editedResult.state) {\n editedResult.state = \"succeeded\";\n }\n // if any propertyNameEdit are pending, and none have failed, consider the commentEdit pending\n if (state === \"pending\" && editedResult.state !== \"failed\") {\n editedResult.state = \"pending\";\n }\n };\n\n // Without a newer update we can only treat recent edits as pending. Older edits that never\n // produced any update are effectively stale and should stop shadowing the live comment.\n if (!comment?.updatedAt) {\n if (isEqual(comment?.[propertyName], propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n } else if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n } else {\n setPropertyNameEditState(\"failed\");\n }\n continue;\n }\n\n // comment.updatedAt is older than propertyNameEdit, propertyNameEdit is pending\n // because we haven't received the update yet and can't evaluate\n if (comment.updatedAt < propertyNameEdit.timestamp) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment.updatedAt is newer than propertyNameEdit, a comment update\n // has been received after the edit was published so we can evaluate\n else {\n // comment has propertyNameEdit, propertyNameEdit succeeded\n if (isEqual(comment[propertyName], propertyNameEdit.value)) {\n setPropertyNameEditState(\"succeeded\");\n continue;\n }\n\n // comment does not have propertyNameEdit\n else {\n // propertyNameEdit is newer than 20min, it is too recent to evaluate\n // so we should assume pending\n if (propertyNameEdit.timestamp > now - expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // propertyNameEdit is older than 20min, we can evaluate it\n else {\n // comment update was received too shortly after propertyNameEdit was\n // published, assume pending until a more recent comment update is received\n const timeSinceUpdate = comment.updatedAt - propertyNameEdit.timestamp;\n if (timeSinceUpdate < expiryTime) {\n setPropertyNameEditState(\"pending\");\n continue;\n }\n\n // comment update time is sufficiently distanced from propertyNameEdit\n // and comment doesn't have propertyNameEdit, assume failed\n else {\n setPropertyNameEditState(\"failed\");\n continue;\n }\n }\n }\n }\n }\n\n // define editedComment\n editedResult.editedComment = { ...comment };\n // add pending and succeeded props so the editor can see his changes right away\n // don't add failed edits to reflect the current state of the edited comment\n for (const propertyName in editedResult.pendingEdits) {\n editedResult.editedComment[propertyName] = editedResult.pendingEdits[propertyName];\n }\n for (const propertyName in editedResult.succeededEdits) {\n editedResult.editedComment[propertyName] = editedResult.succeededEdits[propertyName];\n }\n editedResult.editedComment = addCommentModeration(editedResult.editedComment);\n\n return editedResult;\n }, [comment, commentEditSummary, commentEdits]);\n\n return useMemo(\n () => ({\n ...editedResult,\n state: editedResult.state || initialState,\n error: undefined,\n errors: [],\n }),\n [editedResult, initialState],\n );\n}\n\n/**\n * This hook should be added to pages where the user is likely to publish something, i,e. the\n * submit page and the /c/<commentCid> page, it improves the speed of publishing to the pubsub\n * by subscribing to the pubsub right away.\n *\n * @param accountName - The nickname of the account, e.g. 'Account 1'.\n * @param communityAddress - The community address to subscribe to, e.g. 'news.eth'.\n */\nexport function usePubsubSubscribe(options?: UsePubsubSubscribeOptions): UsePubsubSubscribeResult {\n assert(\n !options || typeof options === \"object\",\n `usePubsubSubscribe options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { accountName, communityAddress } = opts;\n const accountId = useAccountId(accountName);\n const accountIdKey = accountId || \"\";\n const account = useAccountsStore((state) => state.accounts[accountIdKey]);\n const [state, setState] = useState(\"initializing\");\n const [errors, setErrors] = useState<Error[]>([]);\n\n useEffect(() => {\n if (!account?.pkc || !communityAddress) {\n return;\n }\n setState(\"subscribing\");\n account.pkc\n .pubsubSubscribe(communityAddress)\n .then(() => setState(\"succeeded\"))\n .catch((error: any) => {\n setErrors([...errors, error]);\n setState(\"failed\");\n log.error(\"usePubsubSubscribe pkc.pubsubSubscribe error\", { communityAddress, error });\n });\n\n // unsub on component unmount\n return function () {\n account.pkc.pubsubUnsubscribe(communityAddress).catch((error: any) => {\n setErrors([...errors, error]);\n log.error(\"usePubsubSubscribe pkc.pubsubUnsubscribe error\", {\n communityAddress,\n error,\n });\n });\n };\n }, [account?.pkc, communityAddress]);\n\n return useMemo(\n () => ({\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [state, errors],\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from "./accounts.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/accounts/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./accounts.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/accounts/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./accounts\";\n"]}
@@ -0,0 +1,6 @@
1
+ import type { Account, AccountsCommentsReplies, AccountCommentsReplies, AccountsComments, AccountComments, Accounts, AccountsNotifications, AccountCommentReply } from "../../types.js";
2
+ export declare const useCalculatedNotifications: (account?: Account, accountCommentsReplies?: AccountCommentsReplies) => AccountCommentReply[];
3
+ export declare const useCalculatedAccountsNotifications: (accounts?: Accounts, accountsCommentsReplies?: AccountsCommentsReplies) => AccountsNotifications;
4
+ export declare const useAccountWithCalculatedProperties: (account?: Accounts, accountComments?: AccountComments, accountCommentsReplies?: AccountCommentsReplies) => any;
5
+ export declare const useAccountsWithCalculatedProperties: (accounts?: Accounts, accountsComments?: AccountsComments, accountsCommentsReplies?: AccountsCommentsReplies) => Accounts | undefined;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/hooks/accounts/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,qBAAqB,EAErB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AASrB,eAAO,MAAM,0BAA0B,GACrC,UAAU,OAAO,EACjB,yBAAyB,sBAAsB,0BAchD,CAAC;AA0CF,eAAO,MAAM,kCAAkC,GAC7C,WAAW,QAAQ,EACnB,0BAA0B,uBAAuB,0BAqClD,CAAC;AAyCF,eAAO,MAAM,kCAAkC,GAC7C,UAAU,QAAQ,EAClB,kBAAkB,eAAe,EACjC,yBAAyB,sBAAsB,QAoBhD,CAAC;AAGF,eAAO,MAAM,mCAAmC,GAC9C,WAAW,QAAQ,EACnB,mBAAmB,gBAAgB,EACnC,0BAA0B,uBAAuB,yBAiClD,CAAC"}
@@ -0,0 +1,226 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMemo, useState, useEffect } from "react";
11
+ // @ts-ignore
12
+ import memoize from "memoizee";
13
+ import PkcJs from "../../lib/pkc-js/index.js";
14
+ import Logger from "@pkcprotocol/pkc-logger";
15
+ const log = Logger("bitsocial-react-hooks:accounts:hooks");
16
+ export const useCalculatedNotifications = (account, accountCommentsReplies) => {
17
+ return useMemo(() => {
18
+ if (!account || !accountCommentsReplies) {
19
+ return [];
20
+ }
21
+ // get reply notifications only
22
+ // TODO: at some point we should also add upvote notifications like 'your post has gotten 10 upvotes'
23
+ return getReplyNotificationsFromAccountCommentsReplies(accountCommentsReplies, account === null || account === void 0 ? void 0 : account.blockedAddresses, account === null || account === void 0 ? void 0 : account.blockedCids);
24
+ }, [accountCommentsReplies, account === null || account === void 0 ? void 0 : account.blockedAddresses, account === null || account === void 0 ? void 0 : account.blockedCids]);
25
+ };
26
+ // accountsBlockedAddresses must be cached to prevent rerenders
27
+ // TODO: add accountsBlockedAddresses as an object in the store that can easily be === checked for equality
28
+ const getAccountsBlockedAddressesNoCache = (...args) => {
29
+ const accountsBlockedAddresses = {};
30
+ const separator = Math.ceil(args.length / 2);
31
+ for (const [i] of args.entries()) {
32
+ const accountId = args[i];
33
+ const accountBlockedAddresses = args[i + separator];
34
+ if (accountBlockedAddresses) {
35
+ accountsBlockedAddresses[accountId] = accountBlockedAddresses;
36
+ }
37
+ }
38
+ return accountsBlockedAddresses;
39
+ };
40
+ // length false because variable arguments legnth
41
+ const getAccountsBlockedAddressesCached = memoize(getAccountsBlockedAddressesNoCache, {
42
+ max: 100,
43
+ length: false,
44
+ });
45
+ // accountsBlockedCids must be cached to prevent rerenders
46
+ // TODO: add accountsBlockedCids as an object in the store that can easily be === checked for equality
47
+ const getAccountsBlockedCidsNoCache = (...args) => {
48
+ const accountsBlockedCids = {};
49
+ const separator = Math.ceil(args.length / 2);
50
+ for (const [i] of args.entries()) {
51
+ const accountId = args[i];
52
+ const accountBlockedCids = args[i + separator];
53
+ if (accountBlockedCids) {
54
+ accountsBlockedCids[accountId] = accountBlockedCids;
55
+ }
56
+ }
57
+ return accountsBlockedCids;
58
+ };
59
+ // length false because variable arguments legnth
60
+ const getAccountsBlockedCidsCached = memoize(getAccountsBlockedCidsNoCache, {
61
+ max: 100,
62
+ length: false,
63
+ });
64
+ export const useCalculatedAccountsNotifications = (accounts, accountsCommentsReplies) => {
65
+ // accountsBlockedAddresses and accountsBlockedCids must be cached to prevent rerenders
66
+ // TODO: add accountsBlockedAddresses and accountsBlockedCids as objects in the store that can easily be === checked for equality
67
+ let accountsBlockedAddresses;
68
+ let accountsBlockedCids;
69
+ if (accounts && accountsCommentsReplies) {
70
+ const accountIds = Object.keys(accountsCommentsReplies);
71
+ const accountsBlockedAddressesArray = accountIds.map((accountId) => { var _a; return (_a = accounts[accountId]) === null || _a === void 0 ? void 0 : _a.blockedAddresses; });
72
+ accountsBlockedAddresses = getAccountsBlockedAddressesCached(...accountIds, ...accountsBlockedAddressesArray);
73
+ const accountsBlockedCidsArray = accountIds.map((accountId) => { var _a; return (_a = accounts[accountId]) === null || _a === void 0 ? void 0 : _a.blockedCids; });
74
+ accountsBlockedCids = getAccountsBlockedCidsCached(...accountIds, ...accountsBlockedCidsArray);
75
+ }
76
+ return useMemo(() => {
77
+ const accountsNotifications = {};
78
+ if (!accountsCommentsReplies) {
79
+ return accountsNotifications;
80
+ }
81
+ for (const accountId in accountsCommentsReplies) {
82
+ // get reply notifications only
83
+ // TODO: at some point we should also add upvote notifications like 'your post has gotten 10 upvotes'
84
+ accountsNotifications[accountId] = getReplyNotificationsFromAccountCommentsReplies(accountsCommentsReplies[accountId], accountsBlockedAddresses[accountId], accountsBlockedCids[accountId]);
85
+ }
86
+ return accountsNotifications;
87
+ }, [accountsCommentsReplies, accountsBlockedAddresses, accountsBlockedCids]);
88
+ };
89
+ const getReplyNotificationsFromAccountCommentsReplies = (accountCommentsReplies, accountBlockedAddresses, accountBlockedCids) => {
90
+ var _a;
91
+ // get reply notifications
92
+ const replyNotifications = [];
93
+ for (const replyCid in accountCommentsReplies) {
94
+ const reply = accountCommentsReplies[replyCid];
95
+ if ((accountBlockedAddresses === null || accountBlockedAddresses === void 0 ? void 0 : accountBlockedAddresses[reply.communityAddress]) ||
96
+ (accountBlockedAddresses === null || accountBlockedAddresses === void 0 ? void 0 : accountBlockedAddresses[(_a = reply.author) === null || _a === void 0 ? void 0 : _a.address])) {
97
+ continue;
98
+ }
99
+ if ((accountBlockedCids === null || accountBlockedCids === void 0 ? void 0 : accountBlockedCids[reply.cid]) ||
100
+ (accountBlockedCids === null || accountBlockedCids === void 0 ? void 0 : accountBlockedCids[reply.parentCid]) ||
101
+ (accountBlockedCids === null || accountBlockedCids === void 0 ? void 0 : accountBlockedCids[reply.postCid])) {
102
+ continue;
103
+ }
104
+ replyNotifications.push(reply);
105
+ }
106
+ return replyNotifications.sort((a, b) => b.timestamp - a.timestamp);
107
+ };
108
+ // add calculated properties to accounts, like karma and unreadNotificationCount
109
+ const useAccountCalculatedProperties = (account, accountComments, accountCommentsReplies) => {
110
+ const notifications = useCalculatedNotifications(account, accountCommentsReplies);
111
+ return useMemo(() => {
112
+ return getAccountCalculatedProperties(accountComments, notifications);
113
+ }, [accountComments, accountCommentsReplies]);
114
+ };
115
+ export const useAccountWithCalculatedProperties = (account, accountComments, accountCommentsReplies) => {
116
+ var _a, _b;
117
+ const accountCalculatedProperties = useAccountCalculatedProperties(account, accountComments, accountCommentsReplies);
118
+ const shortAddress = ((_a = account === null || account === void 0 ? void 0 : account.author) === null || _a === void 0 ? void 0 : _a.address) && PkcJs.PKC.getShortAddress({ address: (_b = account === null || account === void 0 ? void 0 : account.author) === null || _b === void 0 ? void 0 : _b.address });
119
+ return useMemo(() => {
120
+ if (!account) {
121
+ return;
122
+ }
123
+ if (shortAddress) {
124
+ account = Object.assign(Object.assign({}, account), { author: Object.assign(Object.assign({}, account.author), { shortAddress }) });
125
+ }
126
+ return Object.assign(Object.assign({}, account), accountCalculatedProperties);
127
+ }, [account, accountCalculatedProperties, shortAddress]);
128
+ };
129
+ // add calculated properties to accounts, like karma and unreadNotificationCount
130
+ export const useAccountsWithCalculatedProperties = (accounts, accountsComments, accountsCommentsReplies) => {
131
+ const accountsNotifications = useCalculatedAccountsNotifications(accounts, accountsCommentsReplies);
132
+ const accountsShortAuthorAddresses = useAccountsAuthorShortAddresses(accounts);
133
+ return useMemo(() => {
134
+ if (!accounts) {
135
+ return;
136
+ }
137
+ if (!accountsComments) {
138
+ return accounts;
139
+ }
140
+ const accountsWithCalculatedProperties = {};
141
+ for (const accountId in accounts) {
142
+ // must cache getAccountCalculatedProperties() or it recalculates every account, instead of only the one changed
143
+ const accountCalculatedProperties = getAccountCalculatedProperties(accountsComments[accountId], accountsNotifications[accountId]);
144
+ const account = Object.assign(Object.assign({}, accounts[accountId]), accountCalculatedProperties);
145
+ if (account.author) {
146
+ const shortAddr = accountsShortAuthorAddresses[accountId];
147
+ if (shortAddr !== undefined || !account.author.shortAddress) {
148
+ account.author = Object.assign(Object.assign({}, account.author), { shortAddress: shortAddr });
149
+ }
150
+ }
151
+ accountsWithCalculatedProperties[accountId] = account;
152
+ }
153
+ return accountsWithCalculatedProperties;
154
+ }, [accounts, accountsComments, accountsCommentsReplies, accountsShortAuthorAddresses]);
155
+ };
156
+ const getAccountCalculatedPropertiesNoCache = (accountComments, notifications) => {
157
+ const accountCalculatedProperties = {};
158
+ // add karma
159
+ const karma = {
160
+ replyUpvoteCount: 0,
161
+ replyDownvoteCount: 0,
162
+ replyScore: 0,
163
+ postUpvoteCount: 0,
164
+ postDownvoteCount: 0,
165
+ postScore: 0,
166
+ upvoteCount: 0,
167
+ downvoteCount: 0,
168
+ score: 0,
169
+ };
170
+ const comments = accountComments !== null && accountComments !== void 0 ? accountComments : [];
171
+ for (const comment of comments) {
172
+ if (comment.parentCid && comment.upvoteCount) {
173
+ karma.replyUpvoteCount += comment.upvoteCount;
174
+ }
175
+ if (comment.parentCid && comment.downvoteCount) {
176
+ karma.replyDownvoteCount += comment.downvoteCount;
177
+ }
178
+ if (!comment.parentCid && comment.upvoteCount) {
179
+ karma.postUpvoteCount += comment.upvoteCount;
180
+ }
181
+ if (!comment.parentCid && comment.downvoteCount) {
182
+ karma.postDownvoteCount += comment.downvoteCount;
183
+ }
184
+ }
185
+ karma.replyScore = karma.replyUpvoteCount - karma.replyDownvoteCount;
186
+ karma.postScore = karma.postUpvoteCount - karma.postDownvoteCount;
187
+ karma.upvoteCount = karma.replyUpvoteCount + karma.postUpvoteCount;
188
+ karma.downvoteCount = karma.replyDownvoteCount + karma.postDownvoteCount;
189
+ karma.score = karma.upvoteCount - karma.downvoteCount;
190
+ accountCalculatedProperties.karma = karma;
191
+ // add unreadNotificationCount
192
+ let unreadNotificationCount = 0;
193
+ const notifs = notifications !== null && notifications !== void 0 ? notifications : [];
194
+ for (const notification of notifs) {
195
+ if (!notification.markedAsRead) {
196
+ unreadNotificationCount++;
197
+ }
198
+ }
199
+ accountCalculatedProperties.unreadNotificationCount = unreadNotificationCount;
200
+ return accountCalculatedProperties;
201
+ };
202
+ const getAccountCalculatedProperties = memoize(getAccountCalculatedPropertiesNoCache, { max: 100 });
203
+ const useAccountsAuthorShortAddresses = (accounts) => {
204
+ const [shortAddresses, setShortAddresses] = useState({});
205
+ useEffect(() => {
206
+ (() => __awaiter(void 0, void 0, void 0, function* () {
207
+ var _a, _b;
208
+ const newShortAddresses = {};
209
+ let shouldUpdate = false;
210
+ for (const accountId in accounts || {}) {
211
+ const address = (_b = (_a = accounts === null || accounts === void 0 ? void 0 : accounts[accountId]) === null || _a === void 0 ? void 0 : _a.author) === null || _b === void 0 ? void 0 : _b.address;
212
+ if (!address)
213
+ continue;
214
+ newShortAddresses[accountId] = PkcJs.PKC.getShortAddress({ address });
215
+ if (shortAddresses[accountId] !== newShortAddresses[accountId]) {
216
+ shouldUpdate = true;
217
+ }
218
+ }
219
+ if (shouldUpdate) {
220
+ setShortAddresses(newShortAddresses);
221
+ }
222
+ }))();
223
+ }, [accounts]);
224
+ return shortAddresses;
225
+ };
226
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/hooks/accounts/utils.ts"],"names":[],"mappings":";;;;;;;;;AAYA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,aAAa;AACb,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,sCAAsC,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,OAAiB,EACjB,sBAA+C,EAC/C,EAAE;IACF,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,CAAC,OAAO,IAAI,CAAC,sBAAsB,EAAE,CAAC;YACxC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,+BAA+B;QAC/B,qGAAqG;QACrG,OAAO,+CAA+C,CACpD,sBAAsB,EACtB,OAAO,aAAP,OAAO,uBAAP,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AE,MAAM,0CAAE,OAAO,CAAC;gBAC3E,IAAI,CAAC,OAAO;oBAAE,SAAS;gBACvB,iBAAiB,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;gBACtE,IAAI,cAAc,CAAC,SAAS,CAAC,KAAK,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC/D,YAAY,GAAG,IAAI,CAAC;gBACtB,CAAC;YACH,CAAC;YACD,IAAI,YAAY,EAAE,CAAC;gBACjB,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAA,CAAC,EAAE,CAAC;IACP,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACf,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import assert from \"assert\";\nimport type {\n Account,\n AccountsCommentsReplies,\n AccountCommentsReplies,\n AccountsComments,\n AccountComments,\n Accounts,\n AccountsNotifications,\n Notification,\n AccountCommentReply,\n} from \"../../types\";\nimport { useMemo, useState, useEffect } from \"react\";\n// @ts-ignore\nimport memoize from \"memoizee\";\nimport utils from \"../../lib/utils\";\nimport PkcJs from \"../../lib/pkc-js\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:hooks\");\n\nexport const useCalculatedNotifications = (\n account?: Account,\n accountCommentsReplies?: AccountCommentsReplies,\n) => {\n return useMemo(() => {\n if (!account || !accountCommentsReplies) {\n return [];\n }\n // get reply notifications only\n // TODO: at some point we should also add upvote notifications like 'your post has gotten 10 upvotes'\n return getReplyNotificationsFromAccountCommentsReplies(\n accountCommentsReplies,\n account?.blockedAddresses,\n account?.blockedCids,\n );\n }, [accountCommentsReplies, account?.blockedAddresses, account?.blockedCids]);\n};\n\n// accountsBlockedAddresses must be cached to prevent rerenders\n// TODO: add accountsBlockedAddresses as an object in the store that can easily be === checked for equality\nconst getAccountsBlockedAddressesNoCache = (...args: any) => {\n const accountsBlockedAddresses: { [accountId: string]: { [address: string]: boolean } } = {};\n const separator = Math.ceil(args.length / 2);\n for (const [i] of args.entries()) {\n const accountId = args[i];\n const accountBlockedAddresses = args[i + separator];\n if (accountBlockedAddresses) {\n accountsBlockedAddresses[accountId] = accountBlockedAddresses;\n }\n }\n return accountsBlockedAddresses;\n};\n// length false because variable arguments legnth\nconst getAccountsBlockedAddressesCached = memoize(getAccountsBlockedAddressesNoCache, {\n max: 100,\n length: false,\n});\n\n// accountsBlockedCids must be cached to prevent rerenders\n// TODO: add accountsBlockedCids as an object in the store that can easily be === checked for equality\nconst getAccountsBlockedCidsNoCache = (...args: any) => {\n const accountsBlockedCids: { [accountId: string]: { [cid: string]: boolean } } = {};\n const separator = Math.ceil(args.length / 2);\n for (const [i] of args.entries()) {\n const accountId = args[i];\n const accountBlockedCids = args[i + separator];\n if (accountBlockedCids) {\n accountsBlockedCids[accountId] = accountBlockedCids;\n }\n }\n return accountsBlockedCids;\n};\n// length false because variable arguments legnth\nconst getAccountsBlockedCidsCached = memoize(getAccountsBlockedCidsNoCache, {\n max: 100,\n length: false,\n});\n\nexport const useCalculatedAccountsNotifications = (\n accounts?: Accounts,\n accountsCommentsReplies?: AccountsCommentsReplies,\n) => {\n // accountsBlockedAddresses and accountsBlockedCids must be cached to prevent rerenders\n // TODO: add accountsBlockedAddresses and accountsBlockedCids as objects in the store that can easily be === checked for equality\n let accountsBlockedAddresses: any;\n let accountsBlockedCids: any;\n if (accounts && accountsCommentsReplies) {\n const accountIds = Object.keys(accountsCommentsReplies);\n const accountsBlockedAddressesArray = accountIds.map(\n (accountId) => accounts[accountId]?.blockedAddresses,\n );\n accountsBlockedAddresses = getAccountsBlockedAddressesCached(\n ...accountIds,\n ...accountsBlockedAddressesArray,\n );\n const accountsBlockedCidsArray = accountIds.map(\n (accountId) => accounts[accountId]?.blockedCids,\n );\n accountsBlockedCids = getAccountsBlockedCidsCached(...accountIds, ...accountsBlockedCidsArray);\n }\n\n return useMemo(() => {\n const accountsNotifications: AccountsNotifications = {};\n if (!accountsCommentsReplies) {\n return accountsNotifications;\n }\n for (const accountId in accountsCommentsReplies) {\n // get reply notifications only\n // TODO: at some point we should also add upvote notifications like 'your post has gotten 10 upvotes'\n accountsNotifications[accountId] = getReplyNotificationsFromAccountCommentsReplies(\n accountsCommentsReplies[accountId],\n accountsBlockedAddresses[accountId],\n accountsBlockedCids[accountId],\n );\n }\n return accountsNotifications;\n }, [accountsCommentsReplies, accountsBlockedAddresses, accountsBlockedCids]);\n};\n\nconst getReplyNotificationsFromAccountCommentsReplies = (\n accountCommentsReplies: AccountCommentsReplies,\n accountBlockedAddresses?: { [address: string]: boolean },\n accountBlockedCids?: { [cid: string]: boolean },\n) => {\n // get reply notifications\n const replyNotifications: AccountCommentReply[] = [];\n for (const replyCid in accountCommentsReplies) {\n const reply = accountCommentsReplies[replyCid];\n if (\n accountBlockedAddresses?.[reply.communityAddress] ||\n accountBlockedAddresses?.[reply.author?.address]\n ) {\n continue;\n }\n if (\n accountBlockedCids?.[reply.cid] ||\n accountBlockedCids?.[reply.parentCid] ||\n accountBlockedCids?.[reply.postCid]\n ) {\n continue;\n }\n replyNotifications.push(reply);\n }\n return replyNotifications.sort((a, b) => b.timestamp - a.timestamp);\n};\n\n// add calculated properties to accounts, like karma and unreadNotificationCount\nconst useAccountCalculatedProperties = (\n account?: Account,\n accountComments?: AccountComments,\n accountCommentsReplies?: AccountCommentsReplies,\n) => {\n const notifications = useCalculatedNotifications(account, accountCommentsReplies);\n return useMemo(() => {\n return getAccountCalculatedProperties(accountComments, notifications);\n }, [accountComments, accountCommentsReplies]);\n};\n\nexport const useAccountWithCalculatedProperties = (\n account?: Accounts,\n accountComments?: AccountComments,\n accountCommentsReplies?: AccountCommentsReplies,\n) => {\n const accountCalculatedProperties = useAccountCalculatedProperties(\n account,\n accountComments,\n accountCommentsReplies,\n );\n const shortAddress =\n account?.author?.address && PkcJs.PKC.getShortAddress({ address: account?.author?.address });\n return useMemo(() => {\n if (!account) {\n return;\n }\n\n if (shortAddress) {\n account = { ...account, author: { ...account.author, shortAddress } };\n }\n\n return { ...account, ...accountCalculatedProperties };\n }, [account, accountCalculatedProperties, shortAddress]);\n};\n\n// add calculated properties to accounts, like karma and unreadNotificationCount\nexport const useAccountsWithCalculatedProperties = (\n accounts?: Accounts,\n accountsComments?: AccountsComments,\n accountsCommentsReplies?: AccountsCommentsReplies,\n) => {\n const accountsNotifications = useCalculatedAccountsNotifications(\n accounts,\n accountsCommentsReplies,\n );\n const accountsShortAuthorAddresses = useAccountsAuthorShortAddresses(accounts);\n\n return useMemo(() => {\n if (!accounts) {\n return;\n }\n if (!accountsComments) {\n return accounts;\n }\n const accountsWithCalculatedProperties: Accounts = {};\n for (const accountId in accounts) {\n // must cache getAccountCalculatedProperties() or it recalculates every account, instead of only the one changed\n const accountCalculatedProperties = getAccountCalculatedProperties(\n accountsComments[accountId],\n accountsNotifications[accountId],\n );\n const account = { ...accounts[accountId], ...accountCalculatedProperties };\n if (account.author) {\n const shortAddr = accountsShortAuthorAddresses[accountId];\n if (shortAddr !== undefined || !account.author.shortAddress) {\n account.author = { ...account.author, shortAddress: shortAddr };\n }\n }\n accountsWithCalculatedProperties[accountId] = account;\n }\n return accountsWithCalculatedProperties;\n }, [accounts, accountsComments, accountsCommentsReplies, accountsShortAuthorAddresses]);\n};\n\nconst getAccountCalculatedPropertiesNoCache = (\n accountComments?: AccountComments,\n notifications?: Notification[],\n) => {\n const accountCalculatedProperties: any = {};\n\n // add karma\n const karma = {\n replyUpvoteCount: 0,\n replyDownvoteCount: 0,\n replyScore: 0,\n postUpvoteCount: 0,\n postDownvoteCount: 0,\n postScore: 0,\n upvoteCount: 0,\n downvoteCount: 0,\n score: 0,\n };\n const comments = accountComments ?? [];\n for (const comment of comments) {\n if (comment.parentCid && comment.upvoteCount) {\n karma.replyUpvoteCount += comment.upvoteCount;\n }\n if (comment.parentCid && comment.downvoteCount) {\n karma.replyDownvoteCount += comment.downvoteCount;\n }\n if (!comment.parentCid && comment.upvoteCount) {\n karma.postUpvoteCount += comment.upvoteCount;\n }\n if (!comment.parentCid && comment.downvoteCount) {\n karma.postDownvoteCount += comment.downvoteCount;\n }\n }\n karma.replyScore = karma.replyUpvoteCount - karma.replyDownvoteCount;\n karma.postScore = karma.postUpvoteCount - karma.postDownvoteCount;\n karma.upvoteCount = karma.replyUpvoteCount + karma.postUpvoteCount;\n karma.downvoteCount = karma.replyDownvoteCount + karma.postDownvoteCount;\n karma.score = karma.upvoteCount - karma.downvoteCount;\n accountCalculatedProperties.karma = karma;\n\n // add unreadNotificationCount\n let unreadNotificationCount = 0;\n const notifs = notifications ?? [];\n for (const notification of notifs) {\n if (!notification.markedAsRead) {\n unreadNotificationCount++;\n }\n }\n accountCalculatedProperties.unreadNotificationCount = unreadNotificationCount;\n\n return accountCalculatedProperties;\n};\nconst getAccountCalculatedProperties = memoize(getAccountCalculatedPropertiesNoCache, { max: 100 });\n\nconst useAccountsAuthorShortAddresses = (accounts?: Accounts) => {\n const [shortAddresses, setShortAddresses] = useState<{ [accountId: string]: string }>({});\n useEffect(() => {\n (async () => {\n const newShortAddresses: { [accountId: string]: string } = {};\n let shouldUpdate = false;\n for (const accountId in accounts || {}) {\n const address: string | undefined = accounts?.[accountId]?.author?.address;\n if (!address) continue;\n newShortAddresses[accountId] = PkcJs.PKC.getShortAddress({ address });\n if (shortAddresses[accountId] !== newShortAddresses[accountId]) {\n shouldUpdate = true;\n }\n }\n if (shouldUpdate) {\n setShortAddresses(newShortAddresses);\n }\n })();\n }, [accounts]);\n return shortAddresses;\n};\n"]}
@@ -0,0 +1,19 @@
1
+ import type { Dispatch, SetStateAction } from "react";
2
+ /** Wraps a callback to no-op when guard returns false. Exported for coverage. */
3
+ export declare function withGuardActive<T extends (...args: any[]) => void>(guardActive: () => boolean, fn: T): T;
4
+ /** For usePublishComment: when abandoned, catch should no-op. Exported for coverage. */
5
+ export declare function handlePublishErrorWhenAbandoned(activeRequestIdRef: {
6
+ current: number | undefined;
7
+ }, requestId: number, error: Error, setErrors: Dispatch<SetStateAction<Error[]>>, onError?: (e: Error) => void): void;
8
+ /** For usePublishVote catch. Exported for coverage. */
9
+ export declare function handlePublishVoteError(error: Error, setErrors: Dispatch<SetStateAction<Error[]>>, onError?: (e: Error) => void): void;
10
+ import type { UseSubscribeOptions, UseSubscribeResult, UsePublishCommentOptions, UsePublishCommentResult, UseBlockOptions, UseBlockResult, UseCreateCommunityOptions, UseCreateCommunityResult, UsePublishVoteOptions, UsePublishVoteResult, UsePublishCommentEditOptions, UsePublishCommentEditResult, UsePublishCommentModerationOptions, UsePublishCommentModerationResult, UsePublishCommunityEditOptions, UsePublishCommunityEditResult } from "../../types.js";
11
+ export declare function useSubscribe(options?: UseSubscribeOptions): UseSubscribeResult;
12
+ export declare function useBlock(options?: UseBlockOptions): UseBlockResult;
13
+ export declare function usePublishComment(options?: UsePublishCommentOptions): UsePublishCommentResult;
14
+ export declare function usePublishVote(options?: UsePublishVoteOptions): UsePublishVoteResult;
15
+ export declare function usePublishCommentEdit(options?: UsePublishCommentEditOptions): UsePublishCommentEditResult;
16
+ export declare function usePublishCommentModeration(options?: UsePublishCommentModerationOptions): UsePublishCommentModerationResult;
17
+ export declare function usePublishCommunityEdit(options?: UsePublishCommunityEditOptions): UsePublishCommunityEditResult;
18
+ export declare function useCreateCommunity(options?: UseCreateCommunityOptions): UseCreateCommunityResult;
19
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/hooks/actions/actions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAOtD,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAChE,WAAW,EAAE,MAAM,OAAO,EAC1B,EAAE,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