@bitsocial/bitsocial-react-hooks 0.1.38 → 0.1.39

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 (60) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +13 -1
  3. package/dist/hooks/feeds/feeds.d.ts +1 -1
  4. package/dist/hooks/feeds/feeds.d.ts.map +1 -1
  5. package/dist/hooks/feeds/feeds.js +25 -38
  6. package/dist/hooks/feeds/feeds.js.map +1 -1
  7. package/dist/hooks/replies.d.ts.map +1 -1
  8. package/dist/hooks/replies.js +0 -1
  9. package/dist/hooks/replies.js.map +1 -1
  10. package/dist/index.d.ts +8 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +8 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/lib/page-sorts.d.ts +8 -0
  15. package/dist/lib/page-sorts.d.ts.map +1 -0
  16. package/dist/lib/page-sorts.js +37 -0
  17. package/dist/lib/page-sorts.js.map +1 -0
  18. package/dist/lib/serialize-feed-key.d.ts +2 -0
  19. package/dist/lib/serialize-feed-key.d.ts.map +1 -0
  20. package/dist/lib/serialize-feed-key.js +5 -0
  21. package/dist/lib/serialize-feed-key.js.map +1 -0
  22. package/dist/lib/validator.d.ts.map +1 -1
  23. package/dist/lib/validator.js +5 -37
  24. package/dist/lib/validator.js.map +1 -1
  25. package/dist/lib/wordfilters.d.ts +6 -0
  26. package/dist/lib/wordfilters.d.ts.map +1 -0
  27. package/dist/lib/wordfilters.js +113 -0
  28. package/dist/lib/wordfilters.js.map +1 -0
  29. package/dist/stores/accounts/accounts-actions.d.ts.map +1 -1
  30. package/dist/stores/accounts/accounts-actions.js +66 -0
  31. package/dist/stores/accounts/accounts-actions.js.map +1 -1
  32. package/dist/stores/communities-pages/communities-pages-store.d.ts +2 -2
  33. package/dist/stores/communities-pages/communities-pages-store.d.ts.map +1 -1
  34. package/dist/stores/communities-pages/communities-pages-store.js +11 -6
  35. package/dist/stores/communities-pages/communities-pages-store.js.map +1 -1
  36. package/dist/stores/feeds/feed-sorter.d.ts +1 -1
  37. package/dist/stores/feeds/feed-sorter.d.ts.map +1 -1
  38. package/dist/stores/feeds/feed-sorter.js +28 -22
  39. package/dist/stores/feeds/feed-sorter.js.map +1 -1
  40. package/dist/stores/feeds/feeds-store.d.ts.map +1 -1
  41. package/dist/stores/feeds/feeds-store.js +2 -6
  42. package/dist/stores/feeds/feeds-store.js.map +1 -1
  43. package/dist/stores/feeds/utils.d.ts.map +1 -1
  44. package/dist/stores/feeds/utils.js +10 -22
  45. package/dist/stores/feeds/utils.js.map +1 -1
  46. package/dist/stores/replies/replies-store.d.ts.map +1 -1
  47. package/dist/stores/replies/replies-store.js +22 -5
  48. package/dist/stores/replies/replies-store.js.map +1 -1
  49. package/dist/stores/replies/utils.d.ts +1 -1
  50. package/dist/stores/replies/utils.d.ts.map +1 -1
  51. package/dist/stores/replies/utils.js +16 -89
  52. package/dist/stores/replies/utils.js.map +1 -1
  53. package/dist/stores/replies-pages/replies-pages-store.d.ts +2 -2
  54. package/dist/stores/replies-pages/replies-pages-store.d.ts.map +1 -1
  55. package/dist/stores/replies-pages/replies-pages-store.js +15 -5
  56. package/dist/stores/replies-pages/replies-pages-store.js.map +1 -1
  57. package/dist/types.d.ts +23 -3
  58. package/dist/types.d.ts.map +1 -1
  59. package/dist/types.js.map +1 -1
  60. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"feeds-store.js","sourceRoot":"","sources":["../../../src/stores/feeds/feeds-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,oCAAoC,CAAC,CAAC;AAczD,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAA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M,aAAa,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;AAC5C,qDAAqD;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAS,EAAE;IACxC,0CAA0C,GAAG,EAAE,CAAC;IAChD,kDAAkD,GAAG,EAAE,CAAC;IACxD,gCAAgC,GAAG,IAAI,GAAG,EAAE,CAAC;IAC7C,wBAAwB,GAAG,EAAE,CAAC;IAC9B,gCAAgC,GAAG,EAAE,CAAC;IACtC,mBAAmB,GAAG,EAAE,CAAC;IACzB,2BAA2B,GAAG,EAAE,CAAC;IACjC,qCAAqC,GAAG,EAAE,CAAC;IAC3C,wBAAwB,GAAG,IAAI,GAAG,EAAE,CAAC;IACrC,mCAAmC,GAAG,CAAC,CAAC;IACxC,iDAAiD,GAAG,EAAE,CAAC;IACvD,wBAAwB,GAAG,EAAE,CAAC;IAC9B,6BAA6B,GAAG,CAAC,CAAC;IAClC,4BAA4B,GAAG,EAAE,CAAC;IAClC,kBAAkB,GAAG,KAAK,CAAC;IAC3B,gBAAgB,GAAG,KAAK,CAAC;IACzB,mDAAmD;IACnD,UAAU,CAAC,OAAO,EAAE,CAAC;IACrB,yBAAyB;IACzB,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACnC,qBAAqB,GAAG,KAAK,CAAC;AAChC,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAS,EAAE;IACnD,MAAM,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,sCAAsC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IAC9F,MAAM,eAAe,EAAE,CAAC;AAC1B,CAAC,CAAA,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import assert from \"assert\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:feeds:stores\");\nimport {\n Feed,\n Feeds,\n Community,\n Communities,\n Account,\n FeedsOptions,\n CommunityPage,\n FeedsCommunitiesPostCounts,\n CommentsFilter,\n FeedOptionsAccountComments,\n Comment,\n} from \"../../types\";\nimport createStore from \"zustand\";\nimport localForageLru from \"../../lib/localforage-lru\";\nimport { communityPostsCacheExpired } from \"../../lib/utils\";\nimport { getPkcGetCommunity } from \"../../lib/pkc-compat\";\nimport { deriveFeedSortType } from \"../../lib/feed-sort-type\";\nimport { CommunityLookupRef, getCommunityRefKeys } from \"../../lib/community-ref\";\nimport accountsStore from \"../accounts\";\nimport communitiesStore from \"../communities\";\nimport communitiesPagesStore from \"../communities-pages\";\nimport {\n getFeedsCommunitiesFirstPageCids,\n getLoadedFeeds,\n getUpdatedFeeds,\n getBufferedFeedsWithoutLoadedFeeds,\n getFeedsCommunitiesPostCounts,\n getFeedsHaveMore,\n getAccountsBlockedAddresses,\n feedsHaveChangedBlockedAddresses,\n accountsBlockedAddressesChanged,\n getAccountsBlockedCids,\n feedsHaveChangedBlockedCids,\n accountsBlockedCidsChanged,\n feedsCommunitiesChanged,\n getFeedsCommunities,\n getFeedsCommunitiesLoadedCount,\n getFeedsCommunitiesPostsPagesFirstUpdatedAts,\n getFilteredSortedFeeds,\n getFeedsCommunityKeysWithNewerPosts,\n} from \"./utils\";\n\n// reddit loads approximately 25 posts per page\n// while infinite scrolling\nexport const defaultPostsPerPage = 25;\n\n// keep large buffer because fetching cids is slow\nconst communityPostsLeftBeforeNextPage = 50;\n\ntype FeedsState = {\n feedsOptions: FeedsOptions;\n bufferedFeeds: Feeds;\n loadedFeeds: Feeds;\n updatedFeeds: Feeds;\n bufferedFeedsCommunitiesPostCounts: FeedsCommunitiesPostCounts;\n feedsHaveMore: { [feedName: string]: boolean };\n feedsCommunityKeysWithNewerPosts: { [feedName: string]: string[] };\n addFeedToStore: Function;\n incrementFeedPageNumber: Function;\n expandFeedTimeWindow: Function;\n resetFeed: Function;\n updateFeeds: Function;\n};\n\n// don't updateFeeds more than once per updateFeedsMinIntervalTime\nlet updateFeedsPending = false;\nlet updateFeedsAgain = false;\nconst updateFeedsMinIntervalTime = 100;\n\nconst feedsStore = createStore<FeedsState>((setState: Function, getState: Function) => ({\n feedsOptions: {},\n bufferedFeeds: {},\n loadedFeeds: {},\n updatedFeeds: {},\n bufferedFeedsCommunitiesPostCounts: {},\n feedsHaveMore: {},\n feedsCommunityKeysWithNewerPosts: {},\n\n async addFeedToStore(\n feedName: string,\n communities: CommunityLookupRef[],\n communityKeys: string[],\n sortType: string,\n account: Account,\n isBufferedFeed?: boolean,\n postsPerPage?: number,\n filter?: CommentsFilter,\n newerThan?: number,\n accountComments?: FeedOptionsAccountComments,\n modQueue?: string[],\n requestedSortType?: string,\n ) {\n // init here because must be called after async accounts store finished initializing\n initializeFeedsStore();\n\n assert(\n feedName && typeof feedName === \"string\",\n `feedsStore.addFeedToStore feedName '${feedName}' invalid`,\n );\n assert(\n Array.isArray(communities),\n `addFeedToStore.addFeedToStore communities '${communities}' invalid`,\n );\n assert(\n Array.isArray(communityKeys),\n `addFeedToStore.addFeedToStore communityKeys '${communityKeys}' invalid`,\n );\n const derivedCommunityKeys = getCommunityRefKeys(communities);\n assert(\n communityKeys.length === derivedCommunityKeys.length &&\n communityKeys.every((communityKey, index) => communityKey === derivedCommunityKeys[index]),\n `addFeedToStore.addFeedToStore communityKeys '${communityKeys}' do not match communities`,\n );\n assert(\n sortType && typeof sortType === \"string\",\n `addFeedToStore.addFeedToStore sortType '${sortType}' invalid`,\n );\n assert(\n typeof getPkcGetCommunity(account?.pkc) === \"function\",\n `addFeedToStore.addFeedToStore account '${account}' invalid`,\n );\n assert(\n typeof isBufferedFeed === \"boolean\" ||\n isBufferedFeed === undefined ||\n isBufferedFeed === null,\n `addFeedToStore.addFeedToStore isBufferedFeed '${isBufferedFeed}' invalid`,\n );\n assert(\n !filter || typeof filter?.filter === \"function\",\n `addFeedToStore.addFeedToStore filter.filter '${filter?.filter}' invalid`,\n );\n assert(\n !filter || typeof filter?.key === \"string\",\n `addFeedToStore.addFeedToStore filter.key '${filter?.key}' invalid`,\n );\n assert(\n !newerThan || typeof newerThan === \"number\",\n `addFeedToStore.addFeedToStore newerThan '${newerThan}' invalid`,\n );\n postsPerPage = postsPerPage || defaultPostsPerPage;\n assert(\n typeof postsPerPage === \"number\",\n `addFeedToStore.addFeedToStore postsPerPage '${postsPerPage}' invalid`,\n );\n assert(\n !accountComments || typeof accountComments?.newerThan === \"number\",\n `addFeedToStore.addFeedToStore accountComments.newerThan '${accountComments?.newerThan}' invalid`,\n );\n assert(\n !modQueue || Array.isArray(modQueue),\n `addFeedToStore.addFeedToStore modQueue '${modQueue}' invalid`,\n );\n\n const { feedsOptions, updateFeeds } = getState();\n // feed is in store already, do nothing\n // if the feed already exist but is at page 0, reset it to page 1\n if (feedsOptions[feedName] && feedsOptions[feedName].pageNumber !== 0) {\n return;\n }\n // to add a buffered feed, add a feed with pageNumber 0\n const feedOptions = {\n communities,\n communityKeys,\n sortType,\n requestedSortType: requestedSortType || sortType,\n accountId: account.id,\n pageNumber: isBufferedFeed === true ? 0 : 1,\n postsPerPage,\n newerThan,\n filter,\n accountComments,\n // TODO: allow multiple modQueue at once, fow now only use first in array\n modQueue,\n };\n log(\"feedsActions.addFeedToStore\", feedOptions);\n setState(({ feedsOptions }: any) => ({\n feedsOptions: { ...feedsOptions, [feedName]: feedOptions },\n }));\n\n addCommunitiesToCommunitiesStore(communities, account);\n\n // update feeds right away to use the already loaded communities and pages\n // if no new communities are added by the feed, like for a sort type change,\n // a feed update will never be triggered, so must be triggered it manually\n updateFeeds();\n },\n\n incrementFeedPageNumber(feedName: string) {\n const { feedsOptions, loadedFeeds, updateFeeds } = getState();\n assert(\n feedsOptions[feedName],\n `feedsActions.incrementFeedPageNumber feed name '${feedName}' does not exist in feeds store`,\n );\n log(\"feedsActions.incrementFeedPageNumber\", { feedName });\n\n assert(\n feedsOptions[feedName].pageNumber * feedsOptions[feedName].postsPerPage <=\n loadedFeeds[feedName].length,\n `feedsActions.incrementFeedPageNumber cannot increment feed page number before current page has loaded`,\n );\n setState(({ feedsOptions, loadedFeeds }: any) => {\n const feedOptions = {\n ...feedsOptions[feedName],\n pageNumber: feedsOptions[feedName].pageNumber + 1,\n };\n return { feedsOptions: { ...feedsOptions, [feedName]: feedOptions } };\n });\n\n // do not update feed at the same time as increment a page number or it might cause\n // a race condition, rather schedule a feed update\n updateFeeds();\n },\n\n expandFeedTimeWindow(feedName: string, newerThan?: number) {\n const { feedsOptions, loadedFeeds, updateFeeds } = getState();\n assert(\n feedsOptions[feedName],\n `feedsActions.expandFeedTimeWindow feed name '${feedName}' does not exist in feeds store`,\n );\n assert(\n newerThan === undefined || typeof newerThan === \"number\",\n `feedsActions.expandFeedTimeWindow newerThan '${newerThan}' invalid`,\n );\n\n const currentFeedOptions = feedsOptions[feedName];\n const currentNewerThan = currentFeedOptions.newerThan;\n\n if (currentNewerThan === newerThan) {\n return;\n }\n\n const isExpandedTimeWindow =\n typeof currentNewerThan === \"number\" &&\n (newerThan === undefined || newerThan > currentNewerThan);\n assert(\n isExpandedTimeWindow,\n `feedsActions.expandFeedTimeWindow newerThan '${newerThan}' must broaden the current window '${currentNewerThan}'`,\n );\n\n const nextSortType = deriveFeedSortType(currentFeedOptions.requestedSortType, newerThan);\n assert(\n nextSortType === currentFeedOptions.sortType,\n `feedsActions.expandFeedTimeWindow cannot change sort type from '${currentFeedOptions.sortType}' to '${nextSortType}'`,\n );\n\n const loadedFeed = loadedFeeds[feedName] || [];\n const shouldPrefetchExpandedPage =\n currentFeedOptions.pageNumber > 0 &&\n loadedFeed.length >= currentFeedOptions.pageNumber * currentFeedOptions.postsPerPage;\n\n setState(({ feedsOptions }: any) => ({\n feedsOptions: {\n ...feedsOptions,\n [feedName]: {\n ...currentFeedOptions,\n newerThan,\n pageNumber: shouldPrefetchExpandedPage\n ? currentFeedOptions.pageNumber + 1\n : currentFeedOptions.pageNumber,\n },\n },\n }));\n\n updateFeeds();\n },\n\n async resetFeed(feedName: string) {\n const { feedsOptions, updateFeeds } = getState();\n assert(\n feedsOptions[feedName],\n `feedsActions.resetFeed feed name '${feedName}' does not exist in feeds store`,\n );\n assert(\n feedsOptions[feedName].pageNumber >= 1,\n `feedsActions.resetFeed cannot reset feed page number '${feedsOptions[feedName].pageNumber}' lower than 1`,\n );\n log(\"feedsActions.resetFeed\", { feedName });\n\n const { modQueue, sortType, communities, communityKeys, accountId } = feedsOptions[feedName];\n const account = accountsStore.getState().accounts[accountId];\n assert(\n account,\n `feedsActions.resetFeed account id '${accountId}' does not exist in accounts store`,\n );\n\n setState(({ feedsOptions, loadedFeeds, updatedFeeds }: any) => {\n const feedOptions = {\n ...feedsOptions[feedName],\n pageNumber: 1,\n };\n return {\n feedsOptions: { ...feedsOptions, [feedName]: feedOptions },\n loadedFeeds: { ...loadedFeeds, [feedName]: [] },\n updatedFeeds: { ...updatedFeeds, [feedName]: [] },\n };\n });\n\n if (modQueue?.[0]) {\n const { communities } = communitiesStore.getState();\n const { invalidateCommunityPages } = communitiesPagesStore.getState();\n const loadedCommunities = communityKeys\n .map((communityKey: string) => communities[communityKey])\n .filter((community: Community | undefined): community is Community => Boolean(community));\n await Promise.all(\n loadedCommunities.map((community: Community) =>\n invalidateCommunityPages(community, sortType, modQueue, account.id),\n ),\n );\n }\n\n await Promise.all(\n communities.map((communityRef: CommunityLookupRef, communityIndex: number) =>\n communitiesStore\n .getState()\n .refreshCommunity(communityRef, account)\n .catch((error: unknown) =>\n log.error(\"feedsStore.resetFeed refreshCommunity error\", {\n feedName,\n community: communityRef,\n communityKey: communityKeys[communityIndex],\n error,\n }),\n ),\n ),\n );\n\n updateFeeds();\n },\n\n // recalculate all feeds using new communities.post.pages, communitiesPagesStore and page numbers\n updateFeeds() {\n if (updateFeedsPending) {\n updateFeedsAgain = true;\n return;\n }\n updateFeedsPending = true;\n\n // don't update feeds more than once per updateFeedsMinIntervalTime\n const timeUntilNextUpdate = Date.now() % updateFeedsMinIntervalTime;\n\n setTimeout(async () => {\n // get state from all stores\n const previousState = getState();\n const { feedsOptions, updateFeeds } = previousState;\n const { communities } = communitiesStore.getState();\n const { communitiesPages } = communitiesPagesStore.getState();\n const { accounts } = accountsStore.getState();\n\n // calculate new feeds\n const filteredSortedFeeds = getFilteredSortedFeeds(\n feedsOptions,\n communities,\n communitiesPages,\n accounts,\n communitiesPagesStore.getState().comments,\n );\n const bufferedFeedsWithoutPreviousLoadedFeeds = getBufferedFeedsWithoutLoadedFeeds(\n filteredSortedFeeds,\n previousState.loadedFeeds,\n );\n const loadedFeeds = await getLoadedFeeds(\n feedsOptions,\n filteredSortedFeeds,\n previousState.loadedFeeds,\n bufferedFeedsWithoutPreviousLoadedFeeds,\n accounts,\n );\n // after loaded feeds are caculated, remove new loaded feeds (again) from buffered feeds\n const bufferedFeeds = getBufferedFeedsWithoutLoadedFeeds(\n bufferedFeedsWithoutPreviousLoadedFeeds,\n loadedFeeds,\n );\n const bufferedFeedsCommunitiesPostCounts = getFeedsCommunitiesPostCounts(\n feedsOptions,\n bufferedFeeds,\n );\n const feedsHaveMore = getFeedsHaveMore(\n feedsOptions,\n bufferedFeeds,\n communities,\n communitiesPages,\n accounts,\n );\n const feedsCommunityKeysWithNewerPosts = getFeedsCommunityKeysWithNewerPosts(\n feedsOptions,\n filteredSortedFeeds,\n loadedFeeds,\n previousState.feedsCommunityKeysWithNewerPosts,\n );\n const updatedFeeds = await getUpdatedFeeds(\n feedsOptions,\n filteredSortedFeeds,\n previousState.updatedFeeds,\n loadedFeeds,\n accounts,\n );\n\n // set new feeds\n setState((state: any) => ({\n bufferedFeeds,\n loadedFeeds,\n updatedFeeds,\n bufferedFeedsCommunitiesPostCounts,\n feedsHaveMore,\n feedsCommunityKeysWithNewerPosts,\n }));\n log.trace(\"feedsStore.updateFeeds\", {\n feedsOptions,\n bufferedFeeds,\n loadedFeeds,\n updatedFeeds,\n bufferedFeedsCommunitiesPostCounts,\n feedsHaveMore,\n communities,\n communitiesPages,\n feedsCommunityKeysWithNewerPosts,\n });\n\n updateFeedsPending = false;\n\n // If a community/page update arrived during this calculation, run one\n // more pass so feedsHaveMore and loadedFeeds cannot stay on stale input.\n if (updateFeedsAgain) {\n updateFeedsAgain = false;\n updateFeeds();\n }\n }, timeUntilNextUpdate);\n },\n}));\n\nlet feedsStoreInitialized = false;\nconst initializeFeedsStore = async () => {\n if (feedsStoreInitialized) {\n return;\n }\n // TODO: optimize subscriptions e.g. updateFeedsOnFeedsCommunitiesChange(communities)\n // subscribe to communities store changes\n communitiesStore.subscribe(updateFeedsOnFeedsCommunitiesChange);\n // subscribe to bufferedFeedsCommunitiesPostCounts change\n feedsStore.subscribe(addCommunitiesPagesOnLowBufferedFeedsCommunitiesPostCounts);\n // subscribe to communities pages store changes\n communitiesPagesStore.subscribe(updateFeedsOnFeedsCommunitiesPagesChange);\n // subscribe to accounts store change (for blocked addresses)\n accountsStore.subscribe(updateFeedsOnAccountsBlockedAddressesChange);\n // subscribe to accounts store change (for blocked cids)\n accountsStore.subscribe(updateFeedsOnAccountsBlockedCidsChange);\n // subscribe to accounts store changes (for account comments)\n accountsStore.subscribe(updateFeedsOnAccountsCommentsChange);\n feedsStoreInitialized = true;\n};\n\nlet previousBlockedAddresses: string[] = [];\nlet previousAccountsBlockedAddresses: { [address: string]: boolean }[] = [];\nconst updateFeedsOnAccountsBlockedAddressesChange = (accountsStoreState: any) => {\n const { accounts } = accountsStoreState;\n\n // blocked addresses haven't changed, do nothing\n const accountsBlockedAddresses = [];\n for (const i in accounts) {\n accountsBlockedAddresses.push(accounts[i].blockedAddresses);\n }\n if (\n !accountsBlockedAddressesChanged(previousAccountsBlockedAddresses, accountsBlockedAddresses)\n ) {\n return;\n }\n previousAccountsBlockedAddresses = accountsBlockedAddresses;\n\n const blockedAddresses = getAccountsBlockedAddresses(accounts);\n\n // blocked addresses haven't changed, do nothing\n if (blockedAddresses.toString() === previousBlockedAddresses.toString()) {\n return;\n }\n\n const { feedsOptions, updateFeeds, bufferedFeeds } = feedsStore.getState();\n const _feedsHaveChangedBlockedAddresses = feedsHaveChangedBlockedAddresses(\n feedsOptions,\n bufferedFeeds,\n blockedAddresses,\n previousBlockedAddresses,\n );\n previousBlockedAddresses = blockedAddresses;\n\n // if changed blocked addresses arent used in the feeds, do nothing\n // NOTE: because of this, if an author address is unblocked, feeds won't update until some other event causes a feed update\n if (!_feedsHaveChangedBlockedAddresses) {\n return;\n }\n\n updateFeeds();\n};\n\nlet previousBlockedCids: string[] = [];\nlet previousAccountsBlockedCids: { [cid: string]: boolean }[] = [];\nconst updateFeedsOnAccountsBlockedCidsChange = (accountsStoreState: any) => {\n const { accounts } = accountsStoreState;\n\n // blocked cids haven't changed, do nothing\n const accountsBlockedCids = [];\n for (const i in accounts) {\n accountsBlockedCids.push(accounts[i].blockedCids);\n }\n if (!accountsBlockedCidsChanged(previousAccountsBlockedCids, accountsBlockedCids)) {\n return;\n }\n previousAccountsBlockedCids = accountsBlockedCids;\n\n const blockedCids = getAccountsBlockedCids(accounts);\n\n // blocked cids haven't changed, do nothing\n if (blockedCids.toString() === previousBlockedCids.toString()) {\n return;\n }\n\n const { feedsOptions, updateFeeds, bufferedFeeds } = feedsStore.getState();\n const _feedsHaveChangedBlockedCids = feedsHaveChangedBlockedCids(\n feedsOptions,\n bufferedFeeds,\n blockedCids,\n previousBlockedCids,\n );\n previousBlockedCids = blockedCids;\n\n // if changed blocked cids arent used in the feeds, do nothing\n // NOTE: because of this, if a cid is unblocked, feeds won't update until some other event causes a feed update\n if (!_feedsHaveChangedBlockedCids) {\n return;\n }\n\n updateFeeds();\n};\n\nlet previousCommunitiesPages: { [pageCid: string]: CommunityPage } = {};\nconst updateFeedsOnFeedsCommunitiesPagesChange = (communitiesPagesStoreState: any) => {\n const { communitiesPages } = communitiesPagesStoreState;\n\n // no changes, do nothing\n if (communitiesPages === previousCommunitiesPages) {\n return;\n }\n previousCommunitiesPages = communitiesPages;\n\n // currently only the feeds use communitiesPagesStore, so any change must\n // trigger a feed update, if in the future another hook uses the communitiesPagesStore\n // we should check if the communities pages changed are actually used by the feeds before\n // triggering an update\n feedsStore.getState().updateFeeds();\n};\n\nlet previousBufferedFeedsCommunitiesPostCountsPageCids: string[] = [];\nlet previousBufferedFeedsCommunities = new Map<string, Community>();\nlet previousBufferedFeedsCommunitiesPostCounts: FeedsCommunitiesPostCounts = {};\nconst addCommunitiesPagesOnLowBufferedFeedsCommunitiesPostCounts = (feedsStoreState: any) => {\n const { bufferedFeedsCommunitiesPostCounts, feedsOptions } = feedsStore.getState();\n const { communities } = communitiesStore.getState();\n\n // if feeds communities have changed, we must try adding them even if buffered posts counts haven't changed\n const bufferedFeedsCommunities = getFeedsCommunities(feedsOptions, communities);\n const _feedsCommunitiesChanged = feedsCommunitiesChanged(\n previousBufferedFeedsCommunities,\n bufferedFeedsCommunities,\n );\n const bufferedFeedsCommunitiesPostCountsChanged =\n previousBufferedFeedsCommunitiesPostCounts !== bufferedFeedsCommunitiesPostCounts;\n\n // if feeds communities havent changed and buffered posts counts also havent changed, do nothing\n if (!_feedsCommunitiesChanged && !bufferedFeedsCommunitiesPostCountsChanged) {\n return;\n }\n previousBufferedFeedsCommunities = bufferedFeedsCommunities;\n previousBufferedFeedsCommunitiesPostCounts = bufferedFeedsCommunitiesPostCounts;\n\n // in case feeds community changed, but the first page cids haven't\n const bufferedFeedsCommunitiesPostCountsPageCids =\n getFeedsCommunitiesFirstPageCids(bufferedFeedsCommunities);\n const bufferedFeedsCommunitiesPostCountsPageCidsChanged =\n bufferedFeedsCommunitiesPostCountsPageCids.toString() !==\n previousBufferedFeedsCommunitiesPostCountsPageCids.toString();\n if (\n !bufferedFeedsCommunitiesPostCountsPageCidsChanged &&\n !bufferedFeedsCommunitiesPostCountsChanged\n ) {\n return;\n }\n previousBufferedFeedsCommunitiesPostCountsPageCids = bufferedFeedsCommunitiesPostCountsPageCids;\n\n const { addNextCommunityPageToStore } = communitiesPagesStore.getState();\n const { accounts } = accountsStore.getState();\n\n // bufferedFeedsCommunitiesPostCounts have changed, check if any of them are low\n for (const feedName in bufferedFeedsCommunitiesPostCounts) {\n const account = accounts[feedsOptions[feedName].accountId];\n const communitiesPostCounts = bufferedFeedsCommunitiesPostCounts[feedName];\n const { sortType, modQueue } = feedsOptions[feedName];\n for (const communityAddress in communitiesPostCounts) {\n // don't fetch more pages if community address is blocked\n if (account?.blockedAddresses[communityAddress]) {\n continue;\n }\n\n // community hasn't loaded yet\n if (!communities[communityAddress]) {\n continue;\n }\n\n // if community posts cache is expired, don't use, wait for next community update\n if (communityPostsCacheExpired(communities[communityAddress])) {\n continue;\n }\n\n // community post count is low, fetch next community page\n if (communitiesPostCounts[communityAddress] <= communityPostsLeftBeforeNextPage) {\n addNextCommunityPageToStore(\n communities[communityAddress],\n sortType,\n account,\n modQueue,\n ).catch((error: unknown) =>\n log.error(\"feedsStore communitiesActions.addNextCommunityPageToStore error\", {\n communityAddress,\n community: communities[communityAddress],\n sortType,\n error,\n }),\n );\n }\n }\n }\n};\n\nlet previousFeedsCommunitiesFirstPageCids: string[] = [];\nlet previousFeedsCommunities: Map<string, Community> = new Map();\nlet previousFeedsCommunitiesLoadedCount = 0;\nlet previousFeedsCommunitiesPostsPagesFirstUpdatedAts = \"\";\nconst updateFeedsOnFeedsCommunitiesChange = (communitiesStoreState: any) => {\n const { communities } = communitiesStoreState;\n const { feedsOptions, updateFeeds } = feedsStore.getState();\n\n // feeds communities haven't changed, do nothing\n const feedsCommunities = getFeedsCommunities(feedsOptions, communities);\n if (!feedsCommunitiesChanged(previousFeedsCommunities, feedsCommunities)) {\n return;\n }\n previousFeedsCommunities = feedsCommunities;\n\n // decide if feeds communities have changed by looking at all feeds communities page cids\n // (in case that a community changed, but its first page cid didn't)\n const feedsCommunitiesFirstPageCids = getFeedsCommunitiesFirstPageCids(feedsCommunities);\n\n // first page cids haven't changed, do nothing\n if (\n feedsCommunitiesFirstPageCids.toString() === previousFeedsCommunitiesFirstPageCids.toString()\n ) {\n // if no new feed communities have loaded, do nothing\n // in case a sub loads with no first page cid and first pages cids don't change, need to trigger hasMore update\n const feedsCommunitiesLoadedCount = getFeedsCommunitiesLoadedCount(feedsCommunities);\n if (feedsCommunitiesLoadedCount === previousFeedsCommunitiesLoadedCount) {\n // if community.posts.pages haven't changed, do nothing\n const feedsCommunitiesPostsPagesFirstUpdatedAts =\n getFeedsCommunitiesPostsPagesFirstUpdatedAts(feedsCommunities);\n if (\n feedsCommunitiesPostsPagesFirstUpdatedAts ===\n previousFeedsCommunitiesPostsPagesFirstUpdatedAts\n ) {\n return;\n }\n\n previousFeedsCommunitiesPostsPagesFirstUpdatedAts = feedsCommunitiesPostsPagesFirstUpdatedAts;\n }\n previousFeedsCommunitiesLoadedCount = feedsCommunitiesLoadedCount;\n }\n\n // feeds communities have changed, update feeds\n previousFeedsCommunitiesFirstPageCids = feedsCommunitiesFirstPageCids;\n updateFeeds();\n};\n\nlet previousAccountsCommentsCount = 0;\nlet previousAccountsCommentsCids = \"\";\nconst updateFeedsOnAccountsCommentsChange = (accountsStoreState: any) => {\n const { accountsComments } = accountsStoreState;\n const accountsCommentsCount = Object.values(accountsComments as Comment[][]).reduce(\n (count, accountComments) => count + accountComments.length,\n 0,\n );\n\n // no changes, do nothing\n if (accountsCommentsCount === previousAccountsCommentsCount) {\n // if cids haven't changed (account comments receive cids after pending), do nothing\n const accountsCommentsCids = Object.values(accountsComments as Comment[][]).reduce(\n (cids, accountComments) => cids + String(accountComments.map((comment) => comment.cid || \"\")),\n \"\",\n );\n if (accountsCommentsCids === previousAccountsCommentsCids) {\n return;\n }\n previousAccountsCommentsCids = accountsCommentsCids;\n }\n previousAccountsCommentsCount = accountsCommentsCount;\n\n // TODO: only update the feeds that are relevant to the new accountComment.parentCid/postCid\n feedsStore.getState().updateFeeds();\n};\n\nconst addCommunitiesToCommunitiesStore = (\n communityRefs: CommunityLookupRef[],\n account: Account,\n) => {\n const addCommunityToStore = communitiesStore.getState().addCommunityToStore;\n for (const communityRef of communityRefs) {\n addCommunityToStore(communityRef, account).catch((error: unknown) =>\n log.error(\"feedsStore communitiesActions.addCommunityToStore error\", {\n communityRef,\n error,\n }),\n );\n }\n};\n\n// reset store in between tests\nconst originalState = feedsStore.getState();\n// async function because some stores have async init\nexport const resetFeedsStore = async () => {\n previousBufferedFeedsCommunitiesPostCounts = {};\n previousBufferedFeedsCommunitiesPostCountsPageCids = [];\n previousBufferedFeedsCommunities = new Map();\n previousBlockedAddresses = [];\n previousAccountsBlockedAddresses = [];\n previousBlockedCids = [];\n previousAccountsBlockedCids = [];\n previousFeedsCommunitiesFirstPageCids = [];\n previousFeedsCommunities = new Map();\n previousFeedsCommunitiesLoadedCount = 0;\n previousFeedsCommunitiesPostsPagesFirstUpdatedAts = \"\";\n previousCommunitiesPages = {};\n previousAccountsCommentsCount = 0;\n previousAccountsCommentsCids = \"\";\n updateFeedsPending = false;\n updateFeedsAgain = false;\n // destroy all component subscriptions to the store\n feedsStore.destroy();\n // restore original state\n feedsStore.setState(originalState);\n feedsStoreInitialized = false;\n};\n\n// reset database and store in between tests\nexport const resetFeedsDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-communitiesPages\" }).clear();\n await resetFeedsStore();\n};\n\nexport default feedsStore;\n"]}
