@bitsocial/bitsocial-react-hooks 0.3.0 → 0.3.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"feeds.js","sourceRoot":"","sources":["../../../src/hooks/feeds/feeds.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,mCAAmC,CAAC,CAAC;AACxD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAUtC,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAEL,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,IAAI,+BAA+B,GAAG,CAAC,CAAC;AACxC,MAAM,WAAW,GAAY,EAAE,CAAC;AAChC,MAAM,kBAAkB,GAAa,EAAE,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,OAAwB;IAC9C,MAAM,CACJ,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EACvC,6BAA6B,OAAO,iBAAiB,CACtD,CAAC;IACF,MAAM,IAAI,GAAG,OAAO,IAAI,EAAE,CAAC;IAC3B,IAAI,EACF,WAAW,EACX,QA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C,CAAC,CAAC;gBAChB,MAAA,OAAO,CAAC,CAAC,CAAC,0CAAE,GAAG;gBACf,UAAU,CAAC,CAAC,CAAC;aACd,CAAC,CACH,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,yBAAyB,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAccount } from \"../accounts\";\nimport validator from \"../../lib/validator\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:feeds:hooks\");\nimport assert from \"../../lib/assert\";\nimport {\n Feed,\n Feeds,\n UseBufferedFeedsOptions,\n UseBufferedFeedsResult,\n UseFeedOptions,\n UseFeedResult,\n CommentsFilter,\n} from \"../../types\";\nimport useFeedsStore from \"../../stores/feeds\";\nimport useAccountsStore from \"../../stores/accounts\";\nimport { addCommentModerationToComments } from \"../../lib/utils/comment-moderation\";\nimport { addOptimisticVoteCountsToComments } from \"../../lib/utils/optimistic-vote-counts\";\nimport shallow from \"zustand/shallow\";\nimport {\n CommunityLookupRef,\n getCommunityRefKeys,\n getUniqueSortedCommunityRefs,\n} from \"../../lib/community-ref\";\nimport { serializeFeedKey } from \"../../lib/serialize-feed-key\";\n\nlet feedAutoUpdateSubscriptionCount = 0;\nconst emptyErrors: Error[] = [];\nconst emptyCommunityKeys: string[] = [];\n\n/**\n * @param communities - The communities to fetch, e.g. [{name: 'memes.eth'}, {publicKey: '12D3KooW...'}]\n * @param sortType - A sort name published by the community, or a standard sort computed client-side\n * when every post fits in the preloaded page. Omit it to use the preloaded sort.\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\nexport function useFeed(options?: UseFeedOptions): UseFeedResult {\n assert(\n !options || typeof options === \"object\",\n `useFeed options argument '${options}' not an object`,\n );\n const opts = options || {};\n let {\n communities,\n sortType,\n accountName,\n postsPerPage,\n filter,\n newerThan,\n accountComments,\n modQueue,\n includeBlockedCids,\n } = opts;\n validator.validateUseFeedArguments({\n communities,\n communityRefs: (opts as any).communityRefs,\n communityAddresses: (opts as any).communityAddresses,\n sortType,\n accountName,\n postsPerPage,\n filter,\n newerThan,\n accountComments,\n includeBlockedCids,\n });\n const account = useAccount({ accountName });\n const accountVotes = useAccountsStore((state: any) =>\n account?.id ? state.accountsVotes[account.id] : undefined,\n );\n const addFeedToStore = useFeedsStore((state) => state.addFeedToStore);\n const startFeedAutoUpdate = useFeedsStore((state) => state.startFeedAutoUpdate);\n const stopFeedAutoUpdate = useFeedsStore((state) => state.stopFeedAutoUpdate);\n const autoUpdateSubscriptionId = useRef(`useFeed-${++feedAutoUpdateSubscriptionCount}`);\n const incrementFeedPageNumber = useFeedsStore((state) => state.incrementFeedPageNumber);\n const expandFeedTimeWindow = useFeedsStore((state) => state.expandFeedTimeWindow);\n const resetFeed = useFeedsStore((state) => state.resetFeed);\n const normalizedCommunityRefs = useMemo(() => communities || [], [communities]);\n const uniqueCommunityRefs = useUniqueSortedCommunityRefs(normalizedCommunityRefs);\n const uniqueCommunityKeys = useMemo(\n () => getCommunityRefKeys(uniqueCommunityRefs),\n [uniqueCommunityRefs],\n );\n const feedName = useFeedName(\n account?.id,\n sortType,\n uniqueCommunityKeys,\n postsPerPage,\n filter,\n newerThan,\n accountComments,\n modQueue,\n includeBlockedCids,\n );\n // errors belong to the feed they happened in, another feed starts without them. Drop them when\n // the feed changes (or when one lands after it changed) so they don't return with the old feed\n const [feedErrors, setFeedErrors] = useState<{ feedName: string; errors: Error[] }>();\n if (feedErrors && feedErrors.feedName !== feedName) {\n setFeedErrors(undefined);\n }\n const errors = feedErrors?.feedName === feedName ? feedErrors.errors : emptyErrors;\n const addError = (error: Error) =>\n setFeedErrors((previous) => ({\n feedName,\n errors: previous?.feedName === feedName ? [...previous.errors, error] : [error],\n }));\n const communityKeysWithNewerPosts = useFeedsStore(\n (state) => state.feedsCommunityKeysWithNewerPosts[feedName],\n );\n const feedCommunityKeysWithMore = useFeedsStore(\n (state) => state.feedsCommunityKeysWithMore[feedName],\n );\n const communityKeysWithUnavailableSort = useFeedsStore(\n (state) => state.feedsCommunityKeysWithUnavailableSort[feedName],\n );\n\n // add feed to store\n useEffect(() => {\n if (!uniqueCommunityRefs.length || !account) {\n return;\n }\n const isBufferedFeed = false;\n addFeedToStore(\n feedName,\n uniqueCommunityRefs,\n uniqueCommunityKeys,\n sortType,\n account,\n isBufferedFeed,\n postsPerPage,\n filter,\n newerThan,\n accountComments,\n modQueue,\n includeBlockedCids,\n ).catch((error: unknown) => log.error(\"useFeed addFeedToStore error\", { feedName, error }));\n }, [feedName]);\n\n // keep the feed's communities updating while mounted, after the feed was added above\n useEffect(() => {\n if (!uniqueCommunityRefs.length || !account) {\n return;\n }\n const subscriberId = autoUpdateSubscriptionId.current;\n startFeedAutoUpdate(feedName, subscriberId);\n return () => stopFeedAutoUpdate(feedName, subscriberId);\n }, [feedName]);\n\n const feedKey = feedName;\n const feed = useFeedsStore((state) => state.loadedFeeds[feedKey]);\n const updatedFeed = useFeedsStore((state) => state.updatedFeeds[feedKey]);\n const bufferedFeed = useFeedsStore((state) => state.bufferedFeeds[feedKey]);\n let hasMore = useFeedsStore((state) => state.feedsHaveMore[feedKey]);\n if (!feedName || typeof hasMore !== \"boolean\") {\n hasMore = true;\n }\n if (!normalizedCommunityRefs.length) {\n hasMore = false;\n }\n\n const loadMore = async () => {\n try {\n if (!uniqueCommunityRefs.length || !account) {\n throw Error(\"useFeed cannot load more feed not initalized yet\");\n }\n try {\n incrementFeedPageNumber(feedName);\n } catch (error) {\n // infinite scroll calls loadMore before the feed or its current page has loaded, the\n // store refuses the page increment and that isn't a feed error\n log(\"useFeed loadMore before the feed page loaded\", { feedName, error });\n await new Promise((r) => setTimeout(r, 50));\n }\n } catch (e: any) {\n // wait 100 ms so infinite scroll doesn't spam this function\n await new Promise((r) => setTimeout(r, 50));\n addError(e);\n }\n };\n\n const reset = async () => {\n try {\n if (!uniqueCommunityRefs.length || !account) {\n throw Error(\"useFeed cannot reset feed not initalized yet\");\n }\n await resetFeed(feedName);\n } catch (e: any) {\n // wait 100 ms so infinite scroll doesn't spam this function\n await new Promise((r) => setTimeout(r, 50));\n addError(e);\n }\n };\n\n const expandTimeWindow = async (nextNewerThan?: number) => {\n try {\n if (!uniqueCommunityRefs.length || !account) {\n throw Error(\"useFeed cannot expand time window before feed initialized yet\");\n }\n expandFeedTimeWindow(feedName, nextNewerThan);\n } catch (e: any) {\n await new Promise((r) => setTimeout(r, 50));\n addError(e);\n }\n };\n\n if (account && normalizedCommunityRefs.length) {\n log(\"useFeed\", {\n feedLength: feed?.length || 0,\n hasMore,\n communities: normalizedCommunityRefs,\n communityKeys: uniqueCommunityKeys,\n sortType,\n account,\n feedsStoreOptions: useFeedsStore.getState().feedsOptions,\n feedsStore: useFeedsStore.getState(),\n });\n }\n\n const state = !hasMore ? \"succeeded\" : \"fetching-ipns\";\n // until the feed is first calculated, every community still has more\n let communityKeysWithMore = feedCommunityKeysWithMore || uniqueCommunityKeys;\n if (!normalizedCommunityRefs.length) {\n communityKeysWithMore = [];\n }\n // apply the account's pending votes like useComment/useComments/useReplies do, so voting from a\n // feed updates the score immediately instead of only once the community publishes the new counts\n const normalizedFeed = useMemo(\n () => addOptimisticVoteCountsToComments(addCommentModerationToComments(feed), accountVotes),\n [feed, accountVotes],\n );\n const normalizedBufferedFeed = useMemo(\n () =>\n addOptimisticVoteCountsToComments(addCommentModerationToComments(bufferedFeed), accountVotes),\n [bufferedFeed, accountVotes],\n );\n const normalizedUpdatedFeed = useMemo(\n () =>\n addOptimisticVoteCountsToComments(addCommentModerationToComments(updatedFeed), accountVotes),\n [updatedFeed, accountVotes],\n );\n\n return useMemo(\n () => ({\n feed: normalizedFeed,\n bufferedFeed: normalizedBufferedFeed,\n updatedFeed: normalizedUpdatedFeed,\n hasMore,\n communityKeysWithNewerPosts: communityKeysWithNewerPosts || [],\n communityKeysWithMore,\n communityKeysWithUnavailableSort: communityKeysWithUnavailableSort || emptyCommunityKeys,\n loadMore,\n expandTimeWindow,\n reset,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [\n normalizedFeed,\n normalizedBufferedFeed,\n normalizedUpdatedFeed,\n feedName,\n hasMore,\n errors,\n communityKeysWithNewerPosts,\n communityKeysWithMore,\n communityKeysWithUnavailableSort,\n ],\n );\n}\n\n/**\n * Use useBufferedFeeds to buffer multiple feeds in the background so what when\n * they are called by useFeed later, they are already preloaded.\n *\n * @param feedOptions - The options of the feed\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\nexport function useBufferedFeeds(options?: UseBufferedFeedsOptions): UseBufferedFeedsResult {\n assert(\n !options || typeof options === \"object\",\n `useBufferedFeeds options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { feedsOptions = [], accountName } = opts;\n validator.validateUseBufferedFeedsArguments({ feedsOptions, accountName });\n const account = useAccount({ accountName });\n const addFeedToStore = useFeedsStore((state) => state.addFeedToStore);\n const startFeedAutoUpdate = useFeedsStore((state) => state.startFeedAutoUpdate);\n const stopFeedAutoUpdate = useFeedsStore((state) => state.stopFeedAutoUpdate);\n const autoUpdateSubscriptionId = useRef(`useBufferedFeeds-${++feedAutoUpdateSubscriptionCount}`);\n\n // do a bunch of calculations to get feedsOptionsFlattened and feedNames\n const feedsOpts = feedsOptions;\n const {\n communityRefsArrays,\n communityKeysArrays,\n sortTypes,\n postsPerPages,\n filters,\n newerThans,\n } = useMemo(() => {\n const communityRefsArrays: CommunityLookupRef[][] = [];\n const communityKeysArrays: string[][] = [];\n const sortTypes: (string | undefined)[] = [];\n const postsPerPages: (number | undefined)[] = [];\n const filters: (CommentsFilter | undefined)[] = [];\n const newerThans: (number | undefined)[] = [];\n for (const feedOptions of feedsOpts) {\n validator.validateUseFeedArguments({\n communities: feedOptions.communities,\n communityRefs: (feedOptions as any).communityRefs,\n communityAddresses: (feedOptions as any).communityAddresses,\n sortType: feedOptions.sortType,\n accountName,\n postsPerPage: feedOptions.postsPerPage,\n filter: feedOptions.filter,\n newerThan: feedOptions.newerThan,\n accountComments: feedOptions.accountComments,\n });\n const normalizedCommunityRefs = getUniqueSortedCommunityRefs(feedOptions.communities || []);\n communityRefsArrays.push(normalizedCommunityRefs);\n communityKeysArrays.push(getCommunityRefKeys(normalizedCommunityRefs));\n sortTypes.push(feedOptions.sortType);\n postsPerPages.push(feedOptions.postsPerPage);\n filters.push(feedOptions.filter);\n newerThans.push(feedOptions.newerThan);\n }\n return {\n communityRefsArrays,\n communityKeysArrays,\n sortTypes,\n postsPerPages,\n filters,\n newerThans,\n };\n }, [feedsOpts]);\n const feedNames = useFeedNames(\n account?.id,\n sortTypes,\n communityKeysArrays,\n postsPerPages,\n filters,\n newerThans,\n );\n\n const bufferedFeeds = useFeedsStore((state) => {\n const bufferedFeeds: Feeds = {};\n for (const feedName of feedNames) {\n bufferedFeeds[feedName] = state.bufferedFeeds[feedName];\n }\n return bufferedFeeds;\n }, shallow);\n\n // add feed to store\n useEffect(() => {\n for (const [i] of communityRefsArrays.entries()) {\n const sortType = sortTypes[i];\n const uniqueCommunityRefs = communityRefsArrays[i];\n const uniqueCommunityKeys = communityKeysArrays[i];\n validator.validateFeedSortType(sortType);\n const feedName = feedNames[i];\n if (!account || !uniqueCommunityRefs.length) {\n continue;\n }\n if (!bufferedFeeds[feedName]) {\n const isBufferedFeed = true;\n addFeedToStore(\n feedName,\n uniqueCommunityRefs,\n uniqueCommunityKeys,\n sortType,\n account,\n isBufferedFeed,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n ).catch((error: unknown) =>\n log.error(\"useBufferedFeeds addFeedToStore error\", { feedName, error }),\n );\n }\n }\n }, [feedNames]);\n\n // keep the buffered feeds' communities updating while mounted, keyed by the names so\n // inline options recreated on every render do not resubscribe\n useEffect(() => {\n if (!account) {\n return;\n }\n const subscriberId = autoUpdateSubscriptionId.current;\n const subscribedFeedNames = feedNames.filter((_, i) => communityRefsArrays[i]?.length);\n for (const feedName of subscribedFeedNames) {\n startFeedAutoUpdate(feedName, subscriberId);\n }\n return () => {\n for (const feedName of subscribedFeedNames) {\n stopFeedAutoUpdate(feedName, subscriberId);\n }\n };\n }, [JSON.stringify(feedNames), account?.id]);\n\n // only give to the user the buffered feeds he requested\n const bufferedFeedsArray: Feed[] = useMemo(() => {\n const bufferedFeedsArray: Feed[] = [];\n for (const feedName of feedNames) {\n bufferedFeedsArray.push(addCommentModerationToComments(bufferedFeeds[feedName]));\n }\n return bufferedFeedsArray;\n }, [bufferedFeeds, feedNames]);\n\n if (account && feedsOptions?.length) {\n log(\"useBufferedFeeds\", {\n bufferedFeeds,\n feedsOptions,\n account,\n accountName,\n feedsStoreOptions: useFeedsStore.getState().feedsOptions,\n feedsStore: useFeedsStore.getState(),\n });\n }\n\n const state = \"fetching-ipns\";\n\n return useMemo(\n () => ({\n bufferedFeeds: bufferedFeedsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [bufferedFeedsArray, feedsOptions],\n );\n}\n\nfunction useUniqueSortedCommunityRefs(communityRefs?: CommunityLookupRef[]) {\n return useMemo(() => {\n return getUniqueSortedCommunityRefs(communityRefs);\n }, [communityRefs]);\n}\n\nfunction useFeedName(\n accountId: string,\n sortType: string | undefined,\n uniqueCommunityKeys: string[],\n postsPerPage?: number,\n filter?: CommentsFilter,\n newerThan?: number,\n accountComments?: UseFeedOptions[\"accountComments\"],\n modQueue?: string[],\n includeBlockedCids?: boolean,\n) {\n const filterKey = filter?.key;\n const accountCommentsNewerThan = accountComments?.newerThan;\n const accountCommentsAppend = accountComments?.append;\n const accountCommentsLimit = accountComments?.limit ?? undefined;\n return useMemo(() => {\n const feedKey: unknown[] = [\n accountId,\n sortType,\n uniqueCommunityKeys,\n postsPerPage,\n filterKey,\n newerThan,\n accountCommentsNewerThan,\n accountCommentsAppend,\n modQueue,\n ];\n // options added later are only part of the name when set, feeds without them keep their name\n if (accountCommentsLimit !== undefined) {\n feedKey.push(accountCommentsLimit);\n }\n if (includeBlockedCids === true) {\n feedKey.push(includeBlockedCids);\n }\n return serializeFeedKey(feedKey);\n }, [\n accountId,\n sortType,\n uniqueCommunityKeys,\n postsPerPage,\n filterKey,\n newerThan,\n accountCommentsNewerThan,\n accountCommentsAppend,\n accountCommentsLimit,\n modQueue?.toString(),\n includeBlockedCids,\n ]);\n}\n\nfunction useFeedNames(\n accountId: string,\n sortTypes: (string | undefined)[],\n uniqueCommunityKeysArrays: string[][],\n postsPerPages: (number | undefined)[],\n filters: (CommentsFilter | undefined)[],\n newerThans: (number | undefined)[],\n) {\n return useMemo(() => {\n const feedNames: string[] = [];\n for (const [i] of sortTypes.entries()) {\n feedNames.push(\n serializeFeedKey([\n accountId,\n sortTypes[i],\n uniqueCommunityKeysArrays[i],\n postsPerPages[i],\n filters[i]?.key,\n newerThans[i],\n ]),\n );\n }\n return feedNames;\n }, [accountId, sortTypes, uniqueCommunityKeysArrays, postsPerPages, filters, newerThans]);\n}\n"]}
1
+ {"version":3,"file":"feeds.js","sourceRoot":"","sources":["../../../src/hooks/feeds/feeds.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,mCAAmC,CAAC,CAAC;AACxD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAUtC,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,mBAAmB,EAAE,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,gBAAgB,MAAM,uBAAuB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,SAAiB,EACjB,SAAiC,EACjC,yBAAqC,EACrC,aAAqC,EACrC,OAAuC,EACvC,UAAkC;IAElC,OAAO,OAAO,CAAC,GAAG,EAAE;;QAClB,MAAM,SAAS,GAAa,EAAE,CAAC;QAC/B,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YACtC,SAAS,CAAC,IAAI,CACZ,gBAAgB,CAAC;gBACf,SAAS;gBACT,SAAS,CAAC,CAAC,CAAC;gBACZ,yBAAyB,CAAC,CAAC,CAAC;gBAC5B,aAAa,CAAC,CAAC,CAAC;gBAChB,MAAA,OAAO,CAAC,CAAC,CAAC,0CAAE,GAAG;gBACf,UAAU,CAAC,CAAC,CAAC;aACd,CAAC,CACH,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,yBAAyB,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAccount } from \"../accounts\";\nimport validator from \"../../lib/validator\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:feeds:hooks\");\nimport assert from \"../../lib/assert\";\nimport {\n Feed,\n Feeds,\n UseBufferedFeedsOptions,\n UseBufferedFeedsResult,\n UseFeedOptions,\n UseFeedResult,\n CommentsFilter,\n} from \"../../types\";\nimport useFeedsStore from \"../../stores/feeds\";\nimport useCommunitiesStore, { getCommunityFirstLoadFailure } from \"../../stores/communities\";\nimport useAccountsStore from \"../../stores/accounts\";\nimport { addCommentModerationToComments } from \"../../lib/utils/comment-moderation\";\nimport { addOptimisticVoteCountsToComments } from \"../../lib/utils/optimistic-vote-counts\";\nimport shallow from \"zustand/shallow\";\nimport {\n CommunityLookupRef,\n getCommunityRefKeys,\n getUniqueSortedCommunityRefs,\n isCommunityRefBlocked,\n} from \"../../lib/community-ref\";\nimport { serializeFeedKey } from \"../../lib/serialize-feed-key\";\n\nlet feedAutoUpdateSubscriptionCount = 0;\nconst emptyErrors: Error[] = [];\nconst emptyCommunityKeys: string[] = [];\n\n/**\n * @param communities - The communities to fetch, e.g. [{name: 'memes.eth'}, {publicKey: '12D3KooW...'}]\n * @param sortType - A sort name published by the community, or a standard sort computed client-side\n * when every post fits in the preloaded page. Omit it to use the preloaded sort.\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\nexport function useFeed(options?: UseFeedOptions): UseFeedResult {\n assert(\n !options || typeof options === \"object\",\n `useFeed options argument '${options}' not an object`,\n );\n const opts = options || {};\n let {\n communities,\n sortType,\n accountName,\n postsPerPage,\n filter,\n newerThan,\n accountComments,\n modQueue,\n includeBlockedCids,\n } = opts;\n validator.validateUseFeedArguments({\n communities,\n communityRefs: (opts as any).communityRefs,\n communityAddresses: (opts as any).communityAddresses,\n sortType,\n accountName,\n postsPerPage,\n filter,\n newerThan,\n accountComments,\n includeBlockedCids,\n });\n const account = useAccount({ accountName });\n const accountVotes = useAccountsStore((state: any) =>\n account?.id ? state.accountsVotes[account.id] : undefined,\n );\n const addFeedToStore = useFeedsStore((state) => state.addFeedToStore);\n const startFeedAutoUpdate = useFeedsStore((state) => state.startFeedAutoUpdate);\n const stopFeedAutoUpdate = useFeedsStore((state) => state.stopFeedAutoUpdate);\n const autoUpdateSubscriptionId = useRef(`useFeed-${++feedAutoUpdateSubscriptionCount}`);\n const incrementFeedPageNumber = useFeedsStore((state) => state.incrementFeedPageNumber);\n const expandFeedTimeWindow = useFeedsStore((state) => state.expandFeedTimeWindow);\n const resetFeed = useFeedsStore((state) => state.resetFeed);\n const normalizedCommunityRefs = useMemo(() => communities || [], [communities]);\n const uniqueCommunityRefs = useUniqueSortedCommunityRefs(normalizedCommunityRefs);\n const uniqueCommunityKeys = useMemo(\n () => getCommunityRefKeys(uniqueCommunityRefs),\n [uniqueCommunityRefs],\n );\n const feedName = useFeedName(\n account?.id,\n sortType,\n uniqueCommunityKeys,\n postsPerPage,\n filter,\n newerThan,\n accountComments,\n modQueue,\n includeBlockedCids,\n );\n // errors belong to the feed they happened in, another feed starts without them. Drop them when\n // the feed changes (or when one lands after it changed) so they don't return with the old feed\n const [feedErrors, setFeedErrors] = useState<{ feedName: string; errors: Error[] }>();\n if (feedErrors && feedErrors.feedName !== feedName) {\n setFeedErrors(undefined);\n }\n const errors = feedErrors?.feedName === feedName ? feedErrors.errors : emptyErrors;\n const addError = (error: Error) =>\n setFeedErrors((previous) => ({\n feedName,\n errors: previous?.feedName === feedName ? [...previous.errors, error] : [error],\n }));\n const communityKeysWithNewerPosts = useFeedsStore(\n (state) => state.feedsCommunityKeysWithNewerPosts[feedName],\n );\n const feedCommunityKeysWithMore = useFeedsStore(\n (state) => state.feedsCommunityKeysWithMore[feedName],\n );\n const communityKeysWithUnavailableSort = useFeedsStore(\n (state) => state.feedsCommunityKeysWithUnavailableSort[feedName],\n );\n\n // add feed to store\n useEffect(() => {\n if (!uniqueCommunityRefs.length || !account) {\n return;\n }\n const isBufferedFeed = false;\n addFeedToStore(\n feedName,\n uniqueCommunityRefs,\n uniqueCommunityKeys,\n sortType,\n account,\n isBufferedFeed,\n postsPerPage,\n filter,\n newerThan,\n accountComments,\n modQueue,\n includeBlockedCids,\n ).catch((error: unknown) => log.error(\"useFeed addFeedToStore error\", { feedName, error }));\n }, [feedName]);\n\n // keep the feed's communities updating while mounted, after the feed was added above\n useEffect(() => {\n if (!uniqueCommunityRefs.length || !account) {\n return;\n }\n const subscriberId = autoUpdateSubscriptionId.current;\n startFeedAutoUpdate(feedName, subscriberId);\n return () => stopFeedAutoUpdate(feedName, subscriberId);\n }, [feedName]);\n\n const feedKey = feedName;\n const feed = useFeedsStore((state) => state.loadedFeeds[feedKey]);\n const updatedFeed = useFeedsStore((state) => state.updatedFeeds[feedKey]);\n const bufferedFeed = useFeedsStore((state) => state.bufferedFeeds[feedKey]);\n let hasMore = useFeedsStore((state) => state.feedsHaveMore[feedKey]);\n if (!feedName || typeof hasMore !== \"boolean\") {\n hasMore = true;\n }\n if (!normalizedCommunityRefs.length) {\n hasMore = false;\n }\n\n const loadMore = async () => {\n try {\n if (!uniqueCommunityRefs.length || !account) {\n throw Error(\"useFeed cannot load more feed not initalized yet\");\n }\n try {\n incrementFeedPageNumber(feedName);\n } catch (error) {\n // infinite scroll calls loadMore before the feed or its current page has loaded, the\n // store refuses the page increment and that isn't a feed error\n log(\"useFeed loadMore before the feed page loaded\", { feedName, error });\n await new Promise((r) => setTimeout(r, 50));\n }\n } catch (e: any) {\n // wait 100 ms so infinite scroll doesn't spam this function\n await new Promise((r) => setTimeout(r, 50));\n addError(e);\n }\n };\n\n const reset = async () => {\n try {\n if (!uniqueCommunityRefs.length || !account) {\n throw Error(\"useFeed cannot reset feed not initalized yet\");\n }\n await resetFeed(feedName);\n } catch (e: any) {\n // wait 100 ms so infinite scroll doesn't spam this function\n await new Promise((r) => setTimeout(r, 50));\n addError(e);\n }\n };\n\n const expandTimeWindow = async (nextNewerThan?: number) => {\n try {\n if (!uniqueCommunityRefs.length || !account) {\n throw Error(\"useFeed cannot expand time window before feed initialized yet\");\n }\n expandFeedTimeWindow(feedName, nextNewerThan);\n } catch (e: any) {\n await new Promise((r) => setTimeout(r, 50));\n addError(e);\n }\n };\n\n if (account && normalizedCommunityRefs.length) {\n log(\"useFeed\", {\n feedLength: feed?.length || 0,\n hasMore,\n communities: normalizedCommunityRefs,\n communityKeys: uniqueCommunityKeys,\n sortType,\n account,\n feedsStoreOptions: useFeedsStore.getState().feedsOptions,\n feedsStore: useFeedsStore.getState(),\n });\n }\n\n // until the feed is first calculated, every community still has more\n let communityKeysWithMore = feedCommunityKeysWithMore || uniqueCommunityKeys;\n if (!normalizedCommunityRefs.length) {\n communityKeysWithMore = [];\n }\n // every community of the feed that isn't blocked failed to load a record with a non-retriable\n // failure, which makes useCommunity().state \"failed\". A community that is retrying, still loading\n // or has a record may still add posts.\n const blockedAddresses = account?.blockedAddresses;\n const communitiesFailedToLoad = useCommunitiesStore((state) => {\n let hasUnblockedCommunity = false;\n for (const [index, communityKey] of uniqueCommunityKeys.entries()) {\n const community = state.communities[communityKey];\n if (isCommunityRefBlocked(blockedAddresses, uniqueCommunityRefs[index], community)) {\n continue;\n }\n const syncStatus = state.syncStatuses[communityKey];\n if (getCommunityFirstLoadFailure(syncStatus, community) !== \"non-retriable\") {\n return false;\n }\n hasUnblockedCommunity = true;\n }\n return hasUnblockedCommunity;\n });\n let state = !hasMore ? \"succeeded\" : \"fetching-ipns\";\n // an empty feed that can't get posts from any of its communities\n if (hasMore && !feed?.length && communitiesFailedToLoad) {\n state = \"failed\";\n }\n // apply the account's pending votes like useComment/useComments/useReplies do, so voting from a\n // feed updates the score immediately instead of only once the community publishes the new counts\n const normalizedFeed = useMemo(\n () => addOptimisticVoteCountsToComments(addCommentModerationToComments(feed), accountVotes),\n [feed, accountVotes],\n );\n const normalizedBufferedFeed = useMemo(\n () =>\n addOptimisticVoteCountsToComments(addCommentModerationToComments(bufferedFeed), accountVotes),\n [bufferedFeed, accountVotes],\n );\n const normalizedUpdatedFeed = useMemo(\n () =>\n addOptimisticVoteCountsToComments(addCommentModerationToComments(updatedFeed), accountVotes),\n [updatedFeed, accountVotes],\n );\n\n return useMemo(\n () => ({\n feed: normalizedFeed,\n bufferedFeed: normalizedBufferedFeed,\n updatedFeed: normalizedUpdatedFeed,\n hasMore,\n communityKeysWithNewerPosts: communityKeysWithNewerPosts || [],\n communityKeysWithMore,\n communityKeysWithUnavailableSort: communityKeysWithUnavailableSort || emptyCommunityKeys,\n loadMore,\n expandTimeWindow,\n reset,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [\n normalizedFeed,\n normalizedBufferedFeed,\n normalizedUpdatedFeed,\n feedName,\n hasMore,\n state,\n errors,\n communityKeysWithNewerPosts,\n communityKeysWithMore,\n communityKeysWithUnavailableSort,\n ],\n );\n}\n\n/**\n * Use useBufferedFeeds to buffer multiple feeds in the background so what when\n * they are called by useFeed later, they are already preloaded.\n *\n * @param feedOptions - The options of the feed\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\nexport function useBufferedFeeds(options?: UseBufferedFeedsOptions): UseBufferedFeedsResult {\n assert(\n !options || typeof options === \"object\",\n `useBufferedFeeds options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { feedsOptions = [], accountName } = opts;\n validator.validateUseBufferedFeedsArguments({ feedsOptions, accountName });\n const account = useAccount({ accountName });\n const addFeedToStore = useFeedsStore((state) => state.addFeedToStore);\n const startFeedAutoUpdate = useFeedsStore((state) => state.startFeedAutoUpdate);\n const stopFeedAutoUpdate = useFeedsStore((state) => state.stopFeedAutoUpdate);\n const autoUpdateSubscriptionId = useRef(`useBufferedFeeds-${++feedAutoUpdateSubscriptionCount}`);\n\n // do a bunch of calculations to get feedsOptionsFlattened and feedNames\n const feedsOpts = feedsOptions;\n const {\n communityRefsArrays,\n communityKeysArrays,\n sortTypes,\n postsPerPages,\n filters,\n newerThans,\n } = useMemo(() => {\n const communityRefsArrays: CommunityLookupRef[][] = [];\n const communityKeysArrays: string[][] = [];\n const sortTypes: (string | undefined)[] = [];\n const postsPerPages: (number | undefined)[] = [];\n const filters: (CommentsFilter | undefined)[] = [];\n const newerThans: (number | undefined)[] = [];\n for (const feedOptions of feedsOpts) {\n validator.validateUseFeedArguments({\n communities: feedOptions.communities,\n communityRefs: (feedOptions as any).communityRefs,\n communityAddresses: (feedOptions as any).communityAddresses,\n sortType: feedOptions.sortType,\n accountName,\n postsPerPage: feedOptions.postsPerPage,\n filter: feedOptions.filter,\n newerThan: feedOptions.newerThan,\n accountComments: feedOptions.accountComments,\n });\n const normalizedCommunityRefs = getUniqueSortedCommunityRefs(feedOptions.communities || []);\n communityRefsArrays.push(normalizedCommunityRefs);\n communityKeysArrays.push(getCommunityRefKeys(normalizedCommunityRefs));\n sortTypes.push(feedOptions.sortType);\n postsPerPages.push(feedOptions.postsPerPage);\n filters.push(feedOptions.filter);\n newerThans.push(feedOptions.newerThan);\n }\n return {\n communityRefsArrays,\n communityKeysArrays,\n sortTypes,\n postsPerPages,\n filters,\n newerThans,\n };\n }, [feedsOpts]);\n const feedNames = useFeedNames(\n account?.id,\n sortTypes,\n communityKeysArrays,\n postsPerPages,\n filters,\n newerThans,\n );\n\n const bufferedFeeds = useFeedsStore((state) => {\n const bufferedFeeds: Feeds = {};\n for (const feedName of feedNames) {\n bufferedFeeds[feedName] = state.bufferedFeeds[feedName];\n }\n return bufferedFeeds;\n }, shallow);\n\n // add feed to store\n useEffect(() => {\n for (const [i] of communityRefsArrays.entries()) {\n const sortType = sortTypes[i];\n const uniqueCommunityRefs = communityRefsArrays[i];\n const uniqueCommunityKeys = communityKeysArrays[i];\n validator.validateFeedSortType(sortType);\n const feedName = feedNames[i];\n if (!account || !uniqueCommunityRefs.length) {\n continue;\n }\n if (!bufferedFeeds[feedName]) {\n const isBufferedFeed = true;\n addFeedToStore(\n feedName,\n uniqueCommunityRefs,\n uniqueCommunityKeys,\n sortType,\n account,\n isBufferedFeed,\n undefined,\n undefined,\n undefined,\n undefined,\n undefined,\n ).catch((error: unknown) =>\n log.error(\"useBufferedFeeds addFeedToStore error\", { feedName, error }),\n );\n }\n }\n }, [feedNames]);\n\n // keep the buffered feeds' communities updating while mounted, keyed by the names so\n // inline options recreated on every render do not resubscribe\n useEffect(() => {\n if (!account) {\n return;\n }\n const subscriberId = autoUpdateSubscriptionId.current;\n const subscribedFeedNames = feedNames.filter((_, i) => communityRefsArrays[i]?.length);\n for (const feedName of subscribedFeedNames) {\n startFeedAutoUpdate(feedName, subscriberId);\n }\n return () => {\n for (const feedName of subscribedFeedNames) {\n stopFeedAutoUpdate(feedName, subscriberId);\n }\n };\n }, [JSON.stringify(feedNames), account?.id]);\n\n // only give to the user the buffered feeds he requested\n const bufferedFeedsArray: Feed[] = useMemo(() => {\n const bufferedFeedsArray: Feed[] = [];\n for (const feedName of feedNames) {\n bufferedFeedsArray.push(addCommentModerationToComments(bufferedFeeds[feedName]));\n }\n return bufferedFeedsArray;\n }, [bufferedFeeds, feedNames]);\n\n if (account && feedsOptions?.length) {\n log(\"useBufferedFeeds\", {\n bufferedFeeds,\n feedsOptions,\n account,\n accountName,\n feedsStoreOptions: useFeedsStore.getState().feedsOptions,\n feedsStore: useFeedsStore.getState(),\n });\n }\n\n const state = \"fetching-ipns\";\n\n return useMemo(\n () => ({\n bufferedFeeds: bufferedFeedsArray,\n state,\n error: undefined,\n errors: [],\n }),\n [bufferedFeedsArray, feedsOptions],\n );\n}\n\nfunction useUniqueSortedCommunityRefs(communityRefs?: CommunityLookupRef[]) {\n return useMemo(() => {\n return getUniqueSortedCommunityRefs(communityRefs);\n }, [communityRefs]);\n}\n\nfunction useFeedName(\n accountId: string,\n sortType: string | undefined,\n uniqueCommunityKeys: string[],\n postsPerPage?: number,\n filter?: CommentsFilter,\n newerThan?: number,\n accountComments?: UseFeedOptions[\"accountComments\"],\n modQueue?: string[],\n includeBlockedCids?: boolean,\n) {\n const filterKey = filter?.key;\n const accountCommentsNewerThan = accountComments?.newerThan;\n const accountCommentsAppend = accountComments?.append;\n const accountCommentsLimit = accountComments?.limit ?? undefined;\n return useMemo(() => {\n const feedKey: unknown[] = [\n accountId,\n sortType,\n uniqueCommunityKeys,\n postsPerPage,\n filterKey,\n newerThan,\n accountCommentsNewerThan,\n accountCommentsAppend,\n modQueue,\n ];\n // options added later are only part of the name when set, feeds without them keep their name\n if (accountCommentsLimit !== undefined) {\n feedKey.push(accountCommentsLimit);\n }\n if (includeBlockedCids === true) {\n feedKey.push(includeBlockedCids);\n }\n return serializeFeedKey(feedKey);\n }, [\n accountId,\n sortType,\n uniqueCommunityKeys,\n postsPerPage,\n filterKey,\n newerThan,\n accountCommentsNewerThan,\n accountCommentsAppend,\n accountCommentsLimit,\n modQueue?.toString(),\n includeBlockedCids,\n ]);\n}\n\nfunction useFeedNames(\n accountId: string,\n sortTypes: (string | undefined)[],\n uniqueCommunityKeysArrays: string[][],\n postsPerPages: (number | undefined)[],\n filters: (CommentsFilter | undefined)[],\n newerThans: (number | undefined)[],\n) {\n return useMemo(() => {\n const feedNames: string[] = [];\n for (const [i] of sortTypes.entries()) {\n feedNames.push(\n serializeFeedKey([\n accountId,\n sortTypes[i],\n uniqueCommunityKeysArrays[i],\n postsPerPages[i],\n filters[i]?.key,\n newerThans[i],\n ]),\n );\n }\n return feedNames;\n }, [accountId, sortTypes, uniqueCommunityKeysArrays, postsPerPages, filters, newerThans]);\n}\n"]}
@@ -18,6 +18,9 @@ export declare const getUniqueSortedCommunityRefs: (communityRefs?: CommunityLoo
18
18
  export declare const isCommunityRef: (value: unknown) => value is CommunityLookupRef;
19
19
  export declare function assertCommunityRef(value: unknown, label: string): asserts value is CommunityLookupRef;
20
20
  export declare const doesAddressMatchCommunityRef: (communityAddress: string | undefined, communityRef: CommunityLookupRef, community?: Community) => boolean;
21
+ export declare const isCommunityRefBlocked: (blockedAddresses: {
22
+ [address: string]: unknown;
23
+ } | undefined, communityRef: CommunityLookupRef | undefined, community?: Community) => boolean;
21
24
  export declare const getMatchingCommunityRefKeys: (communityRefs: CommunityLookupRef[], communityAddress: string | undefined, community?: Community) => string[];
22
25
  export {};
23
26
  //# sourceMappingURL=community-ref.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"community-ref.d.ts","sourceRoot":"","sources":["../../src/lib/community-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG1D,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAK1E,eAAO,MAAM,kBA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e,kBAAkB,EAAE,aAChC,CAAC;AAExC,eAAO,MAAM,yBAAyB,GAAI,uBAAuB,kBAAkB,GAAG,MAAM;WAUlE,MAAM;gBAAc,MAAM;;;CAQnD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,kBAAkB,EACxB,OAAO,kBAAkB,KACxB,kBAmBF,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,gBAAgB,kBAAkB,EAAE,yBAahF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,kBAYxD,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,KAAK,IAAI,kBAAkB,CAErC;AAED,eAAO,MAAM,4BAA4B,GACvC,kBAAkB,MAAM,GAAG,SAAS,EACpC,cAAc,kBAAkB,EAChC,YAAY,SAAS,YAyCtB,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAChC,kBAAkB;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,SAAS,EAC5D,cAAc,kBAAkB,GAAG,SAAS,EAC5C,YAAY,SAAS,YAKpB,CAAC;AAEJ,eAAO,MAAM,2BAA2B,GACtC,eAAe,kBAAkB,EAAE,EACnC,kBAAkB,MAAM,GAAG,SAAS,EACpC,YAAY,SAAS,aAStB,CAAC"}
@@ -99,6 +99,8 @@ export const doesAddressMatchCommunityRef = (communityAddress, communityRef, com
99
99
  }
100
100
  return false;
101
101
  };
