@bitsocial/bitsocial-react-hooks 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/hooks/accounts/accounts.d.ts.map +1 -1
- package/dist/hooks/accounts/accounts.js +33 -6
- package/dist/hooks/accounts/accounts.js.map +1 -1
- package/dist/hooks/comments.d.ts.map +1 -1
- package/dist/hooks/comments.js +47 -11
- package/dist/hooks/comments.js.map +1 -1
- package/dist/hooks/communities.d.ts.map +1 -1
- package/dist/hooks/communities.js +74 -16
- package/dist/hooks/communities.js.map +1 -1
- package/dist/hooks/feeds/feeds.d.ts.map +1 -1
- package/dist/hooks/feeds/feeds.js +27 -2
- package/dist/hooks/feeds/feeds.js.map +1 -1
- package/dist/lib/community-ref.d.ts +3 -0
- package/dist/lib/community-ref.d.ts.map +1 -1
- package/dist/lib/community-ref.js +2 -0
- package/dist/lib/community-ref.js.map +1 -1
- package/dist/stores/comments/comments-store.d.ts +3 -0
- package/dist/stores/comments/comments-store.d.ts.map +1 -1
- package/dist/stores/comments/comments-store.js +26 -0
- package/dist/stores/comments/comments-store.js.map +1 -1
- package/dist/stores/communities/communities-store.d.ts +4 -1
- package/dist/stores/communities/communities-store.d.ts.map +1 -1
- package/dist/stores/communities/communities-store.js +51 -7
- package/dist/stores/communities/communities-store.js.map +1 -1
- package/dist/stores/feeds/utils.d.ts.map +1 -1
- package/dist/stores/feeds/utils.js +2 -5
- package/dist/stores/feeds/utils.js.map +1 -1
- package/dist/types.d.ts +18 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communities-store.js","sourceRoot":"","sources":["../../../src/stores/communities/communities-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,cAAc,MAAM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C;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAS,EAAE;IACzD,MAAM,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,iCAAiC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IACzF,MAAM,qBAAqB,EAAE,CAAC;AAChC,CAAC,CAAA,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import assert from \"../../lib/assert\";\nimport localForageLru from \"../../lib/localforage-lru\";\nconst communitiesDatabase = localForageLru.createInstance({\n name: \"bitsocialReactHooks-communities\",\n size: 500,\n});\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:communities:stores\");\nimport {\n Community,\n Communities,\n Account,\n CommunityIdentifier,\n CommunitySyncState,\n CreateCommunityOptions,\n} from \"../../types\";\nimport utils from \"../../lib/utils\";\nimport createStore from \"zustand\";\nimport accountsStore from \"../accounts\";\nimport communitiesPagesStore from \"../communities-pages\";\nimport { getCommunityLookupOptions, getCommunityRefKey } from \"../../lib/community-ref\";\nimport {\n createPkcCommunity,\n getPkcCommunity,\n getPkcCommunityAddresses,\n getPkcCreateCommunity,\n getPkcGetCommunity,\n} from \"../../lib/pkc-compat\";\n\nexport const COMMUNITY_UPDATE_INTERVAL_MS = 15 * 60 * 1000;\n\n// How long a community keeps updating after nothing uses it anymore. pkc-js forgets the record\n// CIDs and gateway ETags it already loaded when a community stops, so every restart downloads the\n// whole record again, while a running loop downloads it once per publish. Communities publish\n// between every ~20 seconds when busy and every 15 minutes when idle, so 2 minutes keeps quick\n// back-and-forth navigation from re-downloading records and bounds what an abandoned busy\n// community costs to about one restart's worth of downloads.\nexport const COMMUNITY_UPDATE_STOP_GRACE_MS = 2 * 60 * 1000;\n\nlet pkcGetCommunityPending: { [key: string]: boolean } = {};\n\n// The pkc-js instance kept for each community in the store, keyed by community so\n// delete/reset can stop it and subscribers can stop and restart its update loop.\ntype LiveCommunity = {\n community: any;\n communityAddressOrRef: string | CommunityIdentifier;\n // defined while the update loop runs\n updateInterval?: ReturnType<typeof setInterval>;\n updateCall?: Promise<void>;\n stopping?: Promise<void>;\n // update() re-emits the record the instance already holds, recognized so it is not stored as\n // a new fetch\n replayRecordId?: string;\n // the cached record replayed on the first update() counts as fetched, a record replayed on a\n // restart keeps the fetchedAt of its real fetch\n replayRefreshesFetchedAt: boolean;\n // the loop started and has neither fetched a record nor failed yet\n openingUpdatePending: boolean;\n stopWhenOpeningUpdateEnds: boolean;\n onUpdatingStateChange: (updatingState: string) => void;\n};\nconst liveCommunities: { [communityKey: string]: LiveCommunity } = {};\n// hooks and feeds that need a community kept updating, the loop stops after the last one leaves\nconst communityUpdateSubscribers: { [communityKey: string]: Set<string> } = {};\nconst communityStopTimers: { [communityKey: string]: ReturnType<typeof setTimeout> } = {};\n\n// reset all event listeners in between tests\nconst listeners: any = [];\n\nconst COMMUNITY_ERROR_UPDATE_GRACE_MS = 1000;\nconst pendingCommunityErrorTimers: {\n [communityKey: string]: ReturnType<typeof setTimeout>[];\n} = {};\n\ninterface CommunitySyncStatus {\n syncState: CommunitySyncState;\n lastFetchAttemptAt?: number;\n lastSuccessfulFetchAt?: number;\n // why the community is being retried; retriable errors stay out of `errors` so they do not\n // flash in the UI, but a community that never loads needs a reason to show\n lastRetriableError?: Error;\n // stopped because nothing used it, the next subscriber restarts it\n stoppedUntilUsed?: true;\n}\n\nconst omitLastRetriableError = (syncStatus: CommunitySyncStatus): CommunitySyncStatus => {\n const nextSyncStatus = { ...syncStatus };\n delete nextSyncStatus.lastRetriableError;\n return nextSyncStatus;\n};\n\nconst getNowSeconds = () => Math.floor(Date.now() / 1000);\n\nconst normalizeCommunitySyncState = (updatingState: string): CommunitySyncState => {\n if (updatingState === \"waiting-retry\") {\n return \"retrying\";\n }\n if (updatingState === \"succeeded\" || updatingState === \"failed\" || updatingState === \"stopped\") {\n return updatingState;\n }\n return \"loading\";\n};\n\nconst getNextSyncStatuses = (\n state: CommunitiesState,\n communityKey: string,\n syncState: CommunitySyncState,\n) => {\n const previousStatus = state.syncStatuses[communityKey];\n const timestamp = getNowSeconds();\n const shouldRecordAttempt = syncState === \"loading\" && previousStatus?.syncState !== \"loading\";\n const nextStatus: CommunitySyncStatus = {\n ...previousStatus,\n syncState,\n ...(shouldRecordAttempt ? { lastFetchAttemptAt: timestamp } : undefined),\n ...(syncState === \"succeeded\" ? { lastSuccessfulFetchAt: timestamp } : undefined),\n };\n return {\n ...state.syncStatuses,\n // a success ends the retries, so their error is no longer current\n [communityKey]: syncState === \"succeeded\" ? omitLastRetriableError(nextStatus) : nextStatus,\n };\n};\n\nconst updateCommunitySyncStatus = (\n setState: Function,\n communityKey: string,\n syncState: CommunitySyncState,\n) => {\n setState((state: CommunitiesState) => ({\n ...state,\n syncStatuses: getNextSyncStatuses(state, communityKey, syncState),\n }));\n};\n\n// identifies a signed community record, to recognize pkc-js re-emitting a record already in the store\nconst getCommunityRecordId = (community: any): string | undefined => {\n const signature = community?.signature?.signature;\n if (typeof signature !== \"string\" || typeof community?.updatedAt !== \"number\") {\n return;\n }\n return `${community.updatedAt}:${signature}`;\n};\n\nconst createCommunityWithLookupFallback = async (\n pkc: any,\n communityLookupOptions: { address?: string; name?: string; publicKey?: string },\n communityKey: string,\n) => {\n const supportsAddressLookup = \"address\" in communityLookupOptions;\n const community = await createPkcCommunity(pkc, communityLookupOptions);\n if (community?.address || supportsAddressLookup) {\n return community;\n }\n throw Error(`communitiesStore.addCommunityToStore failed getting community '${communityKey}'`);\n};\n\nconst getCommunityKey = (communityAddressOrRef: string | CommunityIdentifier) =>\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n\nconst hasCommunityUpdateSubscribers = (communityKey: string) =>\n (communityUpdateSubscribers[communityKey]?.size || 0) > 0;\n\nconst updateCommunity = (communityKey: string, liveCommunity: LiveCommunity) => {\n const { community, communityAddressOrRef } = liveCommunity;\n liveCommunity.updateCall = Promise.resolve()\n .then(() => community.update())\n .catch((error: unknown) =>\n log.trace(\"community.update error\", {\n communityAddressOrRef,\n communityKey,\n community,\n error,\n }),\n );\n};\n\nconst startCommunityUpdatePolling = (communityKey: string, liveCommunity: LiveCommunity) => {\n clearInterval(liveCommunity.updateInterval);\n liveCommunity.openingUpdatePending = true;\n liveCommunity.stopWhenOpeningUpdateEnds = false;\n updateCommunity(communityKey, liveCommunity);\n liveCommunity.updateInterval = setInterval(\n () => updateCommunity(communityKey, liveCommunity),\n COMMUNITY_UPDATE_INTERVAL_MS,\n );\n};\n\nconst pauseCommunityUpdatePolling = (communityKey: string) => {\n const liveCommunity = liveCommunities[communityKey];\n if (!liveCommunity?.updateInterval) {\n return;\n }\n clearInterval(liveCommunity.updateInterval);\n liveCommunity.updateInterval = undefined;\n liveCommunity.openingUpdatePending = false;\n liveCommunity.stopWhenOpeningUpdateEnds = false;\n liveCommunity.replayRecordId = undefined;\n clearPendingCommunityErrors(communityKey);\n const { community, updateCall } = liveCommunity;\n // stopping while update() is still attaching to the shared updating instance would leave its\n // listeners attached, so wait for the call to return first\n const stopping = (async () => {\n await updateCall;\n if (typeof community.stop !== \"function\") {\n return;\n }\n try {\n await community.stop();\n } catch (error) {\n log.trace(\"community.stop error\", { communityKey, community, error });\n }\n })();\n liveCommunity.stopping = stopping;\n stopping.finally(() => {\n if (liveCommunity.stopping === stopping) {\n liveCommunity.stopping = undefined;\n }\n });\n log(\"communitiesStore community update loop stopped\", { communityKey });\n};\n\nconst resumeCommunityUpdatePolling = async (communityKey: string) => {\n const liveCommunity = liveCommunities[communityKey];\n if (!liveCommunity || liveCommunity.updateInterval) {\n return;\n }\n // update() is a no-op until a stop in progress ends\n if (liveCommunity.stopping) {\n await liveCommunity.stopping;\n }\n if (\n liveCommunities[communityKey] !== liveCommunity ||\n liveCommunity.updateInterval ||\n !hasCommunityUpdateSubscribers(communityKey)\n ) {\n return;\n }\n liveCommunity.replayRecordId = getCommunityRecordId(liveCommunity.community);\n liveCommunity.replayRefreshesFetchedAt = false;\n startCommunityUpdatePolling(communityKey, liveCommunity);\n log(\"communitiesStore community update loop restarted\", { communityKey });\n // joining a shared pkc-js instance that another consumer kept updating emits no state change\n // until its next fetch, so take its current state\n await liveCommunity.updateCall;\n const { updatingState } = liveCommunity.community;\n if (\n liveCommunity.updateInterval &&\n typeof updatingState === \"string\" &&\n updatingState !== \"stopped\" &&\n communitiesStore.getState().syncStatuses[communityKey]?.stoppedUntilUsed\n ) {\n liveCommunity.onUpdatingStateChange(updatingState);\n }\n};\n\nconst clearCommunityStopTimer = (communityKey: string) => {\n clearTimeout(communityStopTimers[communityKey]);\n delete communityStopTimers[communityKey];\n};\n\nconst scheduleCommunityUpdateStop = (communityKey: string) => {\n clearCommunityStopTimer(communityKey);\n communityStopTimers[communityKey] = setTimeout(() => {\n delete communityStopTimers[communityKey];\n const liveCommunity = liveCommunities[communityKey];\n if (hasCommunityUpdateSubscribers(communityKey) || !liveCommunity?.updateInterval) {\n return;\n }\n // stopping before the first fetch ends would leave a store-level caller without the record\n // it loaded the community for\n if (liveCommunity.openingUpdatePending) {\n liveCommunity.stopWhenOpeningUpdateEnds = true;\n return;\n }\n pauseCommunityUpdatePolling(communityKey);\n }, COMMUNITY_UPDATE_STOP_GRACE_MS);\n};\n\nconst endOpeningCommunityUpdate = (communityKey: string, liveCommunity: LiveCommunity) => {\n if (!liveCommunity.openingUpdatePending) {\n return;\n }\n liveCommunity.openingUpdatePending = false;\n if (!liveCommunity.stopWhenOpeningUpdateEnds) {\n return;\n }\n liveCommunity.stopWhenOpeningUpdateEnds = false;\n if (!hasCommunityUpdateSubscribers(communityKey)) {\n pauseCommunityUpdatePolling(communityKey);\n }\n};\n\nconst stopCommunityUpdatePolling = (communityKey: string) => {\n clearCommunityStopTimer(communityKey);\n const liveCommunity = liveCommunities[communityKey];\n if (!liveCommunity) {\n return;\n }\n\n clearPendingCommunityErrors(communityKey);\n clearInterval(liveCommunity.updateInterval);\n liveCommunity.updateInterval = undefined;\n liveCommunity.community.removeAllListeners();\n const listenerIndex = listeners.indexOf(liveCommunity.community);\n if (listenerIndex >= 0) {\n listeners.splice(listenerIndex, 1);\n }\n delete liveCommunities[communityKey];\n};\n\nconst clearPendingCommunityErrors = (communityKey: string) => {\n pendingCommunityErrorTimers[communityKey]?.forEach((timeout) => clearTimeout(timeout));\n delete pendingCommunityErrorTimers[communityKey];\n};\n\nconst clearStoredCommunityErrors = (state: CommunitiesState, communityKey: string) => {\n if (!state.errors[communityKey]) {\n return state.errors;\n }\n const nextErrors = { ...state.errors };\n delete nextErrors[communityKey];\n return nextErrors;\n};\n\n// returning the same state skips notifying subscribers when there is nothing to clear\nconst clearStoredCommunityErrorsState = (state: CommunitiesState, communityKey: string) => {\n const syncStatus = state.syncStatuses[communityKey];\n const hasRetriableError = syncStatus?.lastRetriableError !== undefined;\n if (!state.errors[communityKey] && !hasRetriableError) {\n return state;\n }\n return {\n ...state,\n errors: clearStoredCommunityErrors(state, communityKey),\n syncStatuses: hasRetriableError\n ? { ...state.syncStatuses, [communityKey]: omitLastRetriableError(syncStatus) }\n : state.syncStatuses,\n };\n};\n\nexport const isRetriableCommunityLoadError = (error: Error) => {\n const details = (error as Error & { details?: unknown }).details;\n return Boolean(\n details &&\n typeof details === \"object\" &&\n \"retriableError\" in details &&\n (details as { retriableError?: unknown }).retriableError === true,\n );\n};\n\nconst recordRetriableCommunityError = (setState: Function, communityKey: string, error: Error) => {\n setState((state: CommunitiesState) => {\n const syncStatus = state.syncStatuses[communityKey];\n // a deleted community has no sync status left to report on\n if (!syncStatus) {\n return state;\n }\n return {\n syncStatuses: {\n ...state.syncStatuses,\n [communityKey]: { ...syncStatus, lastRetriableError: error },\n },\n };\n });\n};\n\nconst scheduleCommunityError = (setState: Function, communityKey: string, error: Error) => {\n if (isRetriableCommunityLoadError(error)) {\n recordRetriableCommunityError(setState, communityKey, error);\n return;\n }\n\n const timeout = setTimeout(() => {\n const pendingTimeouts = pendingCommunityErrorTimers[communityKey];\n if (!pendingTimeouts?.includes(timeout)) {\n return;\n }\n\n const remainingTimeouts = pendingTimeouts.filter(\n (pendingTimeout) => pendingTimeout !== timeout,\n );\n if (remainingTimeouts.length === 0) {\n delete pendingCommunityErrorTimers[communityKey];\n } else {\n pendingCommunityErrorTimers[communityKey] = remainingTimeouts;\n }\n setState((state: CommunitiesState) => {\n const communityErrors = state.errors[communityKey] || [];\n return {\n ...state,\n errors: { ...state.errors, [communityKey]: [...communityErrors, error] },\n };\n });\n }, COMMUNITY_ERROR_UPDATE_GRACE_MS);\n\n pendingCommunityErrorTimers[communityKey] = [\n ...(pendingCommunityErrorTimers[communityKey] || []),\n timeout,\n ];\n};\n\nexport type CommunitiesState = {\n communities: Communities;\n errors: { [communityAddress: string]: Error[] };\n syncStatuses: { [communityAddress: string]: CommunitySyncStatus };\n addCommunityToStore: Function;\n startCommunityAutoUpdate: Function;\n stopCommunityAutoUpdate: Function;\n refreshCommunity: Function;\n editCommunity: Function;\n createCommunity: Function;\n deleteCommunity: Function;\n};\n\nconst communitiesStore = createStore<CommunitiesState>(\n (setState: Function, getState: Function) => ({\n communities: {},\n errors: {},\n syncStatuses: {},\n\n async addCommunityToStore(\n communityAddressOrRef: string | CommunityIdentifier,\n account: Account,\n ) {\n const communityLookupOptions = getCommunityLookupOptions(communityAddressOrRef);\n const communityKey =\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.addCommunityToStore invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.addCommunityToStore invalid account argument '${account}'`,\n );\n\n // community is in store already, do nothing\n const { communities } = getState();\n let community: Community | undefined = communities[communityKey];\n const pendingKey = communityKey + account.id;\n if (community || pkcGetCommunityPending[pendingKey]) {\n return;\n }\n\n // start trying to get community\n pkcGetCommunityPending[pendingKey] = true;\n updateCommunitySyncStatus(setState, communityKey, \"initializing\");\n let errorGettingCommunity: any;\n try {\n // try to find community in owner communities\n if (getPkcCommunityAddresses(account.pkc).includes(communityKey)) {\n try {\n community = await createCommunityWithLookupFallback(\n account.pkc,\n communityLookupOptions,\n communityKey,\n );\n } catch (e) {\n errorGettingCommunity = e;\n }\n }\n\n // try to find community in database\n let fetchedAt: number | undefined;\n let isFromCache = false;\n if (!community) {\n const communityData: any = await communitiesDatabase.getItem(communityKey);\n const lookupName =\n \"name\" in communityLookupOptions ? communityLookupOptions.name : undefined;\n const lookupPublicKey =\n \"publicKey\" in communityLookupOptions ? communityLookupOptions.publicKey : undefined;\n const lookupAddress =\n \"address\" in communityLookupOptions ? communityLookupOptions.address : undefined;\n const hasCachedPosts =\n Object.keys(communityData?.posts?.pageCids || {}).length > 0 ||\n Object.keys(communityData?.posts?.pages || {}).length > 0;\n const isUnresolvedNameCache =\n communityData &&\n lookupName &&\n !lookupPublicKey &&\n !lookupAddress &&\n !communityData.publicKey &&\n !communityData.updatedAt &&\n !communityData.updateCid &&\n !communityData.title &&\n !communityData.description &&\n !hasCachedPosts;\n if (communityData && !isUnresolvedNameCache) {\n fetchedAt = communityData.fetchedAt;\n delete communityData.fetchedAt; // not part of pkc-js schema\n try {\n community = await createPkcCommunity(account.pkc, communityData);\n isFromCache = Boolean(community);\n } catch (e) {\n fetchedAt = undefined;\n // need to log this always or it could silently fail in production and cache never be used\n console.error(\"failed pkc.createCommunity(cachedCommunity)\", {\n cachedCommunity: communityData,\n error: e,\n });\n }\n }\n if (community) {\n // add page comments to communitiesPagesStore so they can be used in useComment\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(community);\n }\n }\n\n // community not in database, try to fetch from pkc-js\n if (!community) {\n try {\n community = await createCommunityWithLookupFallback(\n account.pkc,\n communityLookupOptions,\n communityKey,\n );\n } catch (e) {\n errorGettingCommunity = e;\n }\n }\n\n // failure getting community\n if (!community) {\n if (errorGettingCommunity) {\n setState((state: CommunitiesState) => {\n let communityErrors = state.errors[communityKey] || [];\n communityErrors = [...communityErrors, errorGettingCommunity];\n return { ...state, errors: { ...state.errors, [communityKey]: communityErrors } };\n });\n }\n\n throw (\n errorGettingCommunity ||\n Error(`communitiesStore.addCommunityToStore failed getting community '${communityKey}'`)\n );\n }\n\n // success getting community\n const firstCommunityState = utils.clone({\n ...community,\n ...(fetchedAt !== undefined ? { fetchedAt } : undefined),\n });\n // a cache hit already is the database entry, rewriting it would only delay the store\n // update behind an IndexedDB write of the whole record\n if (!isFromCache) {\n await communitiesDatabase.setItem(communityKey, firstCommunityState);\n }\n // another load of this community, e.g. by another account, finished first and keeps it\n // updating, so this instance is discarded before it starts updating\n if (liveCommunities[communityKey]) {\n return;\n }\n log(\"communitiesStore.addCommunityToStore\", {\n communityAddressOrRef,\n communityKey,\n community,\n account,\n });\n setState((state: any) => ({\n communities: { ...state.communities, [communityKey]: firstCommunityState },\n }));\n\n const liveCommunity: LiveCommunity = {\n community,\n communityAddressOrRef,\n // pkc-js re-emits the record a community was created with when update() starts\n replayRecordId: isFromCache ? getCommunityRecordId(firstCommunityState) : undefined,\n replayRefreshesFetchedAt: true,\n openingUpdatePending: false,\n stopWhenOpeningUpdateEnds: false,\n onUpdatingStateChange: (updatingState: string) => {\n setState((state: CommunitiesState) => {\n const syncStatuses = getNextSyncStatuses(\n state,\n communityKey,\n normalizeCommunitySyncState(updatingState),\n );\n const { stoppedUntilUsed: _stoppedUntilUsed, ...syncStatus } =\n syncStatuses[communityKey];\n // the loop is not running when the store stopped the community itself\n syncStatuses[communityKey] =\n updatingState === \"stopped\" && !liveCommunity.updateInterval\n ? { ...syncStatus, stoppedUntilUsed: true }\n : syncStatus;\n return {\n syncStatuses,\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], updatingState },\n },\n };\n });\n if (\n updatingState === \"succeeded\" ||\n updatingState === \"failed\" ||\n updatingState === \"waiting-retry\"\n ) {\n endOpeningCommunityUpdate(communityKey, liveCommunity);\n }\n },\n };\n\n // the community has published new posts\n community.on(\"update\", async (updatedCommunity: Community) => {\n clearPendingCommunityErrors(communityKey);\n setState((state: CommunitiesState) =>\n clearStoredCommunityErrorsState(state, communityKey),\n );\n\n const isRecordReplay =\n liveCommunity.replayRecordId !== undefined &&\n getCommunityRecordId(updatedCommunity) === liveCommunity.replayRecordId;\n liveCommunity.replayRecordId = undefined;\n if (isRecordReplay && !liveCommunity.replayRefreshesFetchedAt) {\n // a restarted loop replays the record the store already has, it was not fetched now\n return;\n }\n if (isRecordReplay) {\n // the replayed record is already in the store and the database, only refresh fetchedAt\n // like a fetched update would, without cloning and rewriting the whole record\n setState((state: CommunitiesState) => {\n const storedCommunity = state.communities[communityKey];\n if (!storedCommunity) {\n return state;\n }\n return {\n communities: {\n ...state.communities,\n [communityKey]: { ...storedCommunity, fetchedAt: getNowSeconds() },\n },\n };\n });\n // pass the cloned record, account state keeps references to its roles\n accountsStore\n .getState()\n .accountsActionsInternal.addCommunityRoleToAccountsCommunities(firstCommunityState);\n return;\n }\n\n updatedCommunity = utils.clone(updatedCommunity);\n\n // add fetchedAt to be able to expire the cache\n // NOTE: fetchedAt is undefined on owner communities because never stale\n updatedCommunity.fetchedAt = Math.floor(Date.now() / 1000);\n\n // pkc-js reports the fetch succeeded right after this event, so store the record first:\n // a succeeded sync state must not be shown with the previous record, e.g. a stale one\n // kept while the community was not updating\n setState((state: any) => ({\n ...state,\n communities: { ...state.communities, [communityKey]: updatedCommunity },\n }));\n log(\"communitiesStore community update\", {\n communityAddressOrRef,\n communityKey,\n updatedCommunity,\n account,\n });\n await communitiesDatabase.setItem(communityKey, updatedCommunity);\n\n if (!getState().communities[communityKey]) {\n // deleteCommunity removed the community during the write above: don't leave the record\n // cached or give its roles back to the accounts the deletion just removed it from\n await communitiesDatabase.removeItem(communityKey);\n } else {\n // if a community has a role with an account's address add it to the account.communities\n accountsStore\n .getState()\n .accountsActionsInternal.addCommunityRoleToAccountsCommunities(updatedCommunity);\n\n // add page comments to communitiesPagesStore so they can be used in useComment\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(updatedCommunity);\n }\n\n endOpeningCommunityUpdate(communityKey, liveCommunity);\n });\n\n community.on(\"updatingstatechange\", liveCommunity.onUpdatingStateChange);\n\n community.on(\"error\", (error: Error) => {\n scheduleCommunityError(setState, communityKey, error);\n });\n\n // set clients on community so the frontend can display it, dont persist in db because a reload cancels updating\n utils.clientsOnStateChange(\n community?.clients,\n (clientState: string, clientType: string, clientUrl: string, chainTicker?: string) => {\n setState((state: CommunitiesState) => {\n // make sure not undefined, sometimes happens in e2e tests\n if (!state.communities[communityKey]) {\n return state;\n }\n const clients = { ...state.communities[communityKey]?.clients };\n const client = { state: clientState };\n if (chainTicker) {\n const chainProviders = { ...clients[clientType][chainTicker], [clientUrl]: client };\n clients[clientType] = { ...clients[clientType], [chainTicker]: chainProviders };\n } else {\n clients[clientType] = { ...clients[clientType], [clientUrl]: client };\n }\n return {\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], clients },\n },\n };\n });\n },\n );\n\n listeners.push(community);\n liveCommunities[communityKey] = liveCommunity;\n startCommunityUpdatePolling(communityKey, liveCommunity);\n // joining a shared pkc-js instance that another consumer, e.g. a comment's update loop,\n // keeps updating emits no state change until its next fetch, so take its current state\n void liveCommunity.updateCall?.then(() => {\n const { updatingState } = liveCommunity.community;\n if (\n liveCommunities[communityKey] === liveCommunity &&\n liveCommunity.updateInterval &&\n typeof updatingState === \"string\" &&\n updatingState !== \"stopped\" &&\n getState().syncStatuses[communityKey]?.syncState === \"initializing\"\n ) {\n liveCommunity.onUpdatingStateChange(updatingState);\n }\n });\n // loaded without a subscriber, e.g. by a store-level caller: update until the grace period\n // ends, and at least until the first fetch ends\n if (!hasCommunityUpdateSubscribers(communityKey)) {\n scheduleCommunityUpdateStop(communityKey);\n }\n } catch (error) {\n updateCommunitySyncStatus(setState, communityKey, \"failed\");\n throw error;\n } finally {\n pkcGetCommunityPending[pendingKey] = false;\n }\n },\n\n // keep a community updating while a subscriber (a mounted hook or feed) needs it, and restart\n // its update loop if it stopped after its previous subscribers left\n async startCommunityAutoUpdate(\n communityAddressOrRef: string | CommunityIdentifier,\n subscriberId: string,\n account: Account,\n ) {\n const communityKey = getCommunityKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.startCommunityAutoUpdate invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n subscriberId && typeof subscriberId === \"string\",\n `communitiesStore.startCommunityAutoUpdate invalid subscriberId argument '${subscriberId}'`,\n );\n if (!communityUpdateSubscribers[communityKey]) {\n communityUpdateSubscribers[communityKey] = new Set();\n }\n communityUpdateSubscribers[communityKey].add(subscriberId);\n clearCommunityStopTimer(communityKey);\n\n const liveCommunity = liveCommunities[communityKey];\n if (liveCommunity) {\n liveCommunity.stopWhenOpeningUpdateEnds = false;\n await resumeCommunityUpdatePolling(communityKey);\n return;\n }\n await getState().addCommunityToStore(communityAddressOrRef, account);\n },\n\n // the community stops updating a grace period after its last subscriber leaves\n async stopCommunityAutoUpdate(\n communityAddressOrRef: string | CommunityIdentifier,\n subscriberId: string,\n ) {\n const communityKey = getCommunityKey(communityAddressOrRef);\n const subscribers = communityUpdateSubscribers[communityKey];\n if (!subscribers?.delete(subscriberId)) {\n return;\n }\n if (subscribers.size > 0) {\n return;\n }\n delete communityUpdateSubscribers[communityKey];\n if (liveCommunities[communityKey]) {\n scheduleCommunityUpdateStop(communityKey);\n }\n },\n\n async refreshCommunity(communityAddressOrRef: string | CommunityIdentifier, account: Account) {\n const communityLookupOptions = getCommunityLookupOptions(communityAddressOrRef);\n const communityKey =\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.refreshCommunity invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n typeof getPkcGetCommunity(account?.pkc) === \"function\",\n `communitiesStore.refreshCommunity invalid account argument '${account}'`,\n );\n\n const refreshedCommunity = utils.clone(\n await getPkcCommunity(account.pkc, communityLookupOptions),\n );\n refreshedCommunity.fetchedAt = Math.floor(Date.now() / 1000);\n\n await communitiesDatabase.setItem(communityKey, refreshedCommunity);\n log(\"communitiesStore.refreshCommunity\", {\n communityAddressOrRef,\n communityKey,\n refreshedCommunity,\n account,\n });\n setState((state: any) => ({\n communities: { ...state.communities, [communityKey]: refreshedCommunity },\n }));\n\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(refreshedCommunity);\n\n return refreshedCommunity;\n },\n\n // user is the owner of the community and can edit it locally\n async editCommunity(communityAddress: string, communityEditOptions: any, account: Account) {\n assert(\n communityAddress !== \"\" && typeof communityAddress === \"string\",\n `communitiesStore.editCommunity invalid communityAddress argument '${communityAddress}'`,\n );\n assert(\n communityEditOptions && typeof communityEditOptions === \"object\",\n `communitiesStore.editCommunity invalid communityEditOptions argument '${communityEditOptions}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.editCommunity invalid account argument '${account}'`,\n );\n\n // if not added to store first, community.update() is never called\n await getState().addCommunityToStore(communityAddress, account);\n\n // `communityAddress` is different from `communityEditOptions.address` when editing the community address\n const community = await createPkcCommunity(account.pkc, {\n address: communityAddress,\n });\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n await community.edit(communityEditOptions);\n\n const updatedCommunity = utils.clone(community);\n // edit db of both old and new community address to not break the UI\n await communitiesDatabase.setItem(communityAddress, updatedCommunity);\n await communitiesDatabase.setItem(community.address, updatedCommunity);\n log(\"communitiesStore.editCommunity\", {\n communityAddress,\n communityEditOptions,\n community,\n account,\n });\n setState((state: any) => ({\n communities: {\n ...state.communities,\n // edit react state of both old and new community address to not break the UI\n [communityAddress]: updatedCommunity,\n [community.address]: updatedCommunity,\n },\n }));\n },\n\n // internal action called by accountsActions.createCommunity\n async createCommunity(createCommunityOptions: CreateCommunityOptions, account: Account) {\n assert(\n !createCommunityOptions || typeof createCommunityOptions === \"object\",\n `communitiesStore.createCommunity invalid createCommunityOptions argument '${createCommunityOptions}'`,\n );\n if (!createCommunityOptions?.signer) {\n assert(\n !createCommunityOptions?.address,\n `communitiesStore.createCommunity createCommunityOptions.address '${createCommunityOptions?.address}' must be undefined to create a community`,\n );\n }\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.createCommunity invalid account argument '${account}'`,\n );\n\n const community = await createPkcCommunity(account.pkc, createCommunityOptions);\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n // if not added to store first, community.update() is never called\n await getState().addCommunityToStore(community.address, account);\n\n await communitiesDatabase.setItem(community.address, utils.clone(community));\n log(\"communitiesStore.createCommunity\", { createCommunityOptions, community, account });\n setState((state: any) => ({\n communities: { ...state.communities, [community.address]: utils.clone(community) },\n }));\n return community;\n },\n\n // internal action called by accountsActions.deleteCommunity\n async deleteCommunity(communityAddress: string, account: Account) {\n assert(\n communityAddress && typeof communityAddress === \"string\",\n `communitiesStore.deleteCommunity invalid communityAddress argument '${communityAddress}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.deleteCommunity invalid account argument '${account}'`,\n );\n\n const community = await createPkcCommunity(account.pkc, {\n address: communityAddress,\n });\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n await community.delete();\n stopCommunityUpdatePolling(communityAddress);\n await communitiesDatabase.removeItem(communityAddress);\n log(\"communitiesStore.deleteCommunity\", { communityAddress, community, account });\n setState((state: CommunitiesState) => {\n const syncStatuses = { ...state.syncStatuses };\n delete syncStatuses[communityAddress];\n const errors = { ...state.errors };\n delete errors[communityAddress];\n return {\n communities: { ...state.communities, [communityAddress]: undefined },\n errors,\n syncStatuses,\n };\n });\n },\n }),\n);\n\n// reset store in between tests\nconst originalState = communitiesStore.getState();\n// async function because some stores have async init\nexport const resetCommunitiesStore = async () => {\n pkcGetCommunityPending = {};\n Object.keys(pendingCommunityErrorTimers).forEach(clearPendingCommunityErrors);\n // remove all event listeners\n listeners.forEach((listener: any) => listener.removeAllListeners());\n listeners.length = 0;\n Object.keys(liveCommunities).forEach(stopCommunityUpdatePolling);\n Object.keys(communityStopTimers).forEach(clearCommunityStopTimer);\n for (const communityKey in communityUpdateSubscribers) {\n delete communityUpdateSubscribers[communityKey];\n }\n // destroy all component subscriptions to the store\n communitiesStore.destroy();\n // restore original state\n communitiesStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetCommunitiesDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-communities\" }).clear();\n await resetCommunitiesStore();\n};\n\nexport default communitiesStore;\n"]}
|
|
1
|
+
{"version":3,"file":"communities-store.js","sourceRoot":"","sources":["../../../src/stores/communities/communities-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,MAAM,mBAAmB,GAAG,cAAc,CAAC,cAAc,CAAC;IACxD,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE,GAAG;CACV,CAAC,CAAC;AACH,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,0CAA0C,CAAC,CAAC;AAS/D,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,aAAa,MAAM,aAAa,CAAC;AACxC,OAAO,qBAAqB,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3D,+FAA+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AC,MAAM,GAAG,CAAC,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACjE,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAClE,KAAK,MAAM,YAAY,IAAI,0BAA0B,EAAE,CAAC;QACtD,OAAO,0BAA0B,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;IACD,mDAAmD;IACnD,gBAAgB,CAAC,OAAO,EAAE,CAAC;IAC3B,yBAAyB;IACzB,gBAAgB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC3C,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAS,EAAE;IACzD,MAAM,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,iCAAiC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IACzF,MAAM,qBAAqB,EAAE,CAAC;AAChC,CAAC,CAAA,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import assert from \"../../lib/assert\";\nimport localForageLru from \"../../lib/localforage-lru\";\nconst communitiesDatabase = localForageLru.createInstance({\n name: \"bitsocialReactHooks-communities\",\n size: 500,\n});\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:communities:stores\");\nimport {\n Community,\n Communities,\n Account,\n CommunityIdentifier,\n CommunitySyncState,\n CreateCommunityOptions,\n} from \"../../types\";\nimport utils from \"../../lib/utils\";\nimport createStore from \"zustand\";\nimport accountsStore from \"../accounts\";\nimport communitiesPagesStore from \"../communities-pages\";\nimport { getCommunityLookupOptions, getCommunityRefKey } from \"../../lib/community-ref\";\nimport {\n createPkcCommunity,\n getPkcCommunity,\n getPkcCommunityAddresses,\n getPkcCreateCommunity,\n getPkcGetCommunity,\n} from \"../../lib/pkc-compat\";\n\nexport const COMMUNITY_UPDATE_INTERVAL_MS = 15 * 60 * 1000;\n\n// How long a community keeps updating after nothing uses it anymore. pkc-js forgets the record\n// CIDs and gateway ETags it already loaded when a community stops, so every restart downloads the\n// whole record again, while a running loop downloads it once per publish. Communities publish\n// between every ~20 seconds when busy and every 15 minutes when idle, so 2 minutes keeps quick\n// back-and-forth navigation from re-downloading records and bounds what an abandoned busy\n// community costs to about one restart's worth of downloads.\nexport const COMMUNITY_UPDATE_STOP_GRACE_MS = 2 * 60 * 1000;\n\nlet pkcGetCommunityPending: { [key: string]: boolean } = {};\n\n// The pkc-js instance kept for each community in the store, keyed by community so\n// delete/reset can stop it and subscribers can stop and restart its update loop.\ntype LiveCommunity = {\n community: any;\n communityAddressOrRef: string | CommunityIdentifier;\n // defined while the update loop runs\n updateInterval?: ReturnType<typeof setInterval>;\n updateCall?: Promise<void>;\n stopping?: Promise<void>;\n // update() re-emits the record the instance already holds, recognized so it is not stored as\n // a new fetch\n replayRecordId?: string;\n // the cached record replayed on the first update() counts as fetched, a record replayed on a\n // restart keeps the fetchedAt of its real fetch\n replayRefreshesFetchedAt: boolean;\n // the loop started and has neither fetched a record nor failed yet\n openingUpdatePending: boolean;\n stopWhenOpeningUpdateEnds: boolean;\n onUpdatingStateChange: (updatingState: string) => void;\n};\nconst liveCommunities: { [communityKey: string]: LiveCommunity } = {};\n// hooks and feeds that need a community kept updating, the loop stops after the last one leaves\nconst communityUpdateSubscribers: { [communityKey: string]: Set<string> } = {};\nconst communityStopTimers: { [communityKey: string]: ReturnType<typeof setTimeout> } = {};\n\n// reset all event listeners in between tests\nconst listeners: any = [];\n\nconst COMMUNITY_ERROR_UPDATE_GRACE_MS = 1000;\nconst pendingCommunityErrorTimers: {\n [communityKey: string]: ReturnType<typeof setTimeout>[];\n} = {};\n\ninterface CommunitySyncStatus {\n syncState: CommunitySyncState;\n lastFetchAttemptAt?: number;\n lastSuccessfulFetchAt?: number;\n // why the community is being retried; retriable errors stay out of `errors` so they do not\n // flash in the UI, but a community that never loads needs a reason to show\n lastRetriableError?: Error;\n // stopped because nothing used it, the next subscriber restarts it\n stoppedUntilUsed?: true;\n // a load of the community failed while it had no record: \"retriable\" while pkc-js retries it\n // after an error, e.g. an unreachable community, which it retries forever between loading and\n // retrying, so the sync state alone never says the first load failed; \"non-retriable\" once a\n // load threw, update() rejected or pkc-js reported failed. Kept through the next attempts, a\n // later retriable failure doesn't downgrade a non-retriable one, until a record loads.\n firstLoadFailure?: CommunityFirstLoadFailure;\n}\n\ntype CommunityFirstLoadFailure = \"retriable\" | \"non-retriable\";\n\nconst hasCommunityRecord = (community: Community | undefined) =>\n typeof community?.updatedAt === \"number\";\n\n// how the first load of a community without a record failed, if it did; read it with the\n// community, because a record can arrive without a sync state change, e.g. from the pkc-js RPC client\nexport const getCommunityFirstLoadFailure = (\n syncStatus: CommunitySyncStatus | undefined,\n community: Community | undefined,\n): CommunityFirstLoadFailure | undefined =>\n hasCommunityRecord(community) ? undefined : syncStatus?.firstLoadFailure;\n\nconst getNextFirstLoadFailure = (\n firstLoadFailure: CommunityFirstLoadFailure | undefined,\n syncState: CommunitySyncState,\n hasRecord: boolean,\n): CommunityFirstLoadFailure | undefined => {\n if (hasRecord || syncState === \"succeeded\") {\n return undefined;\n }\n if (syncState === \"failed\") {\n return \"non-retriable\";\n }\n if (syncState === \"retrying\" && firstLoadFailure !== \"non-retriable\") {\n return \"retriable\";\n }\n return firstLoadFailure;\n};\n\n// a stored record ends a failed first load\nconst withCommunityRecordSyncStatus = (\n syncStatuses: CommunitiesState[\"syncStatuses\"],\n communityKey: string,\n community: Community | undefined,\n) => {\n const syncStatus = syncStatuses[communityKey];\n if (!syncStatus?.firstLoadFailure || !hasCommunityRecord(community)) {\n return syncStatuses;\n }\n const { firstLoadFailure: _firstLoadFailure, ...nextSyncStatus } = syncStatus;\n return { ...syncStatuses, [communityKey]: nextSyncStatus };\n};\n\nconst omitLastRetriableError = (syncStatus: CommunitySyncStatus): CommunitySyncStatus => {\n const nextSyncStatus = { ...syncStatus };\n delete nextSyncStatus.lastRetriableError;\n return nextSyncStatus;\n};\n\nconst getNowSeconds = () => Math.floor(Date.now() / 1000);\n\nconst normalizeCommunitySyncState = (updatingState: string): CommunitySyncState => {\n if (updatingState === \"waiting-retry\") {\n return \"retrying\";\n }\n if (updatingState === \"succeeded\" || updatingState === \"failed\" || updatingState === \"stopped\") {\n return updatingState;\n }\n return \"loading\";\n};\n\nconst getNextSyncStatuses = (\n state: CommunitiesState,\n communityKey: string,\n syncState: CommunitySyncState,\n) => {\n const previousStatus = state.syncStatuses[communityKey];\n const timestamp = getNowSeconds();\n const shouldRecordAttempt = syncState === \"loading\" && previousStatus?.syncState !== \"loading\";\n const nextStatus: CommunitySyncStatus = {\n ...previousStatus,\n syncState,\n ...(shouldRecordAttempt ? { lastFetchAttemptAt: timestamp } : undefined),\n ...(syncState === \"succeeded\" ? { lastSuccessfulFetchAt: timestamp } : undefined),\n };\n const firstLoadFailure = getNextFirstLoadFailure(\n previousStatus?.firstLoadFailure,\n syncState,\n hasCommunityRecord(state.communities[communityKey]),\n );\n if (firstLoadFailure) {\n nextStatus.firstLoadFailure = firstLoadFailure;\n } else {\n delete nextStatus.firstLoadFailure;\n }\n return {\n ...state.syncStatuses,\n // a success ends the retries, so their error is no longer current\n [communityKey]: syncState === \"succeeded\" ? omitLastRetriableError(nextStatus) : nextStatus,\n };\n};\n\nconst updateCommunitySyncStatus = (\n setState: Function,\n communityKey: string,\n syncState: CommunitySyncState,\n) => {\n setState((state: CommunitiesState) => ({\n ...state,\n syncStatuses: getNextSyncStatuses(state, communityKey, syncState),\n }));\n};\n\n// identifies a signed community record, to recognize pkc-js re-emitting a record already in the store\nconst getCommunityRecordId = (community: any): string | undefined => {\n const signature = community?.signature?.signature;\n if (typeof signature !== \"string\" || typeof community?.updatedAt !== \"number\") {\n return;\n }\n return `${community.updatedAt}:${signature}`;\n};\n\nconst createCommunityWithLookupFallback = async (\n pkc: any,\n communityLookupOptions: { address?: string; name?: string; publicKey?: string },\n communityKey: string,\n) => {\n const supportsAddressLookup = \"address\" in communityLookupOptions;\n const community = await createPkcCommunity(pkc, communityLookupOptions);\n if (community?.address || supportsAddressLookup) {\n return community;\n }\n throw Error(`communitiesStore.addCommunityToStore failed getting community '${communityKey}'`);\n};\n\nconst getCommunityKey = (communityAddressOrRef: string | CommunityIdentifier) =>\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n\nconst hasCommunityUpdateSubscribers = (communityKey: string) =>\n (communityUpdateSubscribers[communityKey]?.size || 0) > 0;\n\nconst updateCommunity = (communityKey: string, liveCommunity: LiveCommunity) => {\n const { community, communityAddressOrRef } = liveCommunity;\n liveCommunity.updateCall = Promise.resolve()\n .then(() => community.update())\n .catch((error: unknown) => {\n log.trace(\"community.update error\", {\n communityAddressOrRef,\n communityKey,\n community,\n error,\n });\n // the community could not start updating, e.g. the pkc-js RPC client failed to subscribe,\n // which reports failed and then stopped. A rejection after the store stopped it isn't one.\n if (liveCommunities[communityKey] !== liveCommunity || !liveCommunity.updateInterval) {\n return;\n }\n updateCommunitySyncStatus(communitiesStore.setState, communityKey, \"failed\");\n scheduleCommunityError(\n communitiesStore.setState,\n communityKey,\n error instanceof Error ? error : Error(String(error)),\n );\n endOpeningCommunityUpdate(communityKey, liveCommunity);\n });\n};\n\nconst startCommunityUpdatePolling = (communityKey: string, liveCommunity: LiveCommunity) => {\n clearInterval(liveCommunity.updateInterval);\n liveCommunity.openingUpdatePending = true;\n liveCommunity.stopWhenOpeningUpdateEnds = false;\n updateCommunity(communityKey, liveCommunity);\n liveCommunity.updateInterval = setInterval(\n () => updateCommunity(communityKey, liveCommunity),\n COMMUNITY_UPDATE_INTERVAL_MS,\n );\n};\n\nconst pauseCommunityUpdatePolling = (communityKey: string) => {\n const liveCommunity = liveCommunities[communityKey];\n if (!liveCommunity?.updateInterval) {\n return;\n }\n clearInterval(liveCommunity.updateInterval);\n liveCommunity.updateInterval = undefined;\n liveCommunity.openingUpdatePending = false;\n liveCommunity.stopWhenOpeningUpdateEnds = false;\n liveCommunity.replayRecordId = undefined;\n clearPendingCommunityErrors(communityKey);\n const { community, updateCall } = liveCommunity;\n // stopping while update() is still attaching to the shared updating instance would leave its\n // listeners attached, so wait for the call to return first\n const stopping = (async () => {\n await updateCall;\n if (typeof community.stop !== \"function\") {\n return;\n }\n try {\n await community.stop();\n } catch (error) {\n log.trace(\"community.stop error\", { communityKey, community, error });\n }\n })();\n liveCommunity.stopping = stopping;\n stopping.finally(() => {\n if (liveCommunity.stopping === stopping) {\n liveCommunity.stopping = undefined;\n }\n });\n log(\"communitiesStore community update loop stopped\", { communityKey });\n};\n\nconst resumeCommunityUpdatePolling = async (communityKey: string) => {\n const liveCommunity = liveCommunities[communityKey];\n if (!liveCommunity || liveCommunity.updateInterval) {\n return;\n }\n // update() is a no-op until a stop in progress ends\n if (liveCommunity.stopping) {\n await liveCommunity.stopping;\n }\n if (\n liveCommunities[communityKey] !== liveCommunity ||\n liveCommunity.updateInterval ||\n !hasCommunityUpdateSubscribers(communityKey)\n ) {\n return;\n }\n liveCommunity.replayRecordId = getCommunityRecordId(liveCommunity.community);\n liveCommunity.replayRefreshesFetchedAt = false;\n startCommunityUpdatePolling(communityKey, liveCommunity);\n log(\"communitiesStore community update loop restarted\", { communityKey });\n // joining a shared pkc-js instance that another consumer kept updating emits no state change\n // until its next fetch, so take its current state\n await liveCommunity.updateCall;\n const { updatingState } = liveCommunity.community;\n if (\n liveCommunity.updateInterval &&\n typeof updatingState === \"string\" &&\n updatingState !== \"stopped\" &&\n communitiesStore.getState().syncStatuses[communityKey]?.stoppedUntilUsed\n ) {\n liveCommunity.onUpdatingStateChange(updatingState);\n }\n};\n\nconst clearCommunityStopTimer = (communityKey: string) => {\n clearTimeout(communityStopTimers[communityKey]);\n delete communityStopTimers[communityKey];\n};\n\nconst scheduleCommunityUpdateStop = (communityKey: string) => {\n clearCommunityStopTimer(communityKey);\n communityStopTimers[communityKey] = setTimeout(() => {\n delete communityStopTimers[communityKey];\n const liveCommunity = liveCommunities[communityKey];\n if (hasCommunityUpdateSubscribers(communityKey) || !liveCommunity?.updateInterval) {\n return;\n }\n // stopping before the first fetch ends would leave a store-level caller without the record\n // it loaded the community for\n if (liveCommunity.openingUpdatePending) {\n liveCommunity.stopWhenOpeningUpdateEnds = true;\n return;\n }\n pauseCommunityUpdatePolling(communityKey);\n }, COMMUNITY_UPDATE_STOP_GRACE_MS);\n};\n\nconst endOpeningCommunityUpdate = (communityKey: string, liveCommunity: LiveCommunity) => {\n if (!liveCommunity.openingUpdatePending) {\n return;\n }\n liveCommunity.openingUpdatePending = false;\n if (!liveCommunity.stopWhenOpeningUpdateEnds) {\n return;\n }\n liveCommunity.stopWhenOpeningUpdateEnds = false;\n if (!hasCommunityUpdateSubscribers(communityKey)) {\n pauseCommunityUpdatePolling(communityKey);\n }\n};\n\nconst stopCommunityUpdatePolling = (communityKey: string) => {\n clearCommunityStopTimer(communityKey);\n const liveCommunity = liveCommunities[communityKey];\n if (!liveCommunity) {\n return;\n }\n\n clearPendingCommunityErrors(communityKey);\n clearInterval(liveCommunity.updateInterval);\n liveCommunity.updateInterval = undefined;\n liveCommunity.community.removeAllListeners();\n const listenerIndex = listeners.indexOf(liveCommunity.community);\n if (listenerIndex >= 0) {\n listeners.splice(listenerIndex, 1);\n }\n delete liveCommunities[communityKey];\n};\n\nconst clearPendingCommunityErrors = (communityKey: string) => {\n pendingCommunityErrorTimers[communityKey]?.forEach((timeout) => clearTimeout(timeout));\n delete pendingCommunityErrorTimers[communityKey];\n};\n\nconst clearStoredCommunityErrors = (state: CommunitiesState, communityKey: string) => {\n if (!state.errors[communityKey]) {\n return state.errors;\n }\n const nextErrors = { ...state.errors };\n delete nextErrors[communityKey];\n return nextErrors;\n};\n\n// returning the same state skips notifying subscribers when there is nothing to clear\nconst clearStoredCommunityErrorsState = (state: CommunitiesState, communityKey: string) => {\n const syncStatus = state.syncStatuses[communityKey];\n const hasRetriableError = syncStatus?.lastRetriableError !== undefined;\n if (!state.errors[communityKey] && !hasRetriableError) {\n return state;\n }\n return {\n ...state,\n errors: clearStoredCommunityErrors(state, communityKey),\n syncStatuses: hasRetriableError\n ? { ...state.syncStatuses, [communityKey]: omitLastRetriableError(syncStatus) }\n : state.syncStatuses,\n };\n};\n\nexport const isRetriableCommunityLoadError = (error: Error) => {\n const details = (error as Error & { details?: unknown }).details;\n return Boolean(\n details &&\n typeof details === \"object\" &&\n \"retriableError\" in details &&\n (details as { retriableError?: unknown }).retriableError === true,\n );\n};\n\nconst recordRetriableCommunityError = (setState: Function, communityKey: string, error: Error) => {\n setState((state: CommunitiesState) => {\n const syncStatus = state.syncStatuses[communityKey];\n // a deleted community has no sync status left to report on\n if (!syncStatus) {\n return state;\n }\n return {\n syncStatuses: {\n ...state.syncStatuses,\n [communityKey]: { ...syncStatus, lastRetriableError: error },\n },\n };\n });\n};\n\nconst scheduleCommunityError = (setState: Function, communityKey: string, error: Error) => {\n if (isRetriableCommunityLoadError(error)) {\n recordRetriableCommunityError(setState, communityKey, error);\n return;\n }\n\n const timeout = setTimeout(() => {\n const pendingTimeouts = pendingCommunityErrorTimers[communityKey];\n if (!pendingTimeouts?.includes(timeout)) {\n return;\n }\n\n const remainingTimeouts = pendingTimeouts.filter(\n (pendingTimeout) => pendingTimeout !== timeout,\n );\n if (remainingTimeouts.length === 0) {\n delete pendingCommunityErrorTimers[communityKey];\n } else {\n pendingCommunityErrorTimers[communityKey] = remainingTimeouts;\n }\n setState((state: CommunitiesState) => {\n const communityErrors = state.errors[communityKey] || [];\n return {\n ...state,\n errors: { ...state.errors, [communityKey]: [...communityErrors, error] },\n };\n });\n }, COMMUNITY_ERROR_UPDATE_GRACE_MS);\n\n pendingCommunityErrorTimers[communityKey] = [\n ...(pendingCommunityErrorTimers[communityKey] || []),\n timeout,\n ];\n};\n\nexport type CommunitiesState = {\n communities: Communities;\n errors: { [communityAddress: string]: Error[] };\n syncStatuses: { [communityAddress: string]: CommunitySyncStatus };\n addCommunityToStore: Function;\n startCommunityAutoUpdate: Function;\n stopCommunityAutoUpdate: Function;\n refreshCommunity: Function;\n editCommunity: Function;\n createCommunity: Function;\n deleteCommunity: Function;\n};\n\nconst communitiesStore = createStore<CommunitiesState>(\n (setState: Function, getState: Function) => ({\n communities: {},\n errors: {},\n syncStatuses: {},\n\n async addCommunityToStore(\n communityAddressOrRef: string | CommunityIdentifier,\n account: Account,\n ) {\n const communityLookupOptions = getCommunityLookupOptions(communityAddressOrRef);\n const communityKey =\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.addCommunityToStore invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.addCommunityToStore invalid account argument '${account}'`,\n );\n\n // community is in store already, do nothing\n const { communities } = getState();\n let community: Community | undefined = communities[communityKey];\n const pendingKey = communityKey + account.id;\n if (community || pkcGetCommunityPending[pendingKey]) {\n return;\n }\n\n // start trying to get community\n pkcGetCommunityPending[pendingKey] = true;\n updateCommunitySyncStatus(setState, communityKey, \"initializing\");\n let errorGettingCommunity: any;\n try {\n // try to find community in owner communities\n if (getPkcCommunityAddresses(account.pkc).includes(communityKey)) {\n try {\n community = await createCommunityWithLookupFallback(\n account.pkc,\n communityLookupOptions,\n communityKey,\n );\n } catch (e) {\n errorGettingCommunity = e;\n }\n }\n\n // try to find community in database\n let fetchedAt: number | undefined;\n let isFromCache = false;\n if (!community) {\n const communityData: any = await communitiesDatabase.getItem(communityKey);\n const lookupName =\n \"name\" in communityLookupOptions ? communityLookupOptions.name : undefined;\n const lookupPublicKey =\n \"publicKey\" in communityLookupOptions ? communityLookupOptions.publicKey : undefined;\n const lookupAddress =\n \"address\" in communityLookupOptions ? communityLookupOptions.address : undefined;\n const hasCachedPosts =\n Object.keys(communityData?.posts?.pageCids || {}).length > 0 ||\n Object.keys(communityData?.posts?.pages || {}).length > 0;\n const isUnresolvedNameCache =\n communityData &&\n lookupName &&\n !lookupPublicKey &&\n !lookupAddress &&\n !communityData.publicKey &&\n !communityData.updatedAt &&\n !communityData.updateCid &&\n !communityData.title &&\n !communityData.description &&\n !hasCachedPosts;\n if (communityData && !isUnresolvedNameCache) {\n fetchedAt = communityData.fetchedAt;\n delete communityData.fetchedAt; // not part of pkc-js schema\n try {\n community = await createPkcCommunity(account.pkc, communityData);\n isFromCache = Boolean(community);\n } catch (e) {\n fetchedAt = undefined;\n // need to log this always or it could silently fail in production and cache never be used\n console.error(\"failed pkc.createCommunity(cachedCommunity)\", {\n cachedCommunity: communityData,\n error: e,\n });\n }\n }\n if (community) {\n // add page comments to communitiesPagesStore so they can be used in useComment\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(community);\n }\n }\n\n // community not in database, try to fetch from pkc-js\n if (!community) {\n try {\n community = await createCommunityWithLookupFallback(\n account.pkc,\n communityLookupOptions,\n communityKey,\n );\n } catch (e) {\n errorGettingCommunity = e;\n }\n }\n\n // failure getting community\n if (!community) {\n if (errorGettingCommunity) {\n setState((state: CommunitiesState) => {\n let communityErrors = state.errors[communityKey] || [];\n communityErrors = [...communityErrors, errorGettingCommunity];\n return { ...state, errors: { ...state.errors, [communityKey]: communityErrors } };\n });\n }\n\n throw (\n errorGettingCommunity ||\n Error(`communitiesStore.addCommunityToStore failed getting community '${communityKey}'`)\n );\n }\n\n // success getting community\n const firstCommunityState = utils.clone({\n ...community,\n ...(fetchedAt !== undefined ? { fetchedAt } : undefined),\n });\n // a cache hit already is the database entry, rewriting it would only delay the store\n // update behind an IndexedDB write of the whole record\n if (!isFromCache) {\n await communitiesDatabase.setItem(communityKey, firstCommunityState);\n }\n // another load of this community, e.g. by another account, finished first and keeps it\n // updating, so this instance is discarded before it starts updating\n if (liveCommunities[communityKey]) {\n return;\n }\n log(\"communitiesStore.addCommunityToStore\", {\n communityAddressOrRef,\n communityKey,\n community,\n account,\n });\n setState((state: CommunitiesState) => ({\n communities: { ...state.communities, [communityKey]: firstCommunityState },\n syncStatuses: withCommunityRecordSyncStatus(\n state.syncStatuses,\n communityKey,\n firstCommunityState,\n ),\n }));\n\n const liveCommunity: LiveCommunity = {\n community,\n communityAddressOrRef,\n // pkc-js re-emits the record a community was created with when update() starts\n replayRecordId: isFromCache ? getCommunityRecordId(firstCommunityState) : undefined,\n replayRefreshesFetchedAt: true,\n openingUpdatePending: false,\n stopWhenOpeningUpdateEnds: false,\n onUpdatingStateChange: (updatingState: string) => {\n setState((state: CommunitiesState) => {\n const syncStatuses = getNextSyncStatuses(\n state,\n communityKey,\n normalizeCommunitySyncState(updatingState),\n );\n const { stoppedUntilUsed: _stoppedUntilUsed, ...syncStatus } =\n syncStatuses[communityKey];\n // the loop is not running when the store stopped the community itself\n syncStatuses[communityKey] =\n updatingState === \"stopped\" && !liveCommunity.updateInterval\n ? { ...syncStatus, stoppedUntilUsed: true }\n : syncStatus;\n return {\n syncStatuses,\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], updatingState },\n },\n };\n });\n if (\n updatingState === \"succeeded\" ||\n updatingState === \"failed\" ||\n updatingState === \"waiting-retry\"\n ) {\n endOpeningCommunityUpdate(communityKey, liveCommunity);\n }\n },\n };\n\n // the community has published new posts\n community.on(\"update\", async (updatedCommunity: Community) => {\n clearPendingCommunityErrors(communityKey);\n setState((state: CommunitiesState) =>\n clearStoredCommunityErrorsState(state, communityKey),\n );\n\n const isRecordReplay =\n liveCommunity.replayRecordId !== undefined &&\n getCommunityRecordId(updatedCommunity) === liveCommunity.replayRecordId;\n liveCommunity.replayRecordId = undefined;\n if (isRecordReplay && !liveCommunity.replayRefreshesFetchedAt) {\n // a restarted loop replays the record the store already has, it was not fetched now\n return;\n }\n if (isRecordReplay) {\n // the replayed record is already in the store and the database, only refresh fetchedAt\n // like a fetched update would, without cloning and rewriting the whole record\n setState((state: CommunitiesState) => {\n const storedCommunity = state.communities[communityKey];\n if (!storedCommunity) {\n return state;\n }\n return {\n communities: {\n ...state.communities,\n [communityKey]: { ...storedCommunity, fetchedAt: getNowSeconds() },\n },\n };\n });\n // pass the cloned record, account state keeps references to its roles\n accountsStore\n .getState()\n .accountsActionsInternal.addCommunityRoleToAccountsCommunities(firstCommunityState);\n return;\n }\n\n updatedCommunity = utils.clone(updatedCommunity);\n\n // add fetchedAt to be able to expire the cache\n // NOTE: fetchedAt is undefined on owner communities because never stale\n updatedCommunity.fetchedAt = Math.floor(Date.now() / 1000);\n\n // pkc-js reports the fetch succeeded right after this event, so store the record first:\n // a succeeded sync state must not be shown with the previous record, e.g. a stale one\n // kept while the community was not updating\n setState((state: CommunitiesState) => ({\n ...state,\n communities: { ...state.communities, [communityKey]: updatedCommunity },\n syncStatuses: withCommunityRecordSyncStatus(\n state.syncStatuses,\n communityKey,\n updatedCommunity,\n ),\n }));\n log(\"communitiesStore community update\", {\n communityAddressOrRef,\n communityKey,\n updatedCommunity,\n account,\n });\n await communitiesDatabase.setItem(communityKey, updatedCommunity);\n\n if (!getState().communities[communityKey]) {\n // deleteCommunity removed the community during the write above: don't leave the record\n // cached or give its roles back to the accounts the deletion just removed it from\n await communitiesDatabase.removeItem(communityKey);\n } else {\n // if a community has a role with an account's address add it to the account.communities\n accountsStore\n .getState()\n .accountsActionsInternal.addCommunityRoleToAccountsCommunities(updatedCommunity);\n\n // add page comments to communitiesPagesStore so they can be used in useComment\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(updatedCommunity);\n }\n\n endOpeningCommunityUpdate(communityKey, liveCommunity);\n });\n\n community.on(\"updatingstatechange\", liveCommunity.onUpdatingStateChange);\n\n community.on(\"error\", (error: Error) => {\n scheduleCommunityError(setState, communityKey, error);\n });\n\n // set clients on community so the frontend can display it, dont persist in db because a reload cancels updating\n utils.clientsOnStateChange(\n community?.clients,\n (clientState: string, clientType: string, clientUrl: string, chainTicker?: string) => {\n setState((state: CommunitiesState) => {\n // make sure not undefined, sometimes happens in e2e tests\n if (!state.communities[communityKey]) {\n return state;\n }\n const clients = { ...state.communities[communityKey]?.clients };\n const client = { state: clientState };\n if (chainTicker) {\n const chainProviders = { ...clients[clientType][chainTicker], [clientUrl]: client };\n clients[clientType] = { ...clients[clientType], [chainTicker]: chainProviders };\n } else {\n clients[clientType] = { ...clients[clientType], [clientUrl]: client };\n }\n return {\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], clients },\n },\n };\n });\n },\n );\n\n listeners.push(community);\n liveCommunities[communityKey] = liveCommunity;\n startCommunityUpdatePolling(communityKey, liveCommunity);\n // joining a shared pkc-js instance that another consumer, e.g. a comment's update loop,\n // keeps updating emits no state change until its next fetch, so take its current state\n void liveCommunity.updateCall?.then(() => {\n const { updatingState } = liveCommunity.community;\n if (\n liveCommunities[communityKey] === liveCommunity &&\n liveCommunity.updateInterval &&\n typeof updatingState === \"string\" &&\n updatingState !== \"stopped\" &&\n getState().syncStatuses[communityKey]?.syncState === \"initializing\"\n ) {\n liveCommunity.onUpdatingStateChange(updatingState);\n }\n });\n // loaded without a subscriber, e.g. by a store-level caller: update until the grace period\n // ends, and at least until the first fetch ends\n if (!hasCommunityUpdateSubscribers(communityKey)) {\n scheduleCommunityUpdateStop(communityKey);\n }\n } catch (error) {\n updateCommunitySyncStatus(setState, communityKey, \"failed\");\n throw error;\n } finally {\n pkcGetCommunityPending[pendingKey] = false;\n }\n },\n\n // keep a community updating while a subscriber (a mounted hook or feed) needs it, and restart\n // its update loop if it stopped after its previous subscribers left\n async startCommunityAutoUpdate(\n communityAddressOrRef: string | CommunityIdentifier,\n subscriberId: string,\n account: Account,\n ) {\n const communityKey = getCommunityKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.startCommunityAutoUpdate invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n subscriberId && typeof subscriberId === \"string\",\n `communitiesStore.startCommunityAutoUpdate invalid subscriberId argument '${subscriberId}'`,\n );\n if (!communityUpdateSubscribers[communityKey]) {\n communityUpdateSubscribers[communityKey] = new Set();\n }\n communityUpdateSubscribers[communityKey].add(subscriberId);\n clearCommunityStopTimer(communityKey);\n\n const liveCommunity = liveCommunities[communityKey];\n if (liveCommunity) {\n liveCommunity.stopWhenOpeningUpdateEnds = false;\n await resumeCommunityUpdatePolling(communityKey);\n return;\n }\n await getState().addCommunityToStore(communityAddressOrRef, account);\n },\n\n // the community stops updating a grace period after its last subscriber leaves\n async stopCommunityAutoUpdate(\n communityAddressOrRef: string | CommunityIdentifier,\n subscriberId: string,\n ) {\n const communityKey = getCommunityKey(communityAddressOrRef);\n const subscribers = communityUpdateSubscribers[communityKey];\n if (!subscribers?.delete(subscriberId)) {\n return;\n }\n if (subscribers.size > 0) {\n return;\n }\n delete communityUpdateSubscribers[communityKey];\n if (liveCommunities[communityKey]) {\n scheduleCommunityUpdateStop(communityKey);\n }\n },\n\n async refreshCommunity(communityAddressOrRef: string | CommunityIdentifier, account: Account) {\n const communityLookupOptions = getCommunityLookupOptions(communityAddressOrRef);\n const communityKey =\n typeof communityAddressOrRef === \"string\"\n ? communityAddressOrRef\n : getCommunityRefKey(communityAddressOrRef);\n assert(\n communityKey !== \"\" && typeof communityKey === \"string\",\n `communitiesStore.refreshCommunity invalid communityAddress argument '${communityAddressOrRef}'`,\n );\n assert(\n typeof getPkcGetCommunity(account?.pkc) === \"function\",\n `communitiesStore.refreshCommunity invalid account argument '${account}'`,\n );\n\n const refreshedCommunity = utils.clone(\n await getPkcCommunity(account.pkc, communityLookupOptions),\n );\n refreshedCommunity.fetchedAt = Math.floor(Date.now() / 1000);\n\n await communitiesDatabase.setItem(communityKey, refreshedCommunity);\n log(\"communitiesStore.refreshCommunity\", {\n communityAddressOrRef,\n communityKey,\n refreshedCommunity,\n account,\n });\n setState((state: CommunitiesState) => ({\n communities: { ...state.communities, [communityKey]: refreshedCommunity },\n syncStatuses: withCommunityRecordSyncStatus(\n state.syncStatuses,\n communityKey,\n refreshedCommunity,\n ),\n }));\n\n communitiesPagesStore.getState().addCommunityPageCommentsToStore(refreshedCommunity);\n\n return refreshedCommunity;\n },\n\n // user is the owner of the community and can edit it locally\n async editCommunity(communityAddress: string, communityEditOptions: any, account: Account) {\n assert(\n communityAddress !== \"\" && typeof communityAddress === \"string\",\n `communitiesStore.editCommunity invalid communityAddress argument '${communityAddress}'`,\n );\n assert(\n communityEditOptions && typeof communityEditOptions === \"object\",\n `communitiesStore.editCommunity invalid communityEditOptions argument '${communityEditOptions}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.editCommunity invalid account argument '${account}'`,\n );\n\n // if not added to store first, community.update() is never called\n await getState().addCommunityToStore(communityAddress, account);\n\n // `communityAddress` is different from `communityEditOptions.address` when editing the community address\n const community = await createPkcCommunity(account.pkc, {\n address: communityAddress,\n });\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n await community.edit(communityEditOptions);\n\n const updatedCommunity = utils.clone(community);\n // edit db of both old and new community address to not break the UI\n await communitiesDatabase.setItem(communityAddress, updatedCommunity);\n await communitiesDatabase.setItem(community.address, updatedCommunity);\n log(\"communitiesStore.editCommunity\", {\n communityAddress,\n communityEditOptions,\n community,\n account,\n });\n setState((state: any) => ({\n communities: {\n ...state.communities,\n // edit react state of both old and new community address to not break the UI\n [communityAddress]: updatedCommunity,\n [community.address]: updatedCommunity,\n },\n }));\n },\n\n // internal action called by accountsActions.createCommunity\n async createCommunity(createCommunityOptions: CreateCommunityOptions, account: Account) {\n assert(\n !createCommunityOptions || typeof createCommunityOptions === \"object\",\n `communitiesStore.createCommunity invalid createCommunityOptions argument '${createCommunityOptions}'`,\n );\n if (!createCommunityOptions?.signer) {\n assert(\n !createCommunityOptions?.address,\n `communitiesStore.createCommunity createCommunityOptions.address '${createCommunityOptions?.address}' must be undefined to create a community`,\n );\n }\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.createCommunity invalid account argument '${account}'`,\n );\n\n const community = await createPkcCommunity(account.pkc, createCommunityOptions);\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n // if not added to store first, community.update() is never called\n await getState().addCommunityToStore(community.address, account);\n\n await communitiesDatabase.setItem(community.address, utils.clone(community));\n log(\"communitiesStore.createCommunity\", { createCommunityOptions, community, account });\n setState((state: any) => ({\n communities: { ...state.communities, [community.address]: utils.clone(community) },\n }));\n return community;\n },\n\n // internal action called by accountsActions.deleteCommunity\n async deleteCommunity(communityAddress: string, account: Account) {\n assert(\n communityAddress && typeof communityAddress === \"string\",\n `communitiesStore.deleteCommunity invalid communityAddress argument '${communityAddress}'`,\n );\n assert(\n typeof getPkcCreateCommunity(account?.pkc) === \"function\",\n `communitiesStore.deleteCommunity invalid account argument '${account}'`,\n );\n\n const community = await createPkcCommunity(account.pkc, {\n address: communityAddress,\n });\n\n // could fix some test issues\n community.on(\"error\", console.log);\n\n await community.delete();\n stopCommunityUpdatePolling(communityAddress);\n await communitiesDatabase.removeItem(communityAddress);\n log(\"communitiesStore.deleteCommunity\", { communityAddress, community, account });\n setState((state: CommunitiesState) => {\n const syncStatuses = { ...state.syncStatuses };\n delete syncStatuses[communityAddress];\n const errors = { ...state.errors };\n delete errors[communityAddress];\n return {\n communities: { ...state.communities, [communityAddress]: undefined },\n errors,\n syncStatuses,\n };\n });\n },\n }),\n);\n\n// reset store in between tests\nconst originalState = communitiesStore.getState();\n// async function because some stores have async init\nexport const resetCommunitiesStore = async () => {\n pkcGetCommunityPending = {};\n Object.keys(pendingCommunityErrorTimers).forEach(clearPendingCommunityErrors);\n // remove all event listeners\n listeners.forEach((listener: any) => listener.removeAllListeners());\n listeners.length = 0;\n Object.keys(liveCommunities).forEach(stopCommunityUpdatePolling);\n Object.keys(communityStopTimers).forEach(clearCommunityStopTimer);\n for (const communityKey in communityUpdateSubscribers) {\n delete communityUpdateSubscribers[communityKey];\n }\n // destroy all component subscriptions to the store\n communitiesStore.destroy();\n // restore original state\n communitiesStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetCommunitiesDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-communities\" }).clear();\n await resetCommunitiesStore();\n};\n\nexport default communitiesStore;\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;
|
|
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;AA6HrB;;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,UAgLrD,CAAC;AAoBF,eAAO,MAAM,cAAc,GACzB,cAAc,YAAY,EAC1B,qBAAqB,KAAK,EAC1B,aAAa,KAAK,EAClB,eAAe,KAAK,EACpB,UAAU,QAAQ,mBA6DnB,CAAC;AAcF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,iBAAiB,OAAO,EAAE,EAC1B,QAAQ,MAAM,GAAG,IAAI,KACpB,OAAO,EAUT,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,cAAc,YAAY,EAAE,aAAa,KAAK,YAyHjF,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAAI,eAAe,KAAK,EAAE,aAAa,KAAK,UAoC1F,CAAC;AAEF,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AS,CAAC,KACvC,MAAM,EAqCR,CAAC;AAIF,eAAO,MAAM,4CAA4C,GACvD,kBAAkB,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,KACvC,MAUF,CAAC;AAGF,eAAO,MAAM,8BAA8B,GACzC,kBAAkB,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,KACvC,MAQF,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,UAAU,QAAQ,aAU7D,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,kCAAkC;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EAClE,0BAA0B;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,YAY3D,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAC3C,cAAc,YAAY,EAC1B,eAAe,KAAK,EACpB,kBAAkB,MAAM,EAAE,EAC1B,0BAA0B,MAAM,EAAE,YAkCnC,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,QAAQ,aAUxD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACrC,6BAA6B;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,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"}
|
|
@@ -12,7 +12,7 @@ import accountsStore from "../accounts/index.js";
|
|
|
12
12
|
import feedSorter from "./feed-sorter.js";
|
|
13
13
|
import { communityPostsCacheExpired, commentIsValid, removeInvalidComments } from "../../lib/utils/index.js";
|
|
14
14
|
import { getCommentCommunityAddress, normalizeCommentCommunityAddress } from "../../lib/pkc-compat.js";
|
|
15
|
-
import { doesAddressMatchCommunityRef, getCommunityRefKeys, getMatchingCommunityRefKeys, } from "../../lib/community-ref.js";
|
|
15
|
+
import { doesAddressMatchCommunityRef, getCommunityRefKeys, getMatchingCommunityRefKeys, isCommunityRefBlocked, } from "../../lib/community-ref.js";
|
|
16
16
|
import Logger from "@pkcprotocol/pkc-logger";
|
|
17
17
|
import { getPostPageSortType, getSortTimeframeSeconds, isBuiltInPostSortType, isPinnedFirstPostSortType, isPostSortTypeUnavailable, resolvePostSortType, } from "../../lib/page-sorts.js";
|
|
18
18
|
const log = Logger("bitsocial-react-hooks:feeds:stores");
|
|
@@ -585,10 +585,7 @@ const getFeedPageOptions = (feedOptions) => {
|
|
|
585
585
|
}
|
|
586
586
|
return { sortType, pageType };
|
|
587
587
|
};
|
|
588
|
-
const isFeedCommunityBlocked = (accounts, accountId, communityRef, community) => {
|
|
589
|
-
var _a;
|
|
590
|
-
return Object.keys(((_a = accounts[accountId]) === null || _a === void 0 ? void 0 : _a.blockedAddresses) || {}).some((blockedAddress) => communityRef && doesAddressMatchCommunityRef(blockedAddress, communityRef, community));
|
|
591
|
-
};
|
|
588
|
+
const isFeedCommunityBlocked = (accounts, accountId, communityRef, community) => { var _a; return isCommunityRefBlocked((_a = accounts[accountId]) === null || _a === void 0 ? void 0 : _a.blockedAddresses, communityRef, community); };
|
|
592
589
|
// a community has more pages until it has loaded, its posts cache is fresh and its last page has no next page
|
|
593
590
|
const communityHasMorePages = (community, sortType, pageType, communitiesPages, accountId) => {
|
|
594
591
|
if (!(community === null || community === void 0 ? void 0 : community.updatedAt) || communityPostsCacheExpired(community)) {
|