1
+ {"version":3,"file":"feeds-store.js","sourceRoot":"","sources":["../../../src/stores/feeds/feeds-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,oCAAoC,CAAC,CAAC;AAczD,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAsB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,aAAa,MAAM,aAAa,CAAC;AACxC,OAAO,gBAA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AAC;IACrC,mCAAmC,GAAG,CAAC,CAAC;IACxC,iDAAiD,GAAG,EAAE,CAAC;IACvD,wBAAwB,GAAG,EAAE,CAAC;IAC9B,6BAA6B,GAAG,CAAC,CAAC;IAClC,4BAA4B,GAAG,EAAE,CAAC;IAClC,kBAAkB,GAAG,KAAK,CAAC;IAC3B,gBAAgB,GAAG,KAAK,CAAC;IACzB,mDAAmD;IACnD,UAAU,CAAC,OAAO,EAAE,CAAC;IACrB,yBAAyB;IACzB,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACnC,qBAAqB,GAAG,KAAK,CAAC;AAChC,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAS,EAAE;IACnD,MAAM,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,sCAAsC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IAC9F,MAAM,eAAe,EAAE,CAAC;AAC1B,CAAC,CAAA,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import assert from \"assert\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:feeds:stores\");\nimport {\n Feed,\n Feeds,\n Community,\n Communities,\n Account,\n FeedsOptions,\n CommunityPage,\n FeedsCommunitiesPostCounts,\n CommentsFilter,\n FeedOptionsAccountComments,\n Comment,\n} from \"../../types\";\nimport createStore from \"zustand\";\nimport localForageLru from \"../../lib/localforage-lru\";\nimport { communityPostsCacheExpired } from \"../../lib/utils\";\nimport { getPkcGetCommunity } from \"../../lib/pkc-compat\";\nimport { CommunityLookupRef, getCommunityRefKeys } from \"../../lib/community-ref\";\nimport accountsStore from \"../accounts\";\nimport communitiesStore from \"../communities\";\nimport communitiesPagesStore from \"../communities-pages\";\nimport {\n getFeedsCommunitiesFirstPageCids,\n getLoadedFeeds,\n getUpdatedFeeds,\n getBufferedFeedsWithoutLoadedFeeds,\n getFeedsCommunitiesPostCounts,\n getFeedsHaveMore,\n getAccountsBlockedAddresses,\n feedsHaveChangedBlockedAddresses,\n accountsBlockedAddressesChanged,\n getAccountsBlockedCids,\n feedsHaveChangedBlockedCids,\n accountsBlockedCidsChanged,\n feedsCommunitiesChanged,\n getFeedsCommunities,\n getFeedsCommunitiesLoadedCount,\n getFeedsCommunitiesPostsPagesFirstUpdatedAts,\n getFilteredSortedFeeds,\n getFeedsCommunityKeysWithNewerPosts,\n} from \"./utils\";\n\n// reddit loads approximately 25 posts per page\n// while infinite scrolling\nexport const defaultPostsPerPage = 25;\n\n// keep large buffer because fetching cids is slow\nconst communityPostsLeftBeforeNextPage = 50;\n\ntype FeedsState = {\n feedsOptions: FeedsOptions;\n bufferedFeeds: Feeds;\n loadedFeeds: Feeds;\n updatedFeeds: Feeds;\n bufferedFeedsCommunitiesPostCounts: FeedsCommunitiesPostCounts;\n feedsHaveMore: { [feedName: string]: boolean };\n feedsCommunityKeysWithNewerPosts: { [feedName: string]: string[] };\n addFeedToStore: Function;\n incrementFeedPageNumber: Function;\n expandFeedTimeWindow: Function;\n resetFeed: Function;\n updateFeeds: Function;\n};\n\n// don't updateFeeds more than once per updateFeedsMinIntervalTime\nlet updateFeedsPending = false;\nlet updateFeedsAgain = false;\nconst updateFeedsMinIntervalTime = 100;\n\nconst feedsStore = createStore<FeedsState>((setState: Function, getState: Function) => ({\n feedsOptions: {},\n bufferedFeeds: {},\n loadedFeeds: {},\n updatedFeeds: {},\n bufferedFeedsCommunitiesPostCounts: {},\n feedsHaveMore: {},\n feedsCommunityKeysWithNewerPosts: {},\n\n async addFeedToStore(\n feedName: string,\n communities: CommunityLookupRef[],\n communityKeys: string[],\n sortType: string | undefined,\n account: Account,\n isBufferedFeed?: boolean,\n postsPerPage?: number,\n filter?: CommentsFilter,\n newerThan?: number,\n accountComments?: FeedOptionsAccountComments,\n modQueue?: string[],\n ) {\n // init here because must be called after async accounts store finished initializing\n initializeFeedsStore();\n\n assert(\n feedName && typeof feedName === \"string\",\n `feedsStore.addFeedToStore feedName '${feedName}' invalid`,\n );\n assert(\n Array.isArray(communities),\n `addFeedToStore.addFeedToStore communities '${communities}' invalid`,\n );\n assert(\n Array.isArray(communityKeys),\n `addFeedToStore.addFeedToStore communityKeys '${communityKeys}' invalid`,\n );\n const derivedCommunityKeys = getCommunityRefKeys(communities);\n assert(\n communityKeys.length === derivedCommunityKeys.length &&\n communityKeys.every((communityKey, index) => communityKey === derivedCommunityKeys[index]),\n `addFeedToStore.addFeedToStore communityKeys '${communityKeys}' do not match communities`,\n );\n assert(\n sortType === undefined || (typeof sortType === \"string\" && sortType.length > 0),\n `addFeedToStore.addFeedToStore sortType '${sortType}' invalid`,\n );\n assert(\n typeof getPkcGetCommunity(account?.pkc) === \"function\",\n `addFeedToStore.addFeedToStore account '${account}' invalid`,\n );\n assert(\n typeof isBufferedFeed === \"boolean\" ||\n isBufferedFeed === undefined ||\n isBufferedFeed === null,\n `addFeedToStore.addFeedToStore isBufferedFeed '${isBufferedFeed}' invalid`,\n );\n assert(\n !filter || typeof filter?.filter === \"function\",\n `addFeedToStore.addFeedToStore filter.filter '${filter?.filter}' invalid`,\n );\n assert(\n !filter || typeof filter?.key === \"string\",\n `addFeedToStore.addFeedToStore filter.key '${filter?.key}' invalid`,\n );\n assert(\n !newerThan || typeof newerThan === \"number\",\n `addFeedToStore.addFeedToStore newerThan '${newerThan}' invalid`,\n );\n postsPerPage = postsPerPage || defaultPostsPerPage;\n assert(\n typeof postsPerPage === \"number\",\n `addFeedToStore.addFeedToStore postsPerPage '${postsPerPage}' invalid`,\n );\n assert(\n !accountComments || typeof accountComments?.newerThan === \"number\",\n `addFeedToStore.addFeedToStore accountComments.newerThan '${accountComments?.newerThan}' invalid`,\n );\n assert(\n !modQueue || Array.isArray(modQueue),\n `addFeedToStore.addFeedToStore modQueue '${modQueue}' invalid`,\n );\n\n const { feedsOptions, updateFeeds } = getState();\n // feed is in store already, do nothing\n // if the feed already exist but is at page 0, reset it to page 1\n if (feedsOptions[feedName] && feedsOptions[feedName].pageNumber !== 0) {\n return;\n }\n // to add a buffered feed, add a feed with pageNumber 0\n const feedOptions = {\n communities,\n communityKeys,\n sortType,\n accountId: account.id,\n pageNumber: isBufferedFeed === true ? 0 : 1,\n postsPerPage,\n newerThan,\n filter,\n accountComments,\n // TODO: allow multiple modQueue at once, fow now only use first in array\n modQueue,\n };\n log(\"feedsActions.addFeedToStore\", feedOptions);\n setState(({ feedsOptions }: any) => ({\n feedsOptions: { ...feedsOptions, [feedName]: feedOptions },\n }));\n\n addCommunitiesToCommunitiesStore(communities, account);\n\n // update feeds right away to use the already loaded communities and pages\n // if no new communities are added by the feed, like for a sort type change,\n // a feed update will never be triggered, so must be triggered it manually\n updateFeeds();\n },\n\n incrementFeedPageNumber(feedName: string) {\n const { feedsOptions, loadedFeeds, updateFeeds } = getState();\n assert(\n feedsOptions[feedName],\n `feedsActions.incrementFeedPageNumber feed name '${feedName}' does not exist in feeds store`,\n );\n log(\"feedsActions.incrementFeedPageNumber\", { feedName });\n\n assert(\n feedsOptions[feedName].pageNumber * feedsOptions[feedName].postsPerPage <=\n loadedFeeds[feedName].length,\n `feedsActions.incrementFeedPageNumber cannot increment feed page number before current page has loaded`,\n );\n setState(({ feedsOptions, loadedFeeds }: any) => {\n const feedOptions = {\n ...feedsOptions[feedName],\n pageNumber: feedsOptions[feedName].pageNumber + 1,\n };\n return { feedsOptions: { ...feedsOptions, [feedName]: feedOptions } };\n });\n\n // do not update feed at the same time as increment a page number or it might cause\n // a race condition, rather schedule a feed update\n updateFeeds();\n },\n\n expandFeedTimeWindow(feedName: string, newerThan?: number) {\n const { feedsOptions, loadedFeeds, updateFeeds } = getState();\n assert(\n feedsOptions[feedName],\n `feedsActions.expandFeedTimeWindow feed name '${feedName}' does not exist in feeds store`,\n );\n assert(\n newerThan === undefined || typeof newerThan === \"number\",\n `feedsActions.expandFeedTimeWindow newerThan '${newerThan}' invalid`,\n );\n\n const currentFeedOptions = feedsOptions[feedName];\n const currentNewerThan = currentFeedOptions.newerThan;\n\n if (currentNewerThan === newerThan) {\n return;\n }\n\n const isExpandedTimeWindow =\n typeof currentNewerThan === \"number\" &&\n (newerThan === undefined || newerThan > currentNewerThan);\n assert(\n isExpandedTimeWindow,\n `feedsActions.expandFeedTimeWindow newerThan '${newerThan}' must broaden the current window '${currentNewerThan}'`,\n );\n\n const loadedFeed = loadedFeeds[feedName] || [];\n const shouldPrefetchExpandedPage =\n currentFeedOptions.pageNumber > 0 &&\n loadedFeed.length >= currentFeedOptions.pageNumber * currentFeedOptions.postsPerPage;\n\n setState(({ feedsOptions }: any) => ({\n feedsOptions: {\n ...feedsOptions,\n [feedName]: {\n ...currentFeedOptions,\n newerThan,\n pageNumber: shouldPrefetchExpandedPage\n ? currentFeedOptions.pageNumber + 1\n : currentFeedOptions.pageNumber,\n },\n },\n }));\n\n updateFeeds();\n },\n\n async resetFeed(feedName: string) {\n const { feedsOptions, updateFeeds } = getState();\n assert(\n feedsOptions[feedName],\n `feedsActions.resetFeed feed name '${feedName}' does not exist in feeds store`,\n );\n assert(\n feedsOptions[feedName].pageNumber >= 1,\n `feedsActions.resetFeed cannot reset feed page number '${feedsOptions[feedName].pageNumber}' lower than 1`,\n );\n log(\"feedsActions.resetFeed\", { feedName });\n\n const { modQueue, sortType, communities, communityKeys, accountId } = feedsOptions[feedName];\n const account = accountsStore.getState().accounts[accountId];\n assert(\n account,\n `feedsActions.resetFeed account id '${accountId}' does not exist in accounts store`,\n );\n\n setState(({ feedsOptions, loadedFeeds, updatedFeeds }: any) => {\n const feedOptions = {\n ...feedsOptions[feedName],\n pageNumber: 1,\n };\n return {\n feedsOptions: { ...feedsOptions, [feedName]: feedOptions },\n loadedFeeds: { ...loadedFeeds, [feedName]: [] },\n updatedFeeds: { ...updatedFeeds, [feedName]: [] },\n };\n });\n\n if (modQueue?.[0]) {\n const { communities } = communitiesStore.getState();\n const { invalidateCommunityPages } = communitiesPagesStore.getState();\n const loadedCommunities = communityKeys\n .map((communityKey: string) => communities[communityKey])\n .filter((community: Community | undefined): community is Community => Boolean(community));\n await Promise.all(\n loadedCommunities.map((community: Community) =>\n invalidateCommunityPages(community, sortType, modQueue, account.id),\n ),\n );\n }\n\n await Promise.all(\n communities.map((communityRef: CommunityLookupRef, communityIndex: number) =>\n communitiesStore\n .getState()\n .refreshCommunity(communityRef, account)\n .catch((error: unknown) =>\n log.error(\"feedsStore.resetFeed refreshCommunity error\", {\n feedName,\n community: communityRef,\n communityKey: communityKeys[communityIndex],\n error,\n }),\n ),\n ),\n );\n\n updateFeeds();\n },\n\n // recalculate all feeds using new communities.post.pages, communitiesPagesStore and page numbers\n updateFeeds() {\n if (updateFeedsPending) {\n updateFeedsAgain = true;\n return;\n }\n updateFeedsPending = true;\n\n // don't update feeds more than once per updateFeedsMinIntervalTime\n const timeUntilNextUpdate = Date.now() % updateFeedsMinIntervalTime;\n\n setTimeout(async () => {\n // get state from all stores\n const previousState = getState();\n const { feedsOptions, updateFeeds } = previousState;\n const { communities } = communitiesStore.getState();\n const { communitiesPages } = communitiesPagesStore.getState();\n const { accounts } = accountsStore.getState();\n\n // calculate new feeds\n const filteredSortedFeeds = getFilteredSortedFeeds(\n feedsOptions,\n communities,\n communitiesPages,\n accounts,\n communitiesPagesStore.getState().comments,\n );\n const bufferedFeedsWithoutPreviousLoadedFeeds = getBufferedFeedsWithoutLoadedFeeds(\n filteredSortedFeeds,\n previousState.loadedFeeds,\n );\n const loadedFeeds = await getLoadedFeeds(\n feedsOptions,\n filteredSortedFeeds,\n previousState.loadedFeeds,\n bufferedFeedsWithoutPreviousLoadedFeeds,\n accounts,\n );\n // after loaded feeds are caculated, remove new loaded feeds (again) from buffered feeds\n const bufferedFeeds = getBufferedFeedsWithoutLoadedFeeds(\n bufferedFeedsWithoutPreviousLoadedFeeds,\n loadedFeeds,\n );\n const bufferedFeedsCommunitiesPostCounts = getFeedsCommunitiesPostCounts(\n feedsOptions,\n bufferedFeeds,\n );\n const feedsHaveMore = getFeedsHaveMore(\n feedsOptions,\n bufferedFeeds,\n communities,\n communitiesPages,\n accounts,\n );\n const feedsCommunityKeysWithNewerPosts = getFeedsCommunityKeysWithNewerPosts(\n feedsOptions,\n filteredSortedFeeds,\n loadedFeeds,\n previousState.feedsCommunityKeysWithNewerPosts,\n );\n const updatedFeeds = await getUpdatedFeeds(\n feedsOptions,\n filteredSortedFeeds,\n previousState.updatedFeeds,\n loadedFeeds,\n accounts,\n );\n\n // set new feeds\n setState((state: any) => ({\n bufferedFeeds,\n loadedFeeds,\n updatedFeeds,\n bufferedFeedsCommunitiesPostCounts,\n feedsHaveMore,\n feedsCommunityKeysWithNewerPosts,\n }));\n log.trace(\"feedsStore.updateFeeds\", {\n feedsOptions,\n bufferedFeeds,\n loadedFeeds,\n updatedFeeds,\n bufferedFeedsCommunitiesPostCounts,\n feedsHaveMore,\n communities,\n communitiesPages,\n feedsCommunityKeysWithNewerPosts,\n });\n\n updateFeedsPending = false;\n\n // If a community/page update arrived during this calculation, run one\n // more pass so feedsHaveMore and loadedFeeds cannot stay on stale input.\n if (updateFeedsAgain) {\n updateFeedsAgain = false;\n updateFeeds();\n }\n }, timeUntilNextUpdate);\n },\n}));\n\nlet feedsStoreInitialized = false;\nconst initializeFeedsStore = async () => {\n if (feedsStoreInitialized) {\n return;\n }\n // TODO: optimize subscriptions e.g. updateFeedsOnFeedsCommunitiesChange(communities)\n // subscribe to communities store changes\n communitiesStore.subscribe(updateFeedsOnFeedsCommunitiesChange);\n // subscribe to bufferedFeedsCommunitiesPostCounts change\n feedsStore.subscribe(addCommunitiesPagesOnLowBufferedFeedsCommunitiesPostCounts);\n // subscribe to communities pages store changes\n communitiesPagesStore.subscribe(updateFeedsOnFeedsCommunitiesPagesChange);\n // subscribe to accounts store change (for blocked addresses)\n accountsStore.subscribe(updateFeedsOnAccountsBlockedAddressesChange);\n // subscribe to accounts store change (for blocked cids)\n accountsStore.subscribe(updateFeedsOnAccountsBlockedCidsChange);\n // subscribe to accounts store changes (for account comments)\n accountsStore.subscribe(updateFeedsOnAccountsCommentsChange);\n feedsStoreInitialized = true;\n};\n\nlet previousBlockedAddresses: string[] = [];\nlet previousAccountsBlockedAddresses: { [address: string]: boolean }[] = [];\nconst updateFeedsOnAccountsBlockedAddressesChange = (accountsStoreState: any) => {\n const { accounts } = accountsStoreState;\n\n // blocked addresses haven't changed, do nothing\n const accountsBlockedAddresses = [];\n for (const i in accounts) {\n accountsBlockedAddresses.push(accounts[i].blockedAddresses);\n }\n if (\n !accountsBlockedAddressesChanged(previousAccountsBlockedAddresses, accountsBlockedAddresses)\n ) {\n return;\n }\n previousAccountsBlockedAddresses = accountsBlockedAddresses;\n\n const blockedAddresses = getAccountsBlockedAddresses(accounts);\n\n // blocked addresses haven't changed, do nothing\n if (blockedAddresses.toString() === previousBlockedAddresses.toString()) {\n return;\n }\n\n const { feedsOptions, updateFeeds, bufferedFeeds } = feedsStore.getState();\n const _feedsHaveChangedBlockedAddresses = feedsHaveChangedBlockedAddresses(\n feedsOptions,\n bufferedFeeds,\n blockedAddresses,\n previousBlockedAddresses,\n );\n previousBlockedAddresses = blockedAddresses;\n\n // if changed blocked addresses arent used in the feeds, do nothing\n // NOTE: because of this, if an author address is unblocked, feeds won't update until some other event causes a feed update\n if (!_feedsHaveChangedBlockedAddresses) {\n return;\n }\n\n updateFeeds();\n};\n\nlet previousBlockedCids: string[] = [];\nlet previousAccountsBlockedCids: { [cid: string]: boolean }[] = [];\nconst updateFeedsOnAccountsBlockedCidsChange = (accountsStoreState: any) => {\n const { accounts } = accountsStoreState;\n\n // blocked cids haven't changed, do nothing\n const accountsBlockedCids = [];\n for (const i in accounts) {\n accountsBlockedCids.push(accounts[i].blockedCids);\n }\n if (!accountsBlockedCidsChanged(previousAccountsBlockedCids, accountsBlockedCids)) {\n return;\n }\n previousAccountsBlockedCids = accountsBlockedCids;\n\n const blockedCids = getAccountsBlockedCids(accounts);\n\n // blocked cids haven't changed, do nothing\n if (blockedCids.toString() === previousBlockedCids.toString()) {\n return;\n }\n\n const { feedsOptions, updateFeeds, bufferedFeeds } = feedsStore.getState();\n const _feedsHaveChangedBlockedCids = feedsHaveChangedBlockedCids(\n feedsOptions,\n bufferedFeeds,\n blockedCids,\n previousBlockedCids,\n );\n previousBlockedCids = blockedCids;\n\n // if changed blocked cids arent used in the feeds, do nothing\n // NOTE: because of this, if a cid is unblocked, feeds won't update until some other event causes a feed update\n if (!_feedsHaveChangedBlockedCids) {\n return;\n }\n\n updateFeeds();\n};\n\nlet previousCommunitiesPages: { [pageCid: string]: CommunityPage } = {};\nconst updateFeedsOnFeedsCommunitiesPagesChange = (communitiesPagesStoreState: any) => {\n const { communitiesPages } = communitiesPagesStoreState;\n\n // no changes, do nothing\n if (communitiesPages === previousCommunitiesPages) {\n return;\n }\n previousCommunitiesPages = communitiesPages;\n\n // currently only the feeds use communitiesPagesStore, so any change must\n // trigger a feed update, if in the future another hook uses the communitiesPagesStore\n // we should check if the communities pages changed are actually used by the feeds before\n // triggering an update\n feedsStore.getState().updateFeeds();\n};\n\nlet previousBufferedFeedsCommunitiesPostCountsPageCids: string[] = [];\nlet previousBufferedFeedsCommunities = new Map<string, Community>();\nlet previousBufferedFeedsCommunitiesPostCounts: FeedsCommunitiesPostCounts = {};\nconst addCommunitiesPagesOnLowBufferedFeedsCommunitiesPostCounts = (feedsStoreState: any) => {\n const { bufferedFeedsCommunitiesPostCounts, feedsOptions } = feedsStore.getState();\n const { communities } = communitiesStore.getState();\n\n // if feeds communities have changed, we must try adding them even if buffered posts counts haven't changed\n const bufferedFeedsCommunities = getFeedsCommunities(feedsOptions, communities);\n const _feedsCommunitiesChanged = feedsCommunitiesChanged(\n previousBufferedFeedsCommunities,\n bufferedFeedsCommunities,\n );\n const bufferedFeedsCommunitiesPostCountsChanged =\n previousBufferedFeedsCommunitiesPostCounts !== bufferedFeedsCommunitiesPostCounts;\n\n // if feeds communities havent changed and buffered posts counts also havent changed, do nothing\n if (!_feedsCommunitiesChanged && !bufferedFeedsCommunitiesPostCountsChanged) {\n return;\n }\n previousBufferedFeedsCommunities = bufferedFeedsCommunities;\n previousBufferedFeedsCommunitiesPostCounts = bufferedFeedsCommunitiesPostCounts;\n\n // in case feeds community changed, but the first page cids haven't\n const bufferedFeedsCommunitiesPostCountsPageCids =\n getFeedsCommunitiesFirstPageCids(bufferedFeedsCommunities);\n const bufferedFeedsCommunitiesPostCountsPageCidsChanged =\n bufferedFeedsCommunitiesPostCountsPageCids.toString() !==\n previousBufferedFeedsCommunitiesPostCountsPageCids.toString();\n if (\n !bufferedFeedsCommunitiesPostCountsPageCidsChanged &&\n !bufferedFeedsCommunitiesPostCountsChanged\n ) {\n return;\n }\n previousBufferedFeedsCommunitiesPostCountsPageCids = bufferedFeedsCommunitiesPostCountsPageCids;\n\n const { addNextCommunityPageToStore } = communitiesPagesStore.getState();\n const { accounts } = accountsStore.getState();\n\n // bufferedFeedsCommunitiesPostCounts have changed, check if any of them are low\n for (const feedName in bufferedFeedsCommunitiesPostCounts) {\n const account = accounts[feedsOptions[feedName].accountId];\n const communitiesPostCounts = bufferedFeedsCommunitiesPostCounts[feedName];\n const { sortType, modQueue } = feedsOptions[feedName];\n for (const communityAddress in communitiesPostCounts) {\n // don't fetch more pages if community address is blocked\n if (account?.blockedAddresses[communityAddress]) {\n continue;\n }\n\n // community hasn't loaded yet\n if (!communities[communityAddress]) {\n continue;\n }\n\n // if community posts cache is expired, don't use, wait for next community update\n if (communityPostsCacheExpired(communities[communityAddress])) {\n continue;\n }\n\n // community post count is low, fetch next community page\n if (communitiesPostCounts[communityAddress] <= communityPostsLeftBeforeNextPage) {\n addNextCommunityPageToStore(\n communities[communityAddress],\n sortType,\n account,\n modQueue,\n ).catch((error: unknown) =>\n log.error(\"feedsStore communitiesActions.addNextCommunityPageToStore error\", {\n communityAddress,\n community: communities[communityAddress],\n sortType,\n error,\n }),\n );\n }\n }\n }\n};\n\nlet previousFeedsCommunitiesFirstPageCids: string[] = [];\nlet previousFeedsCommunities: Map<string, Community> = new Map();\nlet previousFeedsCommunitiesLoadedCount = 0;\nlet previousFeedsCommunitiesPostsPagesFirstUpdatedAts = \"\";\nconst updateFeedsOnFeedsCommunitiesChange = (communitiesStoreState: any) => {\n const { communities } = communitiesStoreState;\n const { feedsOptions, updateFeeds } = feedsStore.getState();\n\n // feeds communities haven't changed, do nothing\n const feedsCommunities = getFeedsCommunities(feedsOptions, communities);\n if (!feedsCommunitiesChanged(previousFeedsCommunities, feedsCommunities)) {\n return;\n }\n previousFeedsCommunities = feedsCommunities;\n\n // decide if feeds communities have changed by looking at all feeds communities page cids\n // (in case that a community changed, but its first page cid didn't)\n const feedsCommunitiesFirstPageCids = getFeedsCommunitiesFirstPageCids(feedsCommunities);\n\n // first page cids haven't changed, do nothing\n if (\n feedsCommunitiesFirstPageCids.toString() === previousFeedsCommunitiesFirstPageCids.toString()\n ) {\n // if no new feed communities have loaded, do nothing\n // in case a sub loads with no first page cid and first pages cids don't change, need to trigger hasMore update\n const feedsCommunitiesLoadedCount = getFeedsCommunitiesLoadedCount(feedsCommunities);\n if (feedsCommunitiesLoadedCount === previousFeedsCommunitiesLoadedCount) {\n // if community.posts.pages haven't changed, do nothing\n const feedsCommunitiesPostsPagesFirstUpdatedAts =\n getFeedsCommunitiesPostsPagesFirstUpdatedAts(feedsCommunities);\n if (\n feedsCommunitiesPostsPagesFirstUpdatedAts ===\n previousFeedsCommunitiesPostsPagesFirstUpdatedAts\n ) {\n return;\n }\n\n previousFeedsCommunitiesPostsPagesFirstUpdatedAts = feedsCommunitiesPostsPagesFirstUpdatedAts;\n }\n previousFeedsCommunitiesLoadedCount = feedsCommunitiesLoadedCount;\n }\n\n // feeds communities have changed, update feeds\n previousFeedsCommunitiesFirstPageCids = feedsCommunitiesFirstPageCids;\n updateFeeds();\n};\n\nlet previousAccountsCommentsCount = 0;\nlet previousAccountsCommentsCids = \"\";\nconst updateFeedsOnAccountsCommentsChange = (accountsStoreState: any) => {\n const { accountsComments } = accountsStoreState;\n const accountsCommentsCount = Object.values(accountsComments as Comment[][]).reduce(\n (count, accountComments) => count + accountComments.length,\n 0,\n );\n\n // no changes, do nothing\n if (accountsCommentsCount === previousAccountsCommentsCount) {\n // if cids haven't changed (account comments receive cids after pending), do nothing\n const accountsCommentsCids = Object.values(accountsComments as Comment[][]).reduce(\n (cids, accountComments) => cids + String(accountComments.map((comment) => comment.cid || \"\")),\n \"\",\n );\n if (accountsCommentsCids === previousAccountsCommentsCids) {\n return;\n }\n previousAccountsCommentsCids = accountsCommentsCids;\n }\n previousAccountsCommentsCount = accountsCommentsCount;\n\n // TODO: only update the feeds that are relevant to the new accountComment.parentCid/postCid\n feedsStore.getState().updateFeeds();\n};\n\nconst addCommunitiesToCommunitiesStore = (\n communityRefs: CommunityLookupRef[],\n account: Account,\n) => {\n const addCommunityToStore = communitiesStore.getState().addCommunityToStore;\n for (const communityRef of communityRefs) {\n addCommunityToStore(communityRef, account).catch((error: unknown) =>\n log.error(\"feedsStore communitiesActions.addCommunityToStore error\", {\n communityRef,\n error,\n }),\n );\n }\n};\n\n// reset store in between tests\nconst originalState = feedsStore.getState();\n// async function because some stores have async init\nexport const resetFeedsStore = async () => {\n previousBufferedFeedsCommunitiesPostCounts = {};\n previousBufferedFeedsCommunitiesPostCountsPageCids = [];\n previousBufferedFeedsCommunities = new Map();\n previousBlockedAddresses = [];\n previousAccountsBlockedAddresses = [];\n previousBlockedCids = [];\n previousAccountsBlockedCids = [];\n previousFeedsCommunitiesFirstPageCids = [];\n previousFeedsCommunities = new Map();\n previousFeedsCommunitiesLoadedCount = 0;\n previousFeedsCommunitiesPostsPagesFirstUpdatedAts = \"\";\n previousCommunitiesPages = {};\n previousAccountsCommentsCount = 0;\n previousAccountsCommentsCids = \"\";\n updateFeedsPending = false;\n updateFeedsAgain = false;\n // destroy all component subscriptions to the store\n feedsStore.destroy();\n // restore original state\n feedsStore.setState(originalState);\n feedsStoreInitialized = false;\n};\n\n// reset database and store in between tests\nexport const resetFeedsDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-communitiesPages\" }).clear();\n await resetFeedsStore();\n};\n\nexport default feedsStore;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/stores/feeds/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EAEP,KAAK,EAEL,YAAY,EACZ,SAAS,EACT,WAAW,EAEX,QAAQ,EAER,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AAoHrB;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,cAAc,YAAY,EAC1B,aAAa,WAAW,EACxB,kBAAkB,gBAAgB,EAClC,UAAU,QAAQ,EAClB,mBAAmB;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,UAmIrD,CAAC;AA0BF,eAAO,MAAM,cAAc,GACzB,cAAc,YAAY,EAC1B,qBAAqB,KAAK,EAC1B,aAAa,KAAK,EAClB,eAAe,KAAK,EACpB,UAAU,QAAQ,mBAyDnB,CAAC;AAcF,eAAO,MAAM,mBAAmB,GAAI,cAAc,YAAY,EAAE,aAAa,KAAK,YAsHjF,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAAI,eAAe,KAAK,EAAE,aAAa,KAAK,UAoC1F,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,cAAc,YAAY,EAC1B,qBAAqB,KAAK,EAC1B,cAAc,KAAK,EACnB,aAAa,KAAK,EAClB,UAAU,QAAQ,mBAoDnB,CAAC;AAIF,eAAO,MAAM,mCAAmC,GAC9C,cAAc,YAAY,EAC1B,qBAAqB,KAAK,EAC1B,aAAa,KAAK,EAClB,0CAA0C;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE;;CAyC3E,CAAC;AAGF,eAAO,MAAM,6BAA6B,GAAI,cAAc,YAAY,EAAE,OAAO,KAAK,+BAsBrF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBA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,EAC7D,qBAAqB;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,YAYtD,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,cAAc,YAAY,EAC1B,eAAe,KAAK,EACpB,aAAa,MAAM,EAAE,EACrB,qBAAqB,MAAM,EAAE,YAoB9B,CAAC"}
@@ -14,6 +14,7 @@ import { communityPostsCacheExpired, commentIsValid, removeInvalidComments } fro
14
14
  import { getCommentCommunityAddress, normalizeCommentCommunityAddress } from "../../lib/pkc-compat.js";
15
15
  import { doesAddressMatchCommunityRef, getCommunityRefKeys, getMatchingCommunityRefKeys, } from "../../lib/community-ref.js";
16
16
  import Logger from "@pkcprotocol/pkc-logger";
17
+ import { resolvePostSortType } from "../../lib/page-sorts.js";
17
18
  const log = Logger("bitsocial-react-hooks:feeds:stores");
18
19
  const getFeedCommunityRefs = (feedOptions) => feedOptions.communities || [];
19
20
  const getFeedCommunityKeys = (feedOptions) => feedOptions.communityKeys || getCommunityRefKeys(getFeedCommunityRefs(feedOptions));
@@ -148,7 +149,10 @@ export const getFilteredSortedFeeds = (feedsOptions, communities, communitiesPag
148
149
  }
149
150
  }