102
+ // whether an account's blocked addresses block a community, as feeds leave it out
103
+ export const isCommunityRefBlocked = (blockedAddresses, communityRef, community) => Object.keys(blockedAddresses || {}).some((blockedAddress) => communityRef && doesAddressMatchCommunityRef(blockedAddress, communityRef, community));
102
104
  export const getMatchingCommunityRefKeys = (communityRefs, communityAddress, community) => {
103
105
  const matchingCommunityKeys = new Set();
104
106
  for (const communityRef of communityRefs) {
@@ -1 +1 @@
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AAS;QACX,CAAC;QACD,IAAI,gBAAgB,KAAK,UAAU,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,+BAA+B,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAAE,CAAC;YAClE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,aAAmC,EACnC,gBAAoC,EACpC,SAAqB,EACrB,EAAE;IACF,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;IAChD,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,IAAI,4BAA4B,CAAC,gBAAgB,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,CAAC;YAC5E,qBAAqB,CAAC,GAAG,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,qBAAqB,CAAC,CAAC;AACpC,CAAC,CAAC","sourcesContent":["import assert from \"./assert\";\nimport { Community, CommunityIdentifier } from \"../types\";\nimport { areEquivalentCommunityAddresses } from \"./community-address\";\n\ntype LegacyCommunityRef = {\n address: string;\n name?: string;\n publicKey?: string;\n};\n\nexport type CommunityLookupRef = CommunityIdentifier | LegacyCommunityRef;\n\nconst getLegacyCommunityAddress = (communityRef: CommunityLookupRef) =>\n (communityRef as LegacyCommunityRef).address;\n\nexport const getCommunityRefKey = (communityRef: CommunityLookupRef): string => {\n const communityKey =\n communityRef.publicKey || getLegacyCommunityAddress(communityRef) || communityRef.name;\n assert(typeof communityKey === \"string\" && communityKey.length > 0, \"community ref missing key\");\n return communityKey;\n};\n\nexport const getCommunityRefKeys = (communityRefs: CommunityLookupRef[]) =>\n communityRefs.map(getCommunityRefKey);\n\nexport const getCommunityLookupOptions = (communityRefOrAddress: CommunityLookupRef | string) => {\n if (typeof communityRefOrAddress === \"string\") {\n return { address: communityRefOrAddress };\n }\n\n const legacyCommunityAddress = getLegacyCommunityAddress(communityRefOrAddress);\n if (legacyCommunityAddress) {\n return { address: legacyCommunityAddress };\n }\n\n const options: { name?: string; publicKey?: string } = {};\n if (communityRefOrAddress.name) {\n options.name = communityRefOrAddress.name;\n }\n if (communityRefOrAddress.publicKey) {\n options.publicKey = communityRefOrAddress.publicKey;\n }\n return options;\n};\n\nexport const mergeCommunityRefs = (\n base: CommunityLookupRef,\n extra: CommunityLookupRef,\n): CommunityLookupRef => {\n const mergedAddress = getLegacyCommunityAddress(base) || getLegacyCommunityAddress(extra);\n const mergedName = base.name || extra.name;\n const mergedPublicKey = base.publicKey || extra.publicKey;\n if (mergedPublicKey) {\n return {\n publicKey: mergedPublicKey,\n ...(mergedAddress ? { address: mergedAddress } : undefined),\n ...(mergedName ? { name: mergedName } : undefined),\n };\n }\n if (mergedAddress) {\n return {\n address: mergedAddress,\n ...(mergedName ? { name: mergedName } : undefined),\n };\n }\n assert(typeof mergedName === \"string\" && mergedName.length > 0, \"community ref missing name\");\n return { name: mergedName };\n};\n\nexport const getUniqueSortedCommunityRefs = (communityRefs?: CommunityLookupRef[]) => {\n const refsByKey = new Map<string, CommunityLookupRef>();\n for (const communityRef of communityRefs || []) {\n const communityKey = getCommunityRefKey(communityRef);\n const existingCommunityRef = refsByKey.get(communityKey);\n refsByKey.set(\n communityKey,\n existingCommunityRef ? mergeCommunityRefs(existingCommunityRef, communityRef) : communityRef,\n );\n }\n return [...refsByKey.entries()]\n .sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey))\n .map(([, communityRef]) => communityRef);\n};\n\nexport const isCommunityRef = (value: unknown): value is CommunityLookupRef => {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return false;\n }\n\n const communityRef = value as { address?: unknown; name?: unknown; publicKey?: unknown };\n const hasAddress = typeof communityRef.address === \"string\" && communityRef.address.length > 0;\n const hasName = typeof communityRef.name === \"string\" && communityRef.name.length > 0;\n const hasPublicKey =\n typeof communityRef.publicKey === \"string\" && communityRef.publicKey.length > 0;\n\n return hasAddress || hasName || hasPublicKey;\n};\n\nexport function assertCommunityRef(\n value: unknown,\n label: string,\n): asserts value is CommunityLookupRef {\n assert(isCommunityRef(value), `${label} must be an object with address, name, or publicKey`);\n}\n\nexport const doesAddressMatchCommunityRef = (\n communityAddress: string | undefined,\n communityRef: CommunityLookupRef,\n community?: Community,\n) => {\n if (typeof communityAddress !== \"string\") {\n return false;\n }\n\n const legacyCommunityAddress = getLegacyCommunityAddress(communityRef);\n if (legacyCommunityAddress) {\n if (communityAddress === legacyCommunityAddress) {\n return true;\n }\n if (areEquivalentCommunityAddresses(communityAddress, legacyCommunityAddress)) {\n return true;\n }\n }\n if (communityRef.publicKey && communityAddress === communityRef.publicKey) {\n return true;\n }\n if (communityRef.name) {\n if (communityAddress === communityRef.name) {\n return true;\n }\n if (areEquivalentCommunityAddresses(communityAddress, communityRef.name)) {\n return true;\n }\n }\n\n const communityIdentifiers = [community?.address, community?.publicKey, community?.name];\n for (const identifier of communityIdentifiers) {\n if (typeof identifier !== \"string\") {\n continue;\n }\n if (communityAddress === identifier) {\n return true;\n }\n if (areEquivalentCommunityAddresses(communityAddress, identifier)) {\n return true;\n }\n }\n\n return false;\n};\n\nexport const getMatchingCommunityRefKeys = (\n communityRefs: CommunityLookupRef[],\n communityAddress: string | undefined,\n community?: Community,\n) => {\n const matchingCommunityKeys = new Set<string>();\n for (const communityRef of communityRefs) {\n if (doesAddressMatchCommunityRef(communityAddress, communityRef, community)) {\n matchingCommunityKeys.add(getCommunityRefKey(communityRef));\n }\n }\n return [...matchingCommunityKeys];\n};\n"]}
1
+ {"version":3,"file":"community-ref.js","sourceRoot":"","sources":["../../src/lib/community-ref.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAUtE,MAAM,yBAAyB,GAAG,CAAC,YAA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AC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,gBAA4D,EAC5D,YAA4C,EAC5C,SAAqB,EACrB,EAAE,CACF,MAAM,CAAC,IAAI,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,IAAI,CACtC,CAAC,cAAc,EAAE,EAAE,CACjB,YAAY,IAAI,4BAA4B,CAAC,cAAc,EAAE,YAAY,EAAE,SAAS,CAAC,CACxF,CAAC;AAEJ,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,aAAmC,EACnC,gBAAoC,EACpC,SAAqB,EACrB,EAAE;IACF,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;IAChD,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,IAAI,4BAA4B,CAAC,gBAAgB,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,CAAC;YAC5E,qBAAqB,CAAC,GAAG,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,qBAAqB,CAAC,CAAC;AACpC,CAAC,CAAC","sourcesContent":["import assert from \"./assert\";\nimport { Community, CommunityIdentifier } from \"../types\";\nimport { areEquivalentCommunityAddresses } from \"./community-address\";\n\ntype LegacyCommunityRef = {\n address: string;\n name?: string;\n publicKey?: string;\n};\n\nexport type CommunityLookupRef = CommunityIdentifier | LegacyCommunityRef;\n\nconst getLegacyCommunityAddress = (communityRef: CommunityLookupRef) =>\n (communityRef as LegacyCommunityRef).address;\n\nexport const getCommunityRefKey = (communityRef: CommunityLookupRef): string => {\n const communityKey =\n communityRef.publicKey || getLegacyCommunityAddress(communityRef) || communityRef.name;\n assert(typeof communityKey === \"string\" && communityKey.length > 0, \"community ref missing key\");\n return communityKey;\n};\n\nexport const getCommunityRefKeys = (communityRefs: CommunityLookupRef[]) =>\n communityRefs.map(getCommunityRefKey);\n\nexport const getCommunityLookupOptions = (communityRefOrAddress: CommunityLookupRef | string) => {\n if (typeof communityRefOrAddress === \"string\") {\n return { address: communityRefOrAddress };\n }\n\n const legacyCommunityAddress = getLegacyCommunityAddress(communityRefOrAddress);\n if (legacyCommunityAddress) {\n return { address: legacyCommunityAddress };\n }\n\n const options: { name?: string; publicKey?: string } = {};\n if (communityRefOrAddress.name) {\n options.name = communityRefOrAddress.name;\n }\n if (communityRefOrAddress.publicKey) {\n options.publicKey = communityRefOrAddress.publicKey;\n }\n return options;\n};\n\nexport const mergeCommunityRefs = (\n base: CommunityLookupRef,\n extra: CommunityLookupRef,\n): CommunityLookupRef => {\n const mergedAddress = getLegacyCommunityAddress(base) || getLegacyCommunityAddress(extra);\n const mergedName = base.name || extra.name;\n const mergedPublicKey = base.publicKey || extra.publicKey;\n if (mergedPublicKey) {\n return {\n publicKey: mergedPublicKey,\n ...(mergedAddress ? { address: mergedAddress } : undefined),\n ...(mergedName ? { name: mergedName } : undefined),\n };\n }\n if (mergedAddress) {\n return {\n address: mergedAddress,\n ...(mergedName ? { name: mergedName } : undefined),\n };\n }\n assert(typeof mergedName === \"string\" && mergedName.length > 0, \"community ref missing name\");\n return { name: mergedName };\n};\n\nexport const getUniqueSortedCommunityRefs = (communityRefs?: CommunityLookupRef[]) => {\n const refsByKey = new Map<string, CommunityLookupRef>();\n for (const communityRef of communityRefs || []) {\n const communityKey = getCommunityRefKey(communityRef);\n const existingCommunityRef = refsByKey.get(communityKey);\n refsByKey.set(\n communityKey,\n existingCommunityRef ? mergeCommunityRefs(existingCommunityRef, communityRef) : communityRef,\n );\n }\n return [...refsByKey.entries()]\n .sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey))\n .map(([, communityRef]) => communityRef);\n};\n\nexport const isCommunityRef = (value: unknown): value is CommunityLookupRef => {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return false;\n }\n\n const communityRef = value as { address?: unknown; name?: unknown; publicKey?: unknown };\n const hasAddress = typeof communityRef.address === \"string\" && communityRef.address.length > 0;\n const hasName = typeof communityRef.name === \"string\" && communityRef.name.length > 0;\n const hasPublicKey =\n typeof communityRef.publicKey === \"string\" && communityRef.publicKey.length > 0;\n\n return hasAddress || hasName || hasPublicKey;\n};\n\nexport function assertCommunityRef(\n value: unknown,\n label: string,\n): asserts value is CommunityLookupRef {\n assert(isCommunityRef(value), `${label} must be an object with address, name, or publicKey`);\n}\n\nexport const doesAddressMatchCommunityRef = (\n communityAddress: string | undefined,\n communityRef: CommunityLookupRef,\n community?: Community,\n) => {\n if (typeof communityAddress !== \"string\") {\n return false;\n }\n\n const legacyCommunityAddress = getLegacyCommunityAddress(communityRef);\n if (legacyCommunityAddress) {\n if (communityAddress === legacyCommunityAddress) {\n return true;\n }\n if (areEquivalentCommunityAddresses(communityAddress, legacyCommunityAddress)) {\n return true;\n }\n }\n if (communityRef.publicKey && communityAddress === communityRef.publicKey) {\n return true;\n }\n if (communityRef.name) {\n if (communityAddress === communityRef.name) {\n return true;\n }\n if (areEquivalentCommunityAddresses(communityAddress, communityRef.name)) {\n return true;\n }\n }\n\n const communityIdentifiers = [community?.address, community?.publicKey, community?.name];\n for (const identifier of communityIdentifiers) {\n if (typeof identifier !== \"string\") {\n continue;\n }\n if (communityAddress === identifier) {\n return true;\n }\n if (areEquivalentCommunityAddresses(communityAddress, identifier)) {\n return true;\n }\n }\n\n return false;\n};\n\n// whether an account's blocked addresses block a community, as feeds leave it out\nexport const isCommunityRefBlocked = (\n blockedAddresses: { [address: string]: unknown } | undefined,\n communityRef: CommunityLookupRef | undefined,\n community?: Community,\n) =>\n Object.keys(blockedAddresses || {}).some(\n (blockedAddress) =>\n communityRef && doesAddressMatchCommunityRef(blockedAddress, communityRef, community),\n );\n\nexport const getMatchingCommunityRefKeys = (\n communityRefs: CommunityLookupRef[],\n communityAddress: string | undefined,\n community?: Community,\n) => {\n const matchingCommunityKeys = new Set<string>();\n for (const communityRef of communityRefs) {\n if (doesAddressMatchCommunityRef(communityAddress, communityRef, community)) {\n matchingCommunityKeys.add(getCommunityRefKey(communityRef));\n }\n }\n return [...matchingCommunityKeys];\n};\n"]}
@@ -10,6 +10,9 @@ export type CommentsState = {
10
10
  openingUpdatesPending: {
11
11
  [commentCid: string]: true;
12
12
  };
13
+ loadFailed: {
14
+ [commentCid: string]: true;
15
+ };
13
16
  addCommentToStore: Function;
14
17
  startCommentAutoUpdate: Function;
15
18
  stopCommentAutoUpdate: Function;
@@ -1 +1 @@
1
- {"version":3,"file":"comments-store.d.ts","sourceRoot":"","sources":["../../../src/stores/comments/comments-store.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,eAAO,MAAM,GAAG,QAAkD,CAAC;AACnE,OAAO,EAAW,QAAQ,EAAW,MAAM,aAAa,CAAC;AAmCzD,eAAO,MAAM,SAAS,EAAE,GAAQ,CAAC;AAEjC,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,EAAE,CAAA;KAAE,CAAC;IAG1C,qBAAqB,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACtD,iBAAiB,EAAE,QAAQ,CAAC;IAC5B,sBAAsB,EAAE,QAAQ,CAAC;IACjC,qBAAqB,EAAE,QAAQ,CAAC;IAChC,sBAAsB,EAAE,QAAQ,CAAC;IACjC,yBAAyB,EAAE,QAAQ,CAAC;IACpC,cAAc,EAAE,QAAQ,CAAC;CAC1B,CAAC;AAsEF,QAAA,MAAM,aAAa,4EA+mBjB,CAAC;AAiEH,eAAO,MAAM,kBAAkB,qBAqD9B,CAAC;AAGF,eAAO,MAAM,6BAA6B,qBAGzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"comments-store.d.ts","sourceRoot":"","sources":["../../../src/stores/comments/comments-store.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,eAAO,MAAM,GAAG,QAAkD,CAAC;AACnE,OAAO,EAAW,QAAQ,EAAW,MAAM,aAAa,CAAC;AAmCzD,eAAO,MAAM,SAAS,EAAE,GAAQ,CAAC;AAEjC,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,EAAE,CAAA;KAAE,CAAC;IAG1C,qBAAqB,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAMtD,UAAU,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC3C,iBAAiB,EAAE,QAAQ,CAAC;IAC5B,sBAAsB,EAAE,QAAQ,CAAC;IACjC,qBAAqB,EAAE,QAAQ,CAAC;IAChC,sBAAsB,EAAE,QAAQ,CAAC;IACjC,yBAAyB,EAAE,QAAQ,CAAC;IACpC,cAAc,EAAE,QAAQ,CAAC;CAC1B,CAAC;AAwFF,QAAA,MAAM,aAAa,4EA6nBjB,CAAC;AAiEH,eAAO,MAAM,kBAAkB,qBAqD9B,CAAC;AAGF,eAAO,MAAM,6BAA6B,qBAGzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -95,6 +95,20 @@ const maybeReleaseStoppedLiveComment = (commentCid, comment) => {
95
95
  }
96
96
  releaseLiveComment(commentCid, comment);
97
97
  };
98
+ // returns the same object when nothing changes, so the store doesn't notify for nothing
99
+ const getNextLoadFailed = (loadFailed, commentCid, failed) => {
100
+ if (Boolean(loadFailed[commentCid]) === failed) {
101
+ return loadFailed;
102
+ }
103
+ const nextLoadFailed = Object.assign({}, loadFailed);
104
+ if (failed) {
105
+ nextLoadFailed[commentCid] = true;
106
+ }
107
+ else {
108
+ delete nextLoadFailed[commentCid];
109
+ }
110
+ return nextLoadFailed;
111
+ };
98
112
  const commentsStore = createStore((setState, getState) => {
99
113
  const addCommentError = (commentCid, error) => {
100
114
  setState((state) => {
@@ -103,6 +117,12 @@ const commentsStore = createStore((setState, getState) => {
103
117
  return Object.assign(Object.assign({}, state), { errors: Object.assign(Object.assign({}, state.errors), { [commentCid]: commentErrors }) });
104
118
  });
105
119
  };
120
+ const setLoadFailed = (commentCid) => {
121
+ setState((state) => {
122
+ const loadFailed = getNextLoadFailed(state.loadFailed, commentCid, true);
123
+ return loadFailed === state.loadFailed ? state : { loadFailed };
124
+ });
125
+ };
106
126
  const persistComment = (commentCid, nextComment) => __awaiter(void 0, void 0, void 0, function* () {
107
127
  const normalizedComment = normalizeCommentCommunityAddress(utils.clone(nextComment));
108
128
  // Store the update before the database write. pkc-js emits "updatingstatechange" right after
@@ -207,6 +227,7 @@ const commentsStore = createStore((setState, getState) => {
207
227
  addCommentError(commentCid, updateError);
208
228
  }
209
229
  }
230
+ setLoadFailed(commentCid);
210
231
  maybeStopCommentAfterOneShotUpdate(commentCid, comment);
211
232
  endOpeningUpdate(commentCid);
212
233
  return updateError;
@@ -256,6 +277,9 @@ const commentsStore = createStore((setState, getState) => {
256
277
  (_b = comment === null || comment === void 0 ? void 0 : comment.on) === null || _b === void 0 ? void 0 : _b.call(comment, "updatingstatechange", (updatingState) => {
257
278
  setState((state) => ({
258
279
  comments: Object.assign(Object.assign({}, state.comments), { [commentCid]: Object.assign(Object.assign({}, state.comments[commentCid]), { updatingState }) }),
280
+ loadFailed: updatingState === "failed" || updatingState === "succeeded"
281
+ ? getNextLoadFailed(state.loadFailed, commentCid, updatingState === "failed")
282
+ : state.loadFailed,
259
283
  }));
260
284
  if (updatingState === "succeeded" &&
261
285
  shouldRequestSparseCommentFollowup(commentCid, comment)) {
@@ -444,6 +468,7 @@ const commentsStore = createStore((setState, getState) => {
444
468
  comments: {},
445
469
  errors: {},
446
470
  openingUpdatesPending: {},
471
+ loadFailed: {},
447
472
  addCommentToStore(commentCid, account, commentData) {
448
473
  return __awaiter(this, void 0, void 0, function* () {
449
474
  var _a;
@@ -494,6 +519,7 @@ const commentsStore = createStore((setState, getState) => {
494
519
  catch (e) {
495
520
  endOpeningUpdate(commentCid);
496
521
  addCommentError(commentCid, e);
522
+ setLoadFailed(commentCid);
497
523
  throw e;
498
524
  }
499
525
  finally {