150
151
  // sort the feed before filtering to get more accurate results
151
- const originalSortType = feedsOptions[feedName].sortType;
152
+ const resolvedDefaultSortTypes = communityKeys.map((communityKey) => resolvePostSortType(communities[communityKey], feedsOptions[feedName].sortType));
153
+ const uniqueResolvedDefaultSortTypes = new Set(resolvedDefaultSortTypes);
154
+ const originalSortType = feedsOptions[feedName].sortType ||
155
+ (uniqueResolvedDefaultSortTypes.size === 1 ? resolvedDefaultSortTypes[0] : undefined);
152
156
  const sortedBufferedFeedPosts = feedSorter.sort(originalSortType, bufferedFeedPosts);
153
157
  // filter the feed
154
158
  const filteredSortedBufferedFeedPosts = [];
@@ -173,7 +177,7 @@ export const getFilteredSortedFeeds = (feedsOptions, communities, communitiesPag
173
177
  }
174
178
  // filter posts older than newerThan option
175
179
  if (newerThanTimestamp) {
176
- if (sortType === "active") {
180
+ if (originalSortType === "active") {
177
181
  if ((post.lastReplyTimestamp || post.timestamp) <= newerThanTimestamp) {
178
182
  continue;
179
183
  }
@@ -191,28 +195,12 @@ export const getFilteredSortedFeeds = (feedsOptions, communities, communitiesPag
191
195
  return feeds;
192
196
  };
193
197
  const getPreloadedPosts = (community, sortType) => {
194
- var _a, _b, _c, _d, _e, _f, _g;
195
- let preloadedPosts = (_c = (_b = (_a = community.posts) === null || _a === void 0 ? void 0 : _a.pages) === null || _b === void 0 ? void 0 : _b[sortType]) === null || _c === void 0 ? void 0 : _c.comments;
196
- if (preloadedPosts) {
197
- return preloadedPosts;
198
- }
199
- const hasPageCids = Object.keys(((_d = community.posts) === null || _d === void 0 ? void 0 : _d.pageCids) || {}).length !== 0;
200
- if (hasPageCids) {
201
- return;
202
- }
203
- const pages = Object.values(((_e = community.posts) === null || _e === void 0 ? void 0 : _e.pages) || {});
204
- if (!pages.length) {
205
- return;
206
- }
207
- const nextCids = pages.map((page) => page === null || page === void 0 ? void 0 : page.nextCid).filter((nextCid) => !!nextCid);
208
- if (nextCids.length > 0) {
198
+ var _a, _b, _c;
199
+ const resolvedSortType = resolvePostSortType(community, sortType);
200
+ if (!resolvedSortType) {
209
201
  return;
210
202
  }
211
- // if has a preloaded page, but no pageCids and no nextCids, it means all posts fit in a single preloaded page
212
- // so any sort type can be used, and later be resorted by the client
213
- if ((_g = (_f = pages[0]) === null || _f === void 0 ? void 0 : _f.comments) === null || _g === void 0 ? void 0 : _g.length) {
214
- return pages[0].comments;
215
- }
203
+ return (_c = (_b = (_a = community.posts) === null || _a === void 0 ? void 0 : _a.pages) === null || _b === void 0 ? void 0 : _b[resolvedSortType]) === null || _c === void 0 ? void 0 : _c.comments;
216
204
  };
217
205
  export const getLoadedFeeds = (feedsOptions, filteredSortedFeeds, loadedFeeds, bufferedFeeds, accounts) => __awaiter(void 0, void 0, void 0, function* () {
218
206
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.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A2B,GAAG,CACzC,YAA0B,EAC1B,aAAoB,EACpB,WAAqB,EACrB,mBAA6B,EAC7B,EAAE;IACF,qEAAqE;IACrE,MAAM,kBAAkB,GAAG,WAAW;SACnC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC/C,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvE,8DAA8D;IAC9D,+GAA+G;IAC/G,+FAA+F;IAC/F,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC1D,KAAK,MAAM,QAAQ,IAAI,aAAa,EAAE,CAAC;QACrC,KAAK,MAAM,IAAI,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YACjD,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,KAAI,qBAAqB,CAAC,GAAG,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,EAAE,CAAC;gBACtD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import assert from \"assert\";\nimport {\n Comment,\n Feed,\n Feeds,\n FeedOptions,\n FeedsOptions,\n Community,\n Communities,\n Account,\n Accounts,\n CommunityPage,\n CommunitiesPages,\n FeedsCommunitiesPostCounts,\n} from \"../../types\";\nimport { getCommunityPages, getCommunityFirstPageCid } from \"../communities-pages\";\nimport accountsStore from \"../accounts\";\nimport feedSorter from \"./feed-sorter\";\nimport { communityPostsCacheExpired, commentIsValid, removeInvalidComments } from \"../../lib/utils\";\nimport { getCommentCommunityAddress, normalizeCommentCommunityAddress } from \"../../lib/pkc-compat\";\nimport {\n CommunityLookupRef,\n doesAddressMatchCommunityRef,\n getCommunityRefKeys,\n getMatchingCommunityRefKeys,\n} from \"../../lib/community-ref\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:feeds:stores\");\n\nconst getFeedCommunityRefs = (feedOptions: Partial<FeedOptions>): CommunityLookupRef[] =>\n feedOptions.communities || [];\n\nconst getFeedCommunityKeys = (feedOptions: Partial<FeedOptions>) =>\n feedOptions.communityKeys || getCommunityRefKeys(getFeedCommunityRefs(feedOptions));\n\nconst getCommentFreshness = (comment: Comment | undefined) =>\n Math.max(comment?.updatedAt ?? 0, comment?.timestamp ?? 0, 0);\n\nconst commentMatchesModQueue = (comment: Comment | undefined, modQueue?: string[]) => {\n const modQueueName = modQueue?.[0];\n if (!modQueueName) {\n return true;\n }\n if (modQueueName === \"pendingApproval\") {\n return comment?.pendingApproval === true;\n }\n return true;\n};\n\nconst getFeedPost = (\n post: Comment,\n communityRef: CommunityLookupRef,\n community: Community,\n modQueue?: string[],\n freshestComments?: { [commentCid: string]: Comment },\n) => {\n const normalizedPost = normalizeCommentCommunityAddress(post) as Comment;\n const freshestComment = post.cid\n ? normalizeCommentCommunityAddress(freshestComments?.[post.cid])\n : undefined;\n const postCommunityAddress = getCommentCommunityAddress(normalizedPost);\n if (!doesAddressMatchCommunityRef(postCommunityAddress, communityRef, community)) {\n return;\n }\n if (!commentMatchesModQueue(normalizedPost, modQueue)) {\n return;\n }\n if (\n !freshestComment ||\n getCommentFreshness(freshestComment) <= getCommentFreshness(normalizedPost)\n ) {\n return normalizedPost;\n }\n if (!commentMatchesModQueue(freshestComment, modQueue)) {\n return;\n }\n if (\n !doesAddressMatchCommunityRef(\n getCommentCommunityAddress(freshestComment),\n communityRef,\n community,\n )\n ) {\n return;\n }\n return freshestComment;\n};\n\nconst reconcileLoadedModQueueFeed = (\n feedOptions: FeedOptions,\n loadedFeed: Feed,\n filteredSortedFeed: Feed,\n) => {\n if (!feedOptions?.modQueue?.[0] || !loadedFeed?.length) {\n return loadedFeed;\n }\n\n const filteredSortedFeedByCid = new Map<string, Comment>();\n for (const post of filteredSortedFeed) {\n if (post.cid) {\n filteredSortedFeedByCid.set(post.cid, post);\n }\n }\n\n let changed = false;\n const nextLoadedFeed: Comment[] = [];\n for (const post of loadedFeed) {\n if (!post.cid) {\n nextLoadedFeed.push(post);\n continue;\n }\n\n const sourcePost = filteredSortedFeedByCid.get(post.cid);\n if (!sourcePost) {\n changed = true;\n continue;\n }\n\n if (getCommentFreshness(sourcePost) > getCommentFreshness(post)) {\n nextLoadedFeed.push(sourcePost);\n changed = true;\n continue;\n }\n\n nextLoadedFeed.push(post);\n }\n\n return changed ? nextLoadedFeed : loadedFeed;\n};\n\n/**\n * Calculate the feeds from all the loaded community pages, filter and sort them\n */\nexport const getFilteredSortedFeeds = (\n feedsOptions: FeedsOptions,\n communities: Communities,\n communitiesPages: CommunitiesPages,\n accounts: Accounts,\n freshestComments?: { [commentCid: string]: Comment },\n) => {\n // calculate each feed\n let feeds: Feeds = {};\n for (const feedName in feedsOptions) {\n const communityRefs = getFeedCommunityRefs(feedsOptions[feedName]);\n const communityKeys = getFeedCommunityKeys(feedsOptions[feedName]);\n let { sortType, accountId, filter, newerThan, modQueue } = feedsOptions[feedName];\n const newerThanTimestamp = newerThan ? Math.floor(Date.now() / 1000) - newerThan : undefined;\n\n let pageType = \"posts\";\n if (modQueue?.[0]) {\n // TODO: allow multiple modQueue at once, fow now only use first in array\n sortType = modQueue[0];\n pageType = \"modQueue\";\n }\n\n // find all fetched posts\n const bufferedFeedPosts = [];\n\n // add each comment from each page, do not filter at this stage, filter after sorting\n for (const [communityIndex, communityKey] of communityKeys.entries()) {\n const communityRef = communityRefs[communityIndex];\n // community hasn't loaded yet\n const community = communities[communityKey];\n if (!community || !communityRef) {\n continue;\n }\n\n // if cache is expired and has internet access, don't use, wait for next community update\n if (communityPostsCacheExpired(community) && window.navigator.onLine) {\n continue;\n }\n\n // use community preloaded posts if any\n const preloadedPosts = getPreloadedPosts(community, sortType);\n if (preloadedPosts) {\n for (const post of preloadedPosts) {\n // posts are manually validated, could have fake communityAddress\n if (\n !doesAddressMatchCommunityRef(getCommentCommunityAddress(post), communityRef, community)\n ) {\n break;\n }\n const nextPost = getFeedPost(post, communityRef, community, modQueue, freshestComments);\n if (nextPost) {\n bufferedFeedPosts.push(nextPost);\n }\n }\n }\n\n // add all posts from community pages\n const communityPages = getCommunityPages(\n community,\n sortType,\n communitiesPages,\n pageType,\n accountId,\n );\n for (const communityPage of communityPages) {\n if (communityPage?.comments) {\n for (const post of communityPage.comments) {\n // posts are manually validated, could have fake communityAddress\n if (\n !doesAddressMatchCommunityRef(\n getCommentCommunityAddress(post),\n communityRef,\n community,\n )\n ) {\n break;\n }\n const nextPost = getFeedPost(post, communityRef, community, modQueue, freshestComments);\n if (nextPost) {\n bufferedFeedPosts.push(nextPost);\n }\n }\n }\n }\n }\n\n // sort the feed before filtering to get more accurate results\n const originalSortType = feedsOptions[feedName].sortType;\n const sortedBufferedFeedPosts = feedSorter.sort(originalSortType, bufferedFeedPosts);\n\n // filter the feed\n const filteredSortedBufferedFeedPosts = [];\n for (const post of sortedBufferedFeedPosts) {\n // address is blocked\n if (\n accounts[accountId]?.blockedAddresses[getCommentCommunityAddress(post) || \"\"] ||\n (post.author?.address && accounts[accountId]?.blockedAddresses[post.author.address])\n ) {\n continue;\n }\n\n // comment cid is blocked\n if (accounts[accountId]?.blockedCids[post.cid]) {\n continue;\n }\n\n // if a feed has more than 1 sub, don't include pinned posts\n // TODO: add test to check if pinned are filtered\n if (post.pinned && communityKeys.length > 1) {\n continue;\n }\n\n // feedOptions filter function\n if (filter && !filter.filter(post)) {\n continue;\n }\n\n // filter posts older than newerThan option\n if (newerThanTimestamp) {\n if (sortType === \"active\") {\n if ((post.lastReplyTimestamp || post.timestamp) <= newerThanTimestamp) {\n continue;\n }\n } else {\n if (post.timestamp <= newerThanTimestamp) {\n continue;\n }\n }\n }\n\n filteredSortedBufferedFeedPosts.push(post);\n }\n\n feeds[feedName] = filteredSortedBufferedFeedPosts;\n }\n return feeds;\n};\n\nconst getPreloadedPosts = (community: Community, sortType: string) => {\n let preloadedPosts = community.posts?.pages?.[sortType]?.comments;\n if (preloadedPosts) {\n return preloadedPosts;\n }\n const hasPageCids = Object.keys(community.posts?.pageCids || {}).length !== 0;\n if (hasPageCids) {\n return;\n }\n const pages: any[] = Object.values(community.posts?.pages || {});\n if (!pages.length) {\n return;\n }\n const nextCids = pages.map((page: any) => page?.nextCid).filter((nextCid) => !!nextCid);\n if (nextCids.length > 0) {\n return;\n }\n // if has a preloaded page, but no pageCids and no nextCids, it means all posts fit in a single preloaded page\n // so any sort type can be used, and later be resorted by the client\n if (pages[0]?.comments?.length) {\n return pages[0].comments;\n }\n};\n\nexport const getLoadedFeeds = async (\n feedsOptions: FeedsOptions,\n filteredSortedFeeds: Feeds,\n loadedFeeds: Feeds,\n bufferedFeeds: Feeds,\n accounts: Accounts,\n) => {\n const nextLoadedFeeds: Feeds = { ...loadedFeeds };\n let loadedFeedsChanged = false;\n for (const feedName in feedsOptions) {\n const { pageNumber, postsPerPage, accountId } = feedsOptions[feedName];\n const pkc = accounts[accountId]?.pkc;\n const loadedFeedPostCount = pageNumber * postsPerPage;\n const currentLoadedFeed = reconcileLoadedModQueueFeed(\n feedsOptions[feedName],\n loadedFeeds[feedName] || [],\n filteredSortedFeeds[feedName] || [],\n );\n if (currentLoadedFeed !== loadedFeeds[feedName]) {\n nextLoadedFeeds[feedName] = currentLoadedFeed;\n loadedFeedsChanged = true;\n }\n const missingPostsCount =\n loadedFeedPostCount - currentLoadedFeed.filter((post) => post.index === undefined).length;\n\n // get new posts from buffered feed\n const bufferedFeed = bufferedFeeds[feedName] || [];\n\n let missingPosts: any[] = [];\n for (const post of bufferedFeed) {\n if (missingPosts.length >= missingPostsCount) {\n missingPosts = await removeInvalidComments(missingPosts, { validateReplies: false }, pkc);\n // only stop if there were no invalid comments\n if (missingPosts.length >= missingPostsCount) {\n break;\n }\n }\n missingPosts.push(post);\n }\n\n // the current loaded feed already exist and doesn't need new posts\n if (\n missingPosts.length === 0 &&\n loadedFeeds[feedName] &&\n currentLoadedFeed === loadedFeeds[feedName]\n ) {\n continue;\n }\n nextLoadedFeeds[feedName] = [...currentLoadedFeed, ...missingPosts];\n if (missingPosts.length > 0) {\n loadedFeedsChanged = true;\n }\n }\n\n // add account comments\n const accountCommentsChangedFeeds = addAccountsComments(feedsOptions, nextLoadedFeeds);\n\n // do nothing if there are no missing posts\n if (!loadedFeedsChanged && !accountCommentsChangedFeeds) {\n return loadedFeeds;\n }\n return nextLoadedFeeds;\n};\n\nconst getApprovalPublicationKey = (comment: Comment) =>\n [\n comment.timestamp ?? \"\",\n comment.parentCid ?? \"\",\n comment.postCid ?? \"\",\n getCommentCommunityAddress(comment) ?? \"\",\n comment.author?.address ?? \"\",\n comment.title ?? \"\",\n comment.content ?? \"\",\n comment.link ?? \"\",\n ].join(\"\\0\");\n\nexport const addAccountsComments = (feedsOptions: FeedsOptions, loadedFeeds: Feeds) => {\n let loadedFeedsChanged = false;\n const accountsComments = accountsStore.getState().accountsComments || {};\n for (const feedName in feedsOptions) {\n const { accountId, accountComments: accountCommentsOptions } = feedsOptions[feedName];\n const communityRefs = getFeedCommunityRefs(feedsOptions[feedName]);\n const { newerThan, append } = accountCommentsOptions || {};\n if (!newerThan) {\n continue;\n }\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n const isNewerThan = (post: Comment) => post.timestamp > newerThanTimestamp;\n\n const accountComments = accountsComments[accountId] || [];\n const accountPosts = accountComments.filter((comment) => {\n // is a reply, not a post\n if (comment.parentCid || comment.depth > 0) {\n return false;\n }\n if (!isNewerThan(comment)) {\n return false;\n }\n return (\n getMatchingCommunityRefKeys(communityRefs, getCommentCommunityAddress(comment)).length > 0\n );\n });\n const validAccountIndices = new Set(accountPosts.map((p) => p.index));\n const accountCidToPost = new Map<string, Comment>();\n for (const p of accountPosts) {\n if (p.cid) accountCidToPost.set(p.cid, p);\n }\n\n let loadedFeed = loadedFeeds[feedName] || [];\n const approvedPublicationKeys = new Set(\n loadedFeed\n .filter((post) => post.pendingApproval !== true)\n .map((post) => getApprovalPublicationKey(post)),\n );\n // prune stale local-account entries and replace when cid matches but index changed\n const prunedLoadedFeed: Comment[] = [];\n for (const post of loadedFeed) {\n if (post.index === undefined) {\n prunedLoadedFeed.push(post);\n continue;\n }\n if (\n post.pendingApproval === true &&\n approvedPublicationKeys.has(getApprovalPublicationKey(post))\n ) {\n loadedFeedsChanged = true;\n continue;\n }\n if (!validAccountIndices.has(post.index)) {\n loadedFeedsChanged = true;\n continue;\n }\n if (post.cid) {\n const freshAccountPost = accountCidToPost.get(post.cid);\n if (freshAccountPost && freshAccountPost.index !== post.index) {\n prunedLoadedFeed.push(freshAccountPost);\n loadedFeedsChanged = true;\n continue;\n }\n }\n prunedLoadedFeed.push(post);\n }\n loadedFeed = loadedFeeds[feedName] = prunedLoadedFeed;\n\n if (!accountPosts.length) {\n continue;\n }\n // if a loaded comment doesn't have a cid, then it's pending\n // and pending account comments should always have unique timestamps\n const loadedFeedMap = new Map();\n loadedFeed.forEach((post, loadedFeedIndex) => {\n if (post.cid) loadedFeedMap.set(post.cid, loadedFeedIndex);\n if (typeof post.index === \"number\") loadedFeedMap.set(post.index, loadedFeedIndex);\n if (!post.cid) loadedFeedMap.set(post.timestamp, loadedFeedIndex);\n if (post.pendingApproval !== true) {\n loadedFeedMap.set(getApprovalPublicationKey(post), loadedFeedIndex);\n }\n });\n for (const accountPost of accountPosts) {\n // account post with cid already added\n if (accountPost.cid && loadedFeedMap.has(accountPost.cid)) {\n continue;\n }\n if (\n accountPost.pendingApproval === true &&\n loadedFeedMap.has(getApprovalPublicationKey(accountPost))\n ) {\n continue;\n }\n // account post without cid already added, but now we have the cid\n if (accountPost.cid && loadedFeedMap.has(accountPost.index)) {\n const loadedFeedIndex = loadedFeedMap.get(accountPost.index);\n // update the feed with the accountPost.cid now that we have it\n loadedFeed[loadedFeedIndex] = accountPost;\n loadedFeedsChanged = true;\n continue;\n }\n if (loadedFeedMap.has(accountPost.index)) {\n continue;\n }\n // pending account post without cid already added\n if (!accountPost.cid && loadedFeedMap.has(accountPost.timestamp)) {\n continue;\n }\n if (append) {\n loadedFeed.push(accountPost);\n } else {\n loadedFeed.unshift(accountPost);\n }\n loadedFeedsChanged = true;\n }\n }\n return loadedFeedsChanged;\n};\n\nexport const getBufferedFeedsWithoutLoadedFeeds = (bufferedFeeds: Feeds, loadedFeeds: Feeds) => {\n // contruct a list of posts already loaded to remove them from buffered feeds\n const loadedFeedsPosts: { [key: string]: Set<string> } = {};\n for (const feedName in loadedFeeds) {\n loadedFeedsPosts[feedName] = new Set();\n for (const post of loadedFeeds[feedName]) {\n loadedFeedsPosts[feedName].add(post.cid);\n }\n }\n\n const newBufferedFeeds: Feeds = {};\n for (const feedName in bufferedFeeds) {\n newBufferedFeeds[feedName] = [];\n let bufferedFeedPostChanged = false;\n for (const [i, post] of bufferedFeeds[feedName].entries()) {\n if (loadedFeedsPosts[feedName]?.has(post.cid)) {\n continue;\n }\n newBufferedFeeds[feedName].push(post);\n if (\n !bufferedFeedPostChanged &&\n (newBufferedFeeds[feedName][i]?.cid !== bufferedFeeds[feedName][i]?.cid ||\n (newBufferedFeeds[feedName][i]?.updatedAt || 0) >\n (bufferedFeeds[feedName][i]?.updatedAt || 0))\n ) {\n bufferedFeedPostChanged = true;\n }\n }\n if (\n !bufferedFeedPostChanged &&\n newBufferedFeeds[feedName].length === bufferedFeeds[feedName].length\n ) {\n newBufferedFeeds[feedName] = bufferedFeeds[feedName];\n }\n }\n return newBufferedFeeds;\n};\n\nexport const getUpdatedFeeds = async (\n feedsOptions: FeedsOptions,\n filteredSortedFeeds: Feeds,\n updatedFeeds: Feeds,\n loadedFeeds: Feeds,\n accounts: Accounts,\n) => {\n // contruct a list of posts already loaded to remove them from buffered feeds\n const updatedFeedsPosts: { [feedName: string]: { [postCid: string]: any } } = {};\n for (const feedName in updatedFeeds) {\n updatedFeedsPosts[feedName] = {};\n for (const [index, updatedPost] of updatedFeeds[feedName].entries()) {\n updatedFeedsPosts[feedName][updatedPost.cid] = { index, updatedPost };\n }\n }\n\n const newUpdatedFeeds: Feeds = { ...updatedFeeds };\n for (const feedName in filteredSortedFeeds) {\n const pkc = accounts[feedsOptions[feedName]?.accountId]?.pkc;\n const updatedFeed = [...(updatedFeeds[feedName] || [])];\n const onlyHasNewPosts = updatedFeed.length === 0;\n let updatedFeedChanged = false;\n\n // add new posts from loadedFeed posts\n while (updatedFeed.length < loadedFeeds[feedName].length) {\n updatedFeed[updatedFeed.length] = loadedFeeds[feedName][updatedFeed.length];\n updatedFeedChanged = true;\n }\n\n // add updated post from filteredSortedFeed\n if (!onlyHasNewPosts) {\n const promises = [];\n for (const post of filteredSortedFeeds[feedName]) {\n if (updatedFeedsPosts[feedName]?.[post.cid]) {\n const { index, updatedPost } = updatedFeedsPosts[feedName][post.cid];\n // faster to validate comments async\n promises.push(\n (async () => {\n if (\n (post.updatedAt || 0) > (updatedPost.updatedAt || 0) &&\n (await commentIsValid(post, { validateReplies: false }, pkc))\n ) {\n updatedFeed[index] = post;\n updatedFeedChanged = true;\n }\n })(),\n );\n }\n }\n await Promise.all(promises);\n }\n\n if (updatedFeedChanged) {\n newUpdatedFeeds[feedName] = updatedFeed;\n }\n }\n return newUpdatedFeeds;\n};\n\n// find with communities have posts newer (or ranked higher) than the loaded feeds\n// can be used to display \"new posts in x, y, z subs\" alert, like on twitter\nexport const getFeedsCommunityKeysWithNewerPosts = (\n feedsOptions: FeedsOptions,\n filteredSortedFeeds: Feeds,\n loadedFeeds: Feeds,\n previousFeedsCommunityKeysWithNewerPosts: { [feedName: string]: string[] },\n) => {\n const feedsCommunityKeysWithNewerPosts: { [feedName: string]: string[] } = {};\n for (const feedName in loadedFeeds) {\n const loadedFeed = loadedFeeds[feedName];\n const cidsInLoadedFeed = new Set();\n for (const post of loadedFeed) {\n cidsInLoadedFeed.add(post.cid);\n }\n const communityKeysWithNewerPostsSet = new Set<string>();\n for (const [i, post] of filteredSortedFeeds[feedName].entries()) {\n if (i >= loadedFeed.length) {\n break;\n }\n // if any post in filteredSortedFeeds ranks higher than the loaded feed count, it's a newer post\n if (!cidsInLoadedFeed.has(post.cid)) {\n const postCommunityAddress = getCommentCommunityAddress(post);\n if (postCommunityAddress) {\n getMatchingCommunityRefKeys(\n getFeedCommunityRefs(feedsOptions[feedName] || {}),\n postCommunityAddress,\n ).forEach((communityKey) => communityKeysWithNewerPostsSet.add(communityKey));\n }\n }\n }\n const communityKeysWithNewerPosts = [...communityKeysWithNewerPostsSet];\n\n // don't update the array if the data is the same to avoid rerenders\n const previousCommunityKeysWithNewerPosts =\n previousFeedsCommunityKeysWithNewerPosts[feedName] || [];\n if (\n communityKeysWithNewerPosts.length === previousCommunityKeysWithNewerPosts.length &&\n communityKeysWithNewerPosts.toString() === previousCommunityKeysWithNewerPosts.toString()\n ) {\n feedsCommunityKeysWithNewerPosts[feedName] =\n previousFeedsCommunityKeysWithNewerPosts[feedName];\n } else {\n feedsCommunityKeysWithNewerPosts[feedName] = communityKeysWithNewerPosts;\n }\n }\n return feedsCommunityKeysWithNewerPosts;\n};\n\n// find how many posts are left in each communities in a buffereds feeds\nexport const getFeedsCommunitiesPostCounts = (feedsOptions: FeedsOptions, feeds: Feeds) => {\n const feedsCommunitiesPostCounts: FeedsCommunitiesPostCounts = {};\n for (const feedName in feedsOptions) {\n const communityKeys = getFeedCommunityKeys(feedsOptions[feedName]);\n const communityRefs = getFeedCommunityRefs(feedsOptions[feedName]);\n feedsCommunitiesPostCounts[feedName] = {};\n for (const communityKey of communityKeys) {\n feedsCommunitiesPostCounts[feedName][communityKey] = 0;\n }\n for (const comment of feeds[feedName] || []) {\n const commentCommunityAddress = getCommentCommunityAddress(comment);\n if (commentCommunityAddress) {\n getMatchingCommunityRefKeys(communityRefs, commentCommunityAddress).forEach(\n (communityKey) => {\n feedsCommunitiesPostCounts[feedName][communityKey] =\n (feedsCommunitiesPostCounts[feedName][communityKey] || 0) + 1;\n },\n );\n }\n }\n }\n return feedsCommunitiesPostCounts;\n};\n\n/**\n * Get which feeds have more posts, i.e. have not reached the final page of all subs\n */\nexport const getFeedsHaveMore = (\n feedsOptions: FeedsOptions,\n bufferedFeeds: Feeds,\n communities: Communities,\n communitiesPages: CommunitiesPages,\n accounts: Accounts,\n) => {\n const feedsHaveMore: { [feedName: string]: boolean } = {};\n feedsLoop: for (const feedName in feedsOptions) {\n // if the feed still has buffered posts, then it still has more\n if (bufferedFeeds[feedName]?.length) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n\n const communityRefs = getFeedCommunityRefs(feedsOptions[feedName]);\n const communityKeys = getFeedCommunityKeys(feedsOptions[feedName]);\n let { sortType, accountId, modQueue } = feedsOptions[feedName];\n\n let pageType = \"posts\";\n if (modQueue?.[0]) {\n // TODO: allow multiple modQueue at once, fow now only use first in array\n sortType = modQueue[0];\n pageType = \"modQueue\";\n }\n\n communityKeysLoop: for (const [communityIndex, communityKey] of communityKeys.entries()) {\n const community = communities[communityKey];\n const communityRef = communityRefs[communityIndex];\n const isBlockedCommunity = Object.keys(accounts[accountId]?.blockedAddresses || {}).some(\n (blockedAddress) =>\n communityRef && doesAddressMatchCommunityRef(blockedAddress, communityRef, community),\n );\n\n // don't consider the sub if the address is blocked\n if (isBlockedCommunity) {\n continue communityKeysLoop;\n }\n\n // if at least 1 community hasn't loaded yet, then the feed still has more\n if (!community?.updatedAt) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n\n // if at least 1 community has posts cache expired, then the feed still has more\n if (communityPostsCacheExpired(community)) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n\n const firstPageCid = getCommunityFirstPageCid(community, sortType, pageType);\n // TODO: if a loaded community doesn't have a first page, it's unclear what we should do\n // should we try to use another sort type by default, like 'hot', or should we just ignore it?\n // 'continue' to ignore it for now\n if (!firstPageCid) {\n continue communityKeysLoop;\n }\n const pages = getCommunityPages(community, sortType, communitiesPages, pageType, accountId);\n // if first page isn't loaded yet, then the feed still has more\n if (!pages.length) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n const lastPage = pages[pages.length - 1];\n if (lastPage.nextCid) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n }\n\n // if buffered feeds are empty and no last page of any community has a next page, then has more is false\n feedsHaveMore[feedName] = false;\n }\n return feedsHaveMore;\n};\n\n// get all communities pages cids of all feeds, use to check if a communitiesStore change should trigger updateFeeds\nexport const getFeedsCommunities = (feedsOptions: FeedsOptions, communities: Communities) => {\n // find all feeds communities\n const feedsCommunityAddresses = new Set<string>();\n Object.keys(feedsOptions).forEach((i) =>\n getFeedCommunityKeys(feedsOptions[i]).forEach((a) => feedsCommunityAddresses.add(a)),\n );\n\n // use map for performance increase when checking size\n const feedsCommunities = new Map<string, Community>();\n for (const communityAddress of feedsCommunityAddresses) {\n feedsCommunities.set(communityAddress, communities[communityAddress]);\n }\n return feedsCommunities;\n};\n\nexport const feedsCommunitiesChanged = (\n previousFeedsCommunities: Map<string, Community>,\n feedsCommunities: Map<string, Community>,\n) => {\n if (previousFeedsCommunities.size !== feedsCommunities.size) {\n return true;\n }\n for (let communityAddress of previousFeedsCommunities.keys()) {\n // check if the object is still the same\n if (previousFeedsCommunities.get(communityAddress) !== feedsCommunities.get(communityAddress)) {\n return true;\n }\n }\n return false;\n};\n\n// get all communities pages cids of all feeds, use to check if a communitiesStore change should trigger updateFeeds\nexport const getFeedsCommunitiesFirstPageCids = (\n feedsCommunities: Map<string, Community>,\n): string[] => {\n // find all the feeds communities first page cids\n const feedsCommunitiesFirstPageCids = new Set<string>();\n for (const community of feedsCommunities.values()) {\n if (!community?.posts && !community?.modQueue) {\n continue;\n }\n\n // check pages\n if (community.posts?.pages) {\n for (const page of Object.values<CommunityPage>(community.posts.pages)) {\n if (page?.nextCid) {\n feedsCommunitiesFirstPageCids.add(page?.nextCid);\n }\n }\n }\n\n // check pageCids\n if (community.posts?.pageCids) {\n for (const pageCid of Object.values<string>(community.posts.pageCids)) {\n if (pageCid) {\n feedsCommunitiesFirstPageCids.add(pageCid);\n }\n }\n }\n\n // TODO: would be more performant to only check modQueue if there's a feedOptions with modQueue\n if (community.modQueue?.pageCids) {\n for (const pageCid of Object.values<string>(community.modQueue.pageCids)) {\n if (pageCid) {\n feedsCommunitiesFirstPageCids.add(pageCid);\n }\n }\n }\n }\n\n return [...feedsCommunitiesFirstPageCids].sort();\n};\n\n// get all communities posts pages first post updatedAts, use to check if a communitiesStore change should trigger updateFeeds\nexport const getFeedsCommunitiesPostsPagesFirstUpdatedAts = (\n feedsCommunities: Map<string, Community>,\n): string => {\n let feedsCommunitiesPostsPagesFirstUpdatedAts = \"\";\n for (const community of feedsCommunities.values()) {\n for (const page of Object.values<CommunityPage>(community?.posts?.pages || {})) {\n if (page?.comments?.[0]?.updatedAt) {\n feedsCommunitiesPostsPagesFirstUpdatedAts +=\n page.comments[0].cid + page.comments[0].updatedAt;\n }\n }\n }\n return feedsCommunitiesPostsPagesFirstUpdatedAts;\n};\n\n// get number of feeds community that are loaded\nexport const getFeedsCommunitiesLoadedCount = (\n feedsCommunities: Map<string, Community>,\n): number => {\n let count = 0;\n for (const community of feedsCommunities.values()) {\n if (community?.updatedAt) {\n count++;\n }\n }\n return count;\n};\n\nexport const getAccountsBlockedAddresses = (accounts: Accounts) => {\n const blockedAddressesSet = new Set<string>();\n for (const { blockedAddresses } of Object.values(accounts)) {\n for (const address in blockedAddresses) {\n if (blockedAddresses[address]) {\n blockedAddressesSet.add(address);\n }\n }\n }\n return [...blockedAddressesSet].sort();\n};\n\nexport const accountsBlockedAddressesChanged = (\n previousAccountsBlockedAddresses: { [address: string]: boolean }[],\n accountsBlockedAddresses: { [address: string]: boolean }[],\n) => {\n if (previousAccountsBlockedAddresses.length !== accountsBlockedAddresses.length) {\n return true;\n }\n for (const i in previousAccountsBlockedAddresses) {\n // check if the object is still the same\n if (previousAccountsBlockedAddresses[i] !== accountsBlockedAddresses[i]) {\n return true;\n }\n }\n return false;\n};\n\nexport const feedsHaveChangedBlockedAddresses = (\n feedsOptions: FeedsOptions,\n bufferedFeeds: Feeds,\n blockedAddresses: string[],\n previousBlockedAddresses: string[],\n) => {\n // find the difference between current and previous blocked addresses\n const changedBlockedAddresses = blockedAddresses\n .filter((x) => !previousBlockedAddresses.includes(x))\n .concat(previousBlockedAddresses.filter((x) => !blockedAddresses.includes(x)));\n\n // if changed blocked addresses arent used in the feeds, do nothing\n for (const address of changedBlockedAddresses) {\n for (const feedName in feedsOptions) {\n const feedOptions = feedsOptions[feedName];\n if (\n getMatchingCommunityRefKeys(getFeedCommunityRefs(feedOptions), address).some(\n (communityKey) => getFeedCommunityKeys(feedOptions).includes(communityKey),\n )\n ) {\n return true;\n }\n }\n }\n\n // feeds posts author addresses have a changed blocked address\n // NOTE: because of this, if an author address is unblocked, feeds won't update until some other event causes a feed update\n // it seems preferable to causing unnecessary rerenders every time an unused block event occurs\n const changedBlockedAddressesSet = new Set(changedBlockedAddresses);\n for (const feedName in bufferedFeeds) {\n for (const post of bufferedFeeds[feedName] || []) {\n if (post?.author?.address && changedBlockedAddressesSet.has(post.author.address)) {\n return true;\n }\n }\n }\n\n return false;\n};\n\nexport const getAccountsBlockedCids = (accounts: Accounts) => {\n const blockedCidsSet = new Set<string>();\n for (const { blockedCids } of Object.values(accounts)) {\n for (const address in blockedCids) {\n if (blockedCids[address]) {\n blockedCidsSet.add(address);\n }\n }\n }\n return [...blockedCidsSet].sort();\n};\n\nexport const accountsBlockedCidsChanged = (\n previousAccountsBlockedCids: { [address: string]: boolean }[],\n accountsBlockedCids: { [address: string]: boolean }[],\n) => {\n if (previousAccountsBlockedCids.length !== accountsBlockedCids.length) {\n return true;\n }\n for (const i in previousAccountsBlockedCids) {\n // check if the object is still the same\n if (previousAccountsBlockedCids[i] !== accountsBlockedCids[i]) {\n return true;\n }\n }\n return false;\n};\n\nexport const feedsHaveChangedBlockedCids = (\n feedsOptions: FeedsOptions,\n bufferedFeeds: Feeds,\n blockedCids: string[],\n previousBlockedCids: string[],\n) => {\n // find the difference between current and previous blocked addresses\n const changedBlockedCids = blockedCids\n .filter((x) => !previousBlockedCids.includes(x))\n .concat(previousBlockedCids.filter((x) => !blockedCids.includes(x)));\n\n // feeds posts author addresses have a changed blocked address\n // NOTE: because of this, if a cid is unblocked, feeds won't update until some other event causes a feed update\n // it seems preferable to causing unnecessary rerenders every time an unused block event occurs\n const changedBlockedCidsSet = new Set(changedBlockedCids);\n for (const feedName in bufferedFeeds) {\n for (const post of bufferedFeeds[feedName] || []) {\n if (post?.cid && changedBlockedCidsSet.has(post?.cid)) {\n return true;\n }\n }\n }\n\n return false;\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/stores/feeds/utils.ts"],"names":[],"mappings":";;;;;;;;;AAeA,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,aAAa,MAAM,aAAa,CAAC;AACxC,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAEL,4BAA4B,EAC5B,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,oCAAoC,CAAC,CAAC;AAEzD,MAAM,oBAAoB,GAAG,CAAC,WAAiC,EAAwB,EAAE,CACvF,WAAW,CAAC,WAAW,IAAI,EAAE,CAAC;AAEhC,MAAM,oBAAoB,GAAG,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AmB,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,YAA0B,EAC1B,aAAoB,EACpB,WAAqB,EACrB,mBAA6B,EAC7B,EAAE;IACF,qEAAqE;IACrE,MAAM,kBAAkB,GAAG,WAAW;SACnC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC/C,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvE,8DAA8D;IAC9D,+GAA+G;IAC/G,+FAA+F;IAC/F,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC1D,KAAK,MAAM,QAAQ,IAAI,aAAa,EAAE,CAAC;QACrC,KAAK,MAAM,IAAI,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YACjD,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,KAAI,qBAAqB,CAAC,GAAG,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,EAAE,CAAC;gBACtD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import assert from \"assert\";\nimport {\n Comment,\n Feed,\n Feeds,\n FeedOptions,\n FeedsOptions,\n Community,\n Communities,\n Account,\n Accounts,\n CommunityPage,\n CommunitiesPages,\n FeedsCommunitiesPostCounts,\n} from \"../../types\";\nimport { getCommunityPages, getCommunityFirstPageCid } from \"../communities-pages\";\nimport accountsStore from \"../accounts\";\nimport feedSorter from \"./feed-sorter\";\nimport { communityPostsCacheExpired, commentIsValid, removeInvalidComments } from \"../../lib/utils\";\nimport { getCommentCommunityAddress, normalizeCommentCommunityAddress } from \"../../lib/pkc-compat\";\nimport {\n CommunityLookupRef,\n doesAddressMatchCommunityRef,\n getCommunityRefKeys,\n getMatchingCommunityRefKeys,\n} from \"../../lib/community-ref\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nimport { resolvePostSortType } from \"../../lib/page-sorts\";\nconst log = Logger(\"bitsocial-react-hooks:feeds:stores\");\n\nconst getFeedCommunityRefs = (feedOptions: Partial<FeedOptions>): CommunityLookupRef[] =>\n feedOptions.communities || [];\n\nconst getFeedCommunityKeys = (feedOptions: Partial<FeedOptions>) =>\n feedOptions.communityKeys || getCommunityRefKeys(getFeedCommunityRefs(feedOptions));\n\nconst getCommentFreshness = (comment: Comment | undefined) =>\n Math.max(comment?.updatedAt ?? 0, comment?.timestamp ?? 0, 0);\n\nconst commentMatchesModQueue = (comment: Comment | undefined, modQueue?: string[]) => {\n const modQueueName = modQueue?.[0];\n if (!modQueueName) {\n return true;\n }\n if (modQueueName === \"pendingApproval\") {\n return comment?.pendingApproval === true;\n }\n return true;\n};\n\nconst getFeedPost = (\n post: Comment,\n communityRef: CommunityLookupRef,\n community: Community,\n modQueue?: string[],\n freshestComments?: { [commentCid: string]: Comment },\n) => {\n const normalizedPost = normalizeCommentCommunityAddress(post) as Comment;\n const freshestComment = post.cid\n ? normalizeCommentCommunityAddress(freshestComments?.[post.cid])\n : undefined;\n const postCommunityAddress = getCommentCommunityAddress(normalizedPost);\n if (!doesAddressMatchCommunityRef(postCommunityAddress, communityRef, community)) {\n return;\n }\n if (!commentMatchesModQueue(normalizedPost, modQueue)) {\n return;\n }\n if (\n !freshestComment ||\n getCommentFreshness(freshestComment) <= getCommentFreshness(normalizedPost)\n ) {\n return normalizedPost;\n }\n if (!commentMatchesModQueue(freshestComment, modQueue)) {\n return;\n }\n if (\n !doesAddressMatchCommunityRef(\n getCommentCommunityAddress(freshestComment),\n communityRef,\n community,\n )\n ) {\n return;\n }\n return freshestComment;\n};\n\nconst reconcileLoadedModQueueFeed = (\n feedOptions: FeedOptions,\n loadedFeed: Feed,\n filteredSortedFeed: Feed,\n) => {\n if (!feedOptions?.modQueue?.[0] || !loadedFeed?.length) {\n return loadedFeed;\n }\n\n const filteredSortedFeedByCid = new Map<string, Comment>();\n for (const post of filteredSortedFeed) {\n if (post.cid) {\n filteredSortedFeedByCid.set(post.cid, post);\n }\n }\n\n let changed = false;\n const nextLoadedFeed: Comment[] = [];\n for (const post of loadedFeed) {\n if (!post.cid) {\n nextLoadedFeed.push(post);\n continue;\n }\n\n const sourcePost = filteredSortedFeedByCid.get(post.cid);\n if (!sourcePost) {\n changed = true;\n continue;\n }\n\n if (getCommentFreshness(sourcePost) > getCommentFreshness(post)) {\n nextLoadedFeed.push(sourcePost);\n changed = true;\n continue;\n }\n\n nextLoadedFeed.push(post);\n }\n\n return changed ? nextLoadedFeed : loadedFeed;\n};\n\n/**\n * Calculate the feeds from all the loaded community pages, filter and sort them\n */\nexport const getFilteredSortedFeeds = (\n feedsOptions: FeedsOptions,\n communities: Communities,\n communitiesPages: CommunitiesPages,\n accounts: Accounts,\n freshestComments?: { [commentCid: string]: Comment },\n) => {\n // calculate each feed\n let feeds: Feeds = {};\n for (const feedName in feedsOptions) {\n const communityRefs = getFeedCommunityRefs(feedsOptions[feedName]);\n const communityKeys = getFeedCommunityKeys(feedsOptions[feedName]);\n let { sortType, accountId, filter, newerThan, modQueue } = feedsOptions[feedName];\n const newerThanTimestamp = newerThan ? Math.floor(Date.now() / 1000) - newerThan : undefined;\n\n let pageType = \"posts\";\n if (modQueue?.[0]) {\n // TODO: allow multiple modQueue at once, fow now only use first in array\n sortType = modQueue[0];\n pageType = \"modQueue\";\n }\n\n // find all fetched posts\n const bufferedFeedPosts = [];\n\n // add each comment from each page, do not filter at this stage, filter after sorting\n for (const [communityIndex, communityKey] of communityKeys.entries()) {\n const communityRef = communityRefs[communityIndex];\n // community hasn't loaded yet\n const community = communities[communityKey];\n if (!community || !communityRef) {\n continue;\n }\n\n // if cache is expired and has internet access, don't use, wait for next community update\n if (communityPostsCacheExpired(community) && window.navigator.onLine) {\n continue;\n }\n\n // use community preloaded posts if any\n const preloadedPosts = getPreloadedPosts(community, sortType);\n if (preloadedPosts) {\n for (const post of preloadedPosts) {\n // posts are manually validated, could have fake communityAddress\n if (\n !doesAddressMatchCommunityRef(getCommentCommunityAddress(post), communityRef, community)\n ) {\n break;\n }\n const nextPost = getFeedPost(post, communityRef, community, modQueue, freshestComments);\n if (nextPost) {\n bufferedFeedPosts.push(nextPost);\n }\n }\n }\n\n // add all posts from community pages\n const communityPages = getCommunityPages(\n community,\n sortType,\n communitiesPages,\n pageType,\n accountId,\n );\n for (const communityPage of communityPages) {\n if (communityPage?.comments) {\n for (const post of communityPage.comments) {\n // posts are manually validated, could have fake communityAddress\n if (\n !doesAddressMatchCommunityRef(\n getCommentCommunityAddress(post),\n communityRef,\n community,\n )\n ) {\n break;\n }\n const nextPost = getFeedPost(post, communityRef, community, modQueue, freshestComments);\n if (nextPost) {\n bufferedFeedPosts.push(nextPost);\n }\n }\n }\n }\n }\n\n // sort the feed before filtering to get more accurate results\n const resolvedDefaultSortTypes = communityKeys.map((communityKey) =>\n resolvePostSortType(communities[communityKey], feedsOptions[feedName].sortType),\n );\n const uniqueResolvedDefaultSortTypes = new Set(resolvedDefaultSortTypes);\n const originalSortType =\n feedsOptions[feedName].sortType ||\n (uniqueResolvedDefaultSortTypes.size === 1 ? resolvedDefaultSortTypes[0] : undefined);\n const sortedBufferedFeedPosts = feedSorter.sort(originalSortType, bufferedFeedPosts);\n\n // filter the feed\n const filteredSortedBufferedFeedPosts = [];\n for (const post of sortedBufferedFeedPosts) {\n // address is blocked\n if (\n accounts[accountId]?.blockedAddresses[getCommentCommunityAddress(post) || \"\"] ||\n (post.author?.address && accounts[accountId]?.blockedAddresses[post.author.address])\n ) {\n continue;\n }\n\n // comment cid is blocked\n if (accounts[accountId]?.blockedCids[post.cid]) {\n continue;\n }\n\n // if a feed has more than 1 sub, don't include pinned posts\n // TODO: add test to check if pinned are filtered\n if (post.pinned && communityKeys.length > 1) {\n continue;\n }\n\n // feedOptions filter function\n if (filter && !filter.filter(post)) {\n continue;\n }\n\n // filter posts older than newerThan option\n if (newerThanTimestamp) {\n if (originalSortType === \"active\") {\n if ((post.lastReplyTimestamp || post.timestamp) <= newerThanTimestamp) {\n continue;\n }\n } else {\n if (post.timestamp <= newerThanTimestamp) {\n continue;\n }\n }\n }\n\n filteredSortedBufferedFeedPosts.push(post);\n }\n\n feeds[feedName] = filteredSortedBufferedFeedPosts;\n }\n return feeds;\n};\n\nconst getPreloadedPosts = (community: Community, sortType?: string) => {\n const resolvedSortType = resolvePostSortType(community, sortType);\n if (!resolvedSortType) {\n return;\n }\n return community.posts?.pages?.[resolvedSortType]?.comments;\n};\n\nexport const getLoadedFeeds = async (\n feedsOptions: FeedsOptions,\n filteredSortedFeeds: Feeds,\n loadedFeeds: Feeds,\n bufferedFeeds: Feeds,\n accounts: Accounts,\n) => {\n const nextLoadedFeeds: Feeds = { ...loadedFeeds };\n let loadedFeedsChanged = false;\n for (const feedName in feedsOptions) {\n const { pageNumber, postsPerPage, accountId } = feedsOptions[feedName];\n const pkc = accounts[accountId]?.pkc;\n const loadedFeedPostCount = pageNumber * postsPerPage;\n const currentLoadedFeed = reconcileLoadedModQueueFeed(\n feedsOptions[feedName],\n loadedFeeds[feedName] || [],\n filteredSortedFeeds[feedName] || [],\n );\n if (currentLoadedFeed !== loadedFeeds[feedName]) {\n nextLoadedFeeds[feedName] = currentLoadedFeed;\n loadedFeedsChanged = true;\n }\n const missingPostsCount =\n loadedFeedPostCount - currentLoadedFeed.filter((post) => post.index === undefined).length;\n\n // get new posts from buffered feed\n const bufferedFeed = bufferedFeeds[feedName] || [];\n\n let missingPosts: any[] = [];\n for (const post of bufferedFeed) {\n if (missingPosts.length >= missingPostsCount) {\n missingPosts = await removeInvalidComments(missingPosts, { validateReplies: false }, pkc);\n // only stop if there were no invalid comments\n if (missingPosts.length >= missingPostsCount) {\n break;\n }\n }\n missingPosts.push(post);\n }\n\n // the current loaded feed already exist and doesn't need new posts\n if (\n missingPosts.length === 0 &&\n loadedFeeds[feedName] &&\n currentLoadedFeed === loadedFeeds[feedName]\n ) {\n continue;\n }\n nextLoadedFeeds[feedName] = [...currentLoadedFeed, ...missingPosts];\n if (missingPosts.length > 0) {\n loadedFeedsChanged = true;\n }\n }\n\n // add account comments\n const accountCommentsChangedFeeds = addAccountsComments(feedsOptions, nextLoadedFeeds);\n\n // do nothing if there are no missing posts\n if (!loadedFeedsChanged && !accountCommentsChangedFeeds) {\n return loadedFeeds;\n }\n return nextLoadedFeeds;\n};\n\nconst getApprovalPublicationKey = (comment: Comment) =>\n [\n comment.timestamp ?? \"\",\n comment.parentCid ?? \"\",\n comment.postCid ?? \"\",\n getCommentCommunityAddress(comment) ?? \"\",\n comment.author?.address ?? \"\",\n comment.title ?? \"\",\n comment.content ?? \"\",\n comment.link ?? \"\",\n ].join(\"\\0\");\n\nexport const addAccountsComments = (feedsOptions: FeedsOptions, loadedFeeds: Feeds) => {\n let loadedFeedsChanged = false;\n const accountsComments = accountsStore.getState().accountsComments || {};\n for (const feedName in feedsOptions) {\n const { accountId, accountComments: accountCommentsOptions } = feedsOptions[feedName];\n const communityRefs = getFeedCommunityRefs(feedsOptions[feedName]);\n const { newerThan, append } = accountCommentsOptions || {};\n if (!newerThan) {\n continue;\n }\n const newerThanTimestamp =\n newerThan === Infinity ? 0 : Math.floor(Date.now() / 1000) - newerThan;\n const isNewerThan = (post: Comment) => post.timestamp > newerThanTimestamp;\n\n const accountComments = accountsComments[accountId] || [];\n const accountPosts = accountComments.filter((comment) => {\n // is a reply, not a post\n if (comment.parentCid || comment.depth > 0) {\n return false;\n }\n if (!isNewerThan(comment)) {\n return false;\n }\n return (\n getMatchingCommunityRefKeys(communityRefs, getCommentCommunityAddress(comment)).length > 0\n );\n });\n const validAccountIndices = new Set(accountPosts.map((p) => p.index));\n const accountCidToPost = new Map<string, Comment>();\n for (const p of accountPosts) {\n if (p.cid) accountCidToPost.set(p.cid, p);\n }\n\n let loadedFeed = loadedFeeds[feedName] || [];\n const approvedPublicationKeys = new Set(\n loadedFeed\n .filter((post) => post.pendingApproval !== true)\n .map((post) => getApprovalPublicationKey(post)),\n );\n // prune stale local-account entries and replace when cid matches but index changed\n const prunedLoadedFeed: Comment[] = [];\n for (const post of loadedFeed) {\n if (post.index === undefined) {\n prunedLoadedFeed.push(post);\n continue;\n }\n if (\n post.pendingApproval === true &&\n approvedPublicationKeys.has(getApprovalPublicationKey(post))\n ) {\n loadedFeedsChanged = true;\n continue;\n }\n if (!validAccountIndices.has(post.index)) {\n loadedFeedsChanged = true;\n continue;\n }\n if (post.cid) {\n const freshAccountPost = accountCidToPost.get(post.cid);\n if (freshAccountPost && freshAccountPost.index !== post.index) {\n prunedLoadedFeed.push(freshAccountPost);\n loadedFeedsChanged = true;\n continue;\n }\n }\n prunedLoadedFeed.push(post);\n }\n loadedFeed = loadedFeeds[feedName] = prunedLoadedFeed;\n\n if (!accountPosts.length) {\n continue;\n }\n // if a loaded comment doesn't have a cid, then it's pending\n // and pending account comments should always have unique timestamps\n const loadedFeedMap = new Map();\n loadedFeed.forEach((post, loadedFeedIndex) => {\n if (post.cid) loadedFeedMap.set(post.cid, loadedFeedIndex);\n if (typeof post.index === \"number\") loadedFeedMap.set(post.index, loadedFeedIndex);\n if (!post.cid) loadedFeedMap.set(post.timestamp, loadedFeedIndex);\n if (post.pendingApproval !== true) {\n loadedFeedMap.set(getApprovalPublicationKey(post), loadedFeedIndex);\n }\n });\n for (const accountPost of accountPosts) {\n // account post with cid already added\n if (accountPost.cid && loadedFeedMap.has(accountPost.cid)) {\n continue;\n }\n if (\n accountPost.pendingApproval === true &&\n loadedFeedMap.has(getApprovalPublicationKey(accountPost))\n ) {\n continue;\n }\n // account post without cid already added, but now we have the cid\n if (accountPost.cid && loadedFeedMap.has(accountPost.index)) {\n const loadedFeedIndex = loadedFeedMap.get(accountPost.index);\n // update the feed with the accountPost.cid now that we have it\n loadedFeed[loadedFeedIndex] = accountPost;\n loadedFeedsChanged = true;\n continue;\n }\n if (loadedFeedMap.has(accountPost.index)) {\n continue;\n }\n // pending account post without cid already added\n if (!accountPost.cid && loadedFeedMap.has(accountPost.timestamp)) {\n continue;\n }\n if (append) {\n loadedFeed.push(accountPost);\n } else {\n loadedFeed.unshift(accountPost);\n }\n loadedFeedsChanged = true;\n }\n }\n return loadedFeedsChanged;\n};\n\nexport const getBufferedFeedsWithoutLoadedFeeds = (bufferedFeeds: Feeds, loadedFeeds: Feeds) => {\n // contruct a list of posts already loaded to remove them from buffered feeds\n const loadedFeedsPosts: { [key: string]: Set<string> } = {};\n for (const feedName in loadedFeeds) {\n loadedFeedsPosts[feedName] = new Set();\n for (const post of loadedFeeds[feedName]) {\n loadedFeedsPosts[feedName].add(post.cid);\n }\n }\n\n const newBufferedFeeds: Feeds = {};\n for (const feedName in bufferedFeeds) {\n newBufferedFeeds[feedName] = [];\n let bufferedFeedPostChanged = false;\n for (const [i, post] of bufferedFeeds[feedName].entries()) {\n if (loadedFeedsPosts[feedName]?.has(post.cid)) {\n continue;\n }\n newBufferedFeeds[feedName].push(post);\n if (\n !bufferedFeedPostChanged &&\n (newBufferedFeeds[feedName][i]?.cid !== bufferedFeeds[feedName][i]?.cid ||\n (newBufferedFeeds[feedName][i]?.updatedAt || 0) >\n (bufferedFeeds[feedName][i]?.updatedAt || 0))\n ) {\n bufferedFeedPostChanged = true;\n }\n }\n if (\n !bufferedFeedPostChanged &&\n newBufferedFeeds[feedName].length === bufferedFeeds[feedName].length\n ) {\n newBufferedFeeds[feedName] = bufferedFeeds[feedName];\n }\n }\n return newBufferedFeeds;\n};\n\nexport const getUpdatedFeeds = async (\n feedsOptions: FeedsOptions,\n filteredSortedFeeds: Feeds,\n updatedFeeds: Feeds,\n loadedFeeds: Feeds,\n accounts: Accounts,\n) => {\n // contruct a list of posts already loaded to remove them from buffered feeds\n const updatedFeedsPosts: { [feedName: string]: { [postCid: string]: any } } = {};\n for (const feedName in updatedFeeds) {\n updatedFeedsPosts[feedName] = {};\n for (const [index, updatedPost] of updatedFeeds[feedName].entries()) {\n updatedFeedsPosts[feedName][updatedPost.cid] = { index, updatedPost };\n }\n }\n\n const newUpdatedFeeds: Feeds = { ...updatedFeeds };\n for (const feedName in filteredSortedFeeds) {\n const pkc = accounts[feedsOptions[feedName]?.accountId]?.pkc;\n const updatedFeed = [...(updatedFeeds[feedName] || [])];\n const onlyHasNewPosts = updatedFeed.length === 0;\n let updatedFeedChanged = false;\n\n // add new posts from loadedFeed posts\n while (updatedFeed.length < loadedFeeds[feedName].length) {\n updatedFeed[updatedFeed.length] = loadedFeeds[feedName][updatedFeed.length];\n updatedFeedChanged = true;\n }\n\n // add updated post from filteredSortedFeed\n if (!onlyHasNewPosts) {\n const promises = [];\n for (const post of filteredSortedFeeds[feedName]) {\n if (updatedFeedsPosts[feedName]?.[post.cid]) {\n const { index, updatedPost } = updatedFeedsPosts[feedName][post.cid];\n // faster to validate comments async\n promises.push(\n (async () => {\n if (\n (post.updatedAt || 0) > (updatedPost.updatedAt || 0) &&\n (await commentIsValid(post, { validateReplies: false }, pkc))\n ) {\n updatedFeed[index] = post;\n updatedFeedChanged = true;\n }\n })(),\n );\n }\n }\n await Promise.all(promises);\n }\n\n if (updatedFeedChanged) {\n newUpdatedFeeds[feedName] = updatedFeed;\n }\n }\n return newUpdatedFeeds;\n};\n\n// find with communities have posts newer (or ranked higher) than the loaded feeds\n// can be used to display \"new posts in x, y, z subs\" alert, like on twitter\nexport const getFeedsCommunityKeysWithNewerPosts = (\n feedsOptions: FeedsOptions,\n filteredSortedFeeds: Feeds,\n loadedFeeds: Feeds,\n previousFeedsCommunityKeysWithNewerPosts: { [feedName: string]: string[] },\n) => {\n const feedsCommunityKeysWithNewerPosts: { [feedName: string]: string[] } = {};\n for (const feedName in loadedFeeds) {\n const loadedFeed = loadedFeeds[feedName];\n const cidsInLoadedFeed = new Set();\n for (const post of loadedFeed) {\n cidsInLoadedFeed.add(post.cid);\n }\n const communityKeysWithNewerPostsSet = new Set<string>();\n for (const [i, post] of filteredSortedFeeds[feedName].entries()) {\n if (i >= loadedFeed.length) {\n break;\n }\n // if any post in filteredSortedFeeds ranks higher than the loaded feed count, it's a newer post\n if (!cidsInLoadedFeed.has(post.cid)) {\n const postCommunityAddress = getCommentCommunityAddress(post);\n if (postCommunityAddress) {\n getMatchingCommunityRefKeys(\n getFeedCommunityRefs(feedsOptions[feedName] || {}),\n postCommunityAddress,\n ).forEach((communityKey) => communityKeysWithNewerPostsSet.add(communityKey));\n }\n }\n }\n const communityKeysWithNewerPosts = [...communityKeysWithNewerPostsSet];\n\n // don't update the array if the data is the same to avoid rerenders\n const previousCommunityKeysWithNewerPosts =\n previousFeedsCommunityKeysWithNewerPosts[feedName] || [];\n if (\n communityKeysWithNewerPosts.length === previousCommunityKeysWithNewerPosts.length &&\n communityKeysWithNewerPosts.toString() === previousCommunityKeysWithNewerPosts.toString()\n ) {\n feedsCommunityKeysWithNewerPosts[feedName] =\n previousFeedsCommunityKeysWithNewerPosts[feedName];\n } else {\n feedsCommunityKeysWithNewerPosts[feedName] = communityKeysWithNewerPosts;\n }\n }\n return feedsCommunityKeysWithNewerPosts;\n};\n\n// find how many posts are left in each communities in a buffereds feeds\nexport const getFeedsCommunitiesPostCounts = (feedsOptions: FeedsOptions, feeds: Feeds) => {\n const feedsCommunitiesPostCounts: FeedsCommunitiesPostCounts = {};\n for (const feedName in feedsOptions) {\n const communityKeys = getFeedCommunityKeys(feedsOptions[feedName]);\n const communityRefs = getFeedCommunityRefs(feedsOptions[feedName]);\n feedsCommunitiesPostCounts[feedName] = {};\n for (const communityKey of communityKeys) {\n feedsCommunitiesPostCounts[feedName][communityKey] = 0;\n }\n for (const comment of feeds[feedName] || []) {\n const commentCommunityAddress = getCommentCommunityAddress(comment);\n if (commentCommunityAddress) {\n getMatchingCommunityRefKeys(communityRefs, commentCommunityAddress).forEach(\n (communityKey) => {\n feedsCommunitiesPostCounts[feedName][communityKey] =\n (feedsCommunitiesPostCounts[feedName][communityKey] || 0) + 1;\n },\n );\n }\n }\n }\n return feedsCommunitiesPostCounts;\n};\n\n/**\n * Get which feeds have more posts, i.e. have not reached the final page of all subs\n */\nexport const getFeedsHaveMore = (\n feedsOptions: FeedsOptions,\n bufferedFeeds: Feeds,\n communities: Communities,\n communitiesPages: CommunitiesPages,\n accounts: Accounts,\n) => {\n const feedsHaveMore: { [feedName: string]: boolean } = {};\n feedsLoop: for (const feedName in feedsOptions) {\n // if the feed still has buffered posts, then it still has more\n if (bufferedFeeds[feedName]?.length) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n\n const communityRefs = getFeedCommunityRefs(feedsOptions[feedName]);\n const communityKeys = getFeedCommunityKeys(feedsOptions[feedName]);\n let { sortType, accountId, modQueue } = feedsOptions[feedName];\n\n let pageType = \"posts\";\n if (modQueue?.[0]) {\n // TODO: allow multiple modQueue at once, fow now only use first in array\n sortType = modQueue[0];\n pageType = \"modQueue\";\n }\n\n communityKeysLoop: for (const [communityIndex, communityKey] of communityKeys.entries()) {\n const community = communities[communityKey];\n const communityRef = communityRefs[communityIndex];\n const isBlockedCommunity = Object.keys(accounts[accountId]?.blockedAddresses || {}).some(\n (blockedAddress) =>\n communityRef && doesAddressMatchCommunityRef(blockedAddress, communityRef, community),\n );\n\n // don't consider the sub if the address is blocked\n if (isBlockedCommunity) {\n continue communityKeysLoop;\n }\n\n // if at least 1 community hasn't loaded yet, then the feed still has more\n if (!community?.updatedAt) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n\n // if at least 1 community has posts cache expired, then the feed still has more\n if (communityPostsCacheExpired(community)) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n\n const firstPageCid = getCommunityFirstPageCid(community, sortType, pageType);\n // TODO: if a loaded community doesn't have a first page, it's unclear what we should do\n // should we try to use another sort type by default, like 'hot', or should we just ignore it?\n // 'continue' to ignore it for now\n if (!firstPageCid) {\n continue communityKeysLoop;\n }\n const pages = getCommunityPages(community, sortType, communitiesPages, pageType, accountId);\n // if first page isn't loaded yet, then the feed still has more\n if (!pages.length) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n const lastPage = pages[pages.length - 1];\n if (lastPage.nextCid) {\n feedsHaveMore[feedName] = true;\n continue feedsLoop;\n }\n }\n\n // if buffered feeds are empty and no last page of any community has a next page, then has more is false\n feedsHaveMore[feedName] = false;\n }\n return feedsHaveMore;\n};\n\n// get all communities pages cids of all feeds, use to check if a communitiesStore change should trigger updateFeeds\nexport const getFeedsCommunities = (feedsOptions: FeedsOptions, communities: Communities) => {\n // find all feeds communities\n const feedsCommunityAddresses = new Set<string>();\n Object.keys(feedsOptions).forEach((i) =>\n getFeedCommunityKeys(feedsOptions[i]).forEach((a) => feedsCommunityAddresses.add(a)),\n );\n\n // use map for performance increase when checking size\n const feedsCommunities = new Map<string, Community>();\n for (const communityAddress of feedsCommunityAddresses) {\n feedsCommunities.set(communityAddress, communities[communityAddress]);\n }\n return feedsCommunities;\n};\n\nexport const feedsCommunitiesChanged = (\n previousFeedsCommunities: Map<string, Community>,\n feedsCommunities: Map<string, Community>,\n) => {\n if (previousFeedsCommunities.size !== feedsCommunities.size) {\n return true;\n }\n for (let communityAddress of previousFeedsCommunities.keys()) {\n // check if the object is still the same\n if (previousFeedsCommunities.get(communityAddress) !== feedsCommunities.get(communityAddress)) {\n return true;\n }\n }\n return false;\n};\n\n// get all communities pages cids of all feeds, use to check if a communitiesStore change should trigger updateFeeds\nexport const getFeedsCommunitiesFirstPageCids = (\n feedsCommunities: Map<string, Community>,\n): string[] => {\n // find all the feeds communities first page cids\n const feedsCommunitiesFirstPageCids = new Set<string>();\n for (const community of feedsCommunities.values()) {\n if (!community?.posts && !community?.modQueue) {\n continue;\n }\n\n // check pages\n if (community.posts?.pages) {\n for (const page of Object.values<CommunityPage>(community.posts.pages)) {\n if (page?.nextCid) {\n feedsCommunitiesFirstPageCids.add(page?.nextCid);\n }\n }\n }\n\n // check pageCids\n if (community.posts?.pageCids) {\n for (const pageCid of Object.values<string>(community.posts.pageCids)) {\n if (pageCid) {\n feedsCommunitiesFirstPageCids.add(pageCid);\n }\n }\n }\n\n // TODO: would be more performant to only check modQueue if there's a feedOptions with modQueue\n if (community.modQueue?.pageCids) {\n for (const pageCid of Object.values<string>(community.modQueue.pageCids)) {\n if (pageCid) {\n feedsCommunitiesFirstPageCids.add(pageCid);\n }\n }\n }\n }\n\n return [...feedsCommunitiesFirstPageCids].sort();\n};\n\n// get all communities posts pages first post updatedAts, use to check if a communitiesStore change should trigger updateFeeds\nexport const getFeedsCommunitiesPostsPagesFirstUpdatedAts = (\n feedsCommunities: Map<string, Community>,\n): string => {\n let feedsCommunitiesPostsPagesFirstUpdatedAts = \"\";\n for (const community of feedsCommunities.values()) {\n for (const page of Object.values<CommunityPage>(community?.posts?.pages || {})) {\n if (page?.comments?.[0]?.updatedAt) {\n feedsCommunitiesPostsPagesFirstUpdatedAts +=\n page.comments[0].cid + page.comments[0].updatedAt;\n }\n }\n }\n return feedsCommunitiesPostsPagesFirstUpdatedAts;\n};\n\n// get number of feeds community that are loaded\nexport const getFeedsCommunitiesLoadedCount = (\n feedsCommunities: Map<string, Community>,\n): number => {\n let count = 0;\n for (const community of feedsCommunities.values()) {\n if (community?.updatedAt) {\n count++;\n }\n }\n return count;\n};\n\nexport const getAccountsBlockedAddresses = (accounts: Accounts) => {\n const blockedAddressesSet = new Set<string>();\n for (const { blockedAddresses } of Object.values(accounts)) {\n for (const address in blockedAddresses) {\n if (blockedAddresses[address]) {\n blockedAddressesSet.add(address);\n }\n }\n }\n return [...blockedAddressesSet].sort();\n};\n\nexport const accountsBlockedAddressesChanged = (\n previousAccountsBlockedAddresses: { [address: string]: boolean }[],\n accountsBlockedAddresses: { [address: string]: boolean }[],\n) => {\n if (previousAccountsBlockedAddresses.length !== accountsBlockedAddresses.length) {\n return true;\n }\n for (const i in previousAccountsBlockedAddresses) {\n // check if the object is still the same\n if (previousAccountsBlockedAddresses[i] !== accountsBlockedAddresses[i]) {\n return true;\n }\n }\n return false;\n};\n\nexport const feedsHaveChangedBlockedAddresses = (\n feedsOptions: FeedsOptions,\n bufferedFeeds: Feeds,\n blockedAddresses: string[],\n previousBlockedAddresses: string[],\n) => {\n // find the difference between current and previous blocked addresses\n const changedBlockedAddresses = blockedAddresses\n .filter((x) => !previousBlockedAddresses.includes(x))\n .concat(previousBlockedAddresses.filter((x) => !blockedAddresses.includes(x)));\n\n // if changed blocked addresses arent used in the feeds, do nothing\n for (const address of changedBlockedAddresses) {\n for (const feedName in feedsOptions) {\n const feedOptions = feedsOptions[feedName];\n if (\n getMatchingCommunityRefKeys(getFeedCommunityRefs(feedOptions), address).some(\n (communityKey) => getFeedCommunityKeys(feedOptions).includes(communityKey),\n )\n ) {\n return true;\n }\n }\n }\n\n // feeds posts author addresses have a changed blocked address\n // NOTE: because of this, if an author address is unblocked, feeds won't update until some other event causes a feed update\n // it seems preferable to causing unnecessary rerenders every time an unused block event occurs\n const changedBlockedAddressesSet = new Set(changedBlockedAddresses);\n for (const feedName in bufferedFeeds) {\n for (const post of bufferedFeeds[feedName] || []) {\n if (post?.author?.address && changedBlockedAddressesSet.has(post.author.address)) {\n return true;\n }\n }\n }\n\n return false;\n};\n\nexport const getAccountsBlockedCids = (accounts: Accounts) => {\n const blockedCidsSet = new Set<string>();\n for (const { blockedCids } of Object.values(accounts)) {\n for (const address in blockedCids) {\n if (blockedCids[address]) {\n blockedCidsSet.add(address);\n }\n }\n }\n return [...blockedCidsSet].sort();\n};\n\nexport const accountsBlockedCidsChanged = (\n previousAccountsBlockedCids: { [address: string]: boolean }[],\n accountsBlockedCids: { [address: string]: boolean }[],\n) => {\n if (previousAccountsBlockedCids.length !== accountsBlockedCids.length) {\n return true;\n }\n for (const i in previousAccountsBlockedCids) {\n // check if the object is still the same\n if (previousAccountsBlockedCids[i] !== accountsBlockedCids[i]) {\n return true;\n }\n }\n return false;\n};\n\nexport const feedsHaveChangedBlockedCids = (\n feedsOptions: FeedsOptions,\n bufferedFeeds: Feeds,\n blockedCids: string[],\n previousBlockedCids: string[],\n) => {\n // find the difference between current and previous blocked addresses\n const changedBlockedCids = blockedCids\n .filter((x) => !previousBlockedCids.includes(x))\n .concat(previousBlockedCids.filter((x) => !blockedCids.includes(x)));\n\n // feeds posts author addresses have a changed blocked address\n // NOTE: because of this, if a cid is unblocked, feeds won't update until some other event causes a feed update\n // it seems preferable to causing unnecessary rerenders every time an unused block event occurs\n const changedBlockedCidsSet = new Set(changedBlockedCids);\n for (const feedName in bufferedFeeds) {\n for (const post of bufferedFeeds[feedName] || []) {\n if (post?.cid && changedBlockedCidsSet.has(post?.cid)) {\n return true;\n }\n }\n }\n\n return false;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"replies-store.d.ts","sourceRoot":"","sources":["../../../src/stores/replies/replies-store.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EAGP,kBAAkB,EAClB,mBAAmB,EAGpB,MAAM,aAAa,CAAC;AAwBrB,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAKxC,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,mBAAmB,CAAC;IAClC,aAAa,EAAE,KAAK,CAAC;IACrB,WAAW,EAAE,KAAK,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC;IACpB,wBAAwB,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACzD,aAAa,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC/C,eAAe,EAAE,QAAQ,CAAC;IAC1B,6BAA6B,EAAE,QAAQ,CAAC;IACxC,uBAAuB,EAAE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