@bitsocial/bitsocial-react-hooks 0.1.63 → 0.1.65

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 CHANGED
@@ -1,3 +1,21 @@
1
+ ## [0.1.65](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.64...v0.1.65) (2026-10-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **communities:** keep the last retriable error for useCommunity ([46d3909](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/46d3909a151e77375889ff314e01a759663afb02))
7
+
8
+
9
+
10
+ ## [0.1.64](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.63...v0.1.64) (2026-10-31)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **types:** preserve open comment type compatibility in 0.1.64 ([278465b](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/278465bb3a8473e212f7817c73edc1fc193eb76a))
16
+
17
+
18
+
1
19
  ## [0.1.63](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.62...v0.1.63) (2026-10-31)
2
20
 
3
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"communities.d.ts","sourceRoot":"","sources":["../../src/hooks/communities.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,cAAc,EACd,kCAAkC,EAClC,iCAAiC,EACjC,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAyClB;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,kBAAkB,CAqH9E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,uBAAuB,CAyF7F;AAeD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CA2EpF;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,CAAC,EAAE,MAAM,YAqBtD;AAED;;;;GAIG;AAEH,wBAAgB,2BAA2B,CACzC,OAAO,CAAC,EAAE,kCAAkC,GAC3C,iCAAiC,CAgGnC;AAGD,eAAO,MAAM,uBAAuB,GAClC,kBAAkB,MAAM,EACxB,gBAAgB,cAAc,iBAe/B,CAAC"}
1
+ {"version":3,"file":"communities.d.ts","sourceRoot":"","sources":["../../src/hooks/communities.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,cAAc,EACd,kCAAkC,EAClC,iCAAiC,EACjC,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAyClB;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,kBAAkB,CAsH9E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,uBAAuB,CAyF7F;AAeD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CA2EpF;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,CAAC,EAAE,MAAM,YAqBtD;AAED;;;;GAIG;AAEH,wBAAgB,2BAA2B,CACzC,OAAO,CAAC,EAAE,kCAAkC,GAC3C,iCAAiC,CAgGnC;AAGD,eAAO,MAAM,uBAAuB,GAClC,kBAAkB,MAAM,EACxB,gBAAgB,cAAc,iBAe/B,CAAC"}
@@ -130,7 +130,7 @@ export function useCommunity(options) {
130
130
  if (mergedCommunity === null || mergedCommunity === void 0 ? void 0 : mergedCommunity.updatedAt) {
131
131
  state = "succeeded";
132
132
  }
133
- return useMemo(() => (Object.assign(Object.assign({}, mergedCommunity), { state, syncState: (syncStatus === null || syncStatus === void 0 ? void 0 : syncStatus.syncState) || (onlyIfCached ? "stopped" : "initializing"), hasCachedData: typeof (mergedCommunity === null || mergedCommunity === void 0 ? void 0 : mergedCommunity.updatedAt) === "number", lastFetchAttemptAt: syncStatus === null || syncStatus === void 0 ? void 0 : syncStatus.lastFetchAttemptAt, lastSuccessfulFetchAt: syncStatus === null || syncStatus === void 0 ? void 0 : syncStatus.lastSuccessfulFetchAt, error: errors === null || errors === void 0 ? void 0 : errors[errors.length - 1], errors: errors || [] })), [mergedCommunity, communityKey, errors, onlyIfCached, syncStatus]);
133
+ return useMemo(() => (Object.assign(Object.assign({}, mergedCommunity), { state, syncState: (syncStatus === null || syncStatus === void 0 ? void 0 : syncStatus.syncState) || (onlyIfCached ? "stopped" : "initializing"), hasCachedData: typeof (mergedCommunity === null || mergedCommunity === void 0 ? void 0 : mergedCommunity.updatedAt) === "number", lastFetchAttemptAt: syncStatus === null || syncStatus === void 0 ? void 0 : syncStatus.lastFetchAttemptAt, lastSuccessfulFetchAt: syncStatus === null || syncStatus === void 0 ? void 0 : syncStatus.lastSuccessfulFetchAt, lastRetriableError: syncStatus === null || syncStatus === void 0 ? void 0 : syncStatus.lastRetriableError, error: errors === null || errors === void 0 ? void 0 : errors[errors.length - 1], errors: errors || [] })), [mergedCommunity, communityKey, errors, onlyIfCached, syncStatus]);
134
134
  }
135
135
  /**
136
136
  * @param community - The community identifier, e.g. {name: 'memes.eth'} or {publicKey: '12D3KooW...'}
@@ -1 +1 @@
1
- {"version":3,"file":"communities.js","sourceRoot":"","sources":["../../src/hooks/communities.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,yCAAyC,CAAC,CAAC;AAC9D,O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ACN,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAA,CAAC,EAAE,CAAC;IACP,CAAC,EACD,QAAQ,EACR,IAAI,EACJ,CAAC,gBAAgB,EAAE,cAAc,CAAC,CACnC,CAAC;IAEF,iCAAiC;IACjC,MAAM,aAAa,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAG,KAAK,CAAC,CAAC;IAE9C,yGAAyG;IACzG,OAAO;QACL,eAAe;QACf,aAAa;QACb,KAAK,EAAE,KAAK,IAAI,YAAY;QAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM;KACP,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,gBAAwB,EACxB,cAA8B,EAC9B,EAAE;;IACF,IAAI,wBAAwB,CAAC;IAC7B,IAAI,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,wBAAwB,GAAG,MAAM,mBAAmB,CAClD,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,EACL,MAAA,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAG,KAAK,CAAC,0CAAE,IAAI,0CAAG,CAAC,CAAC,EAClC,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAG,KAAK,CAAC,0CAAE,OAAO,CACjC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,CAAC,qDAAqD,gBAAgB,GAAG,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAA,CAAC","sourcesContent":["import { useEffect, useState, useMemo } from \"react\";\nimport { useAccount } from \"./accounts\";\nimport validator from \"../lib/validator\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:communities:hooks\");\nimport assert from \"../lib/assert\";\nimport {\n Community,\n CommunityStats,\n ChainProviders,\n UseResolvedCommunityAddressOptions,\n UseResolvedCommunityAddressResult,\n UseCommunityOptions,\n UseCommunityResult,\n UseCommunitiesOptions,\n UseCommunitiesResult,\n UseCommunityStatsOptions,\n UseCommunityStatsResult,\n} from \"../types\";\nimport useInterval from \"./utils/use-interval\";\nimport createStore from \"zustand\";\nimport { resolveEnsTxtRecord } from \"../lib/chain\";\nimport useCommunitiesStore from \"../stores/communities\";\nimport useAccountsStore from \"../stores/accounts\";\nimport shallow from \"zustand/shallow\";\nimport { getChainProviders, getPkcCommunityAddresses } from \"../lib/pkc-compat\";\nimport { getCommunityRefKey, getUniqueSortedCommunityRefs } from \"../lib/community-ref\";\n\nconst parseMaybeJson = (value: unknown) => (typeof value === \"string\" ? JSON.parse(value) : value);\n\nconst tryParseMaybeJson = (value: unknown) => {\n try {\n return parseMaybeJson(value);\n } catch {\n return value;\n }\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === \"object\";\n\nconst isCommunityStatsPayload = (value: unknown): value is CommunityStats =>\n isRecord(value) &&\n (\"hourActiveUserCount\" in value || \"weekActiveUserCount\" in value || \"allPostCount\" in value);\n\nconst parseFetchedCommunityStats = (fetchedCid: unknown): CommunityStats => {\n const parsedCid = parseMaybeJson(fetchedCid);\n if (isCommunityStatsPayload(parsedCid)) {\n return parsedCid;\n }\n if (isRecord(parsedCid) && \"content\" in parsedCid) {\n const parsedContent = tryParseMaybeJson(parsedCid.content);\n if (isCommunityStatsPayload(parsedContent)) {\n return parsedContent;\n }\n }\n return parsedCid as CommunityStats;\n};\n\n/**\n * @param community - The community identifier, e.g. {name: 'memes.eth'} or {publicKey: '12D3KooW...'}\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 useCommunity(options?: UseCommunityOptions): UseCommunityResult {\n assert(\n !options || typeof options === \"object\",\n `useCommunity options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { community: communityInput, accountName, onlyIfCached } = opts;\n const account = useAccount({ accountName });\n const accountId = account?.id || \"\";\n validator.validateUseCommunityArguments({\n community: communityInput,\n communityAddress: (opts as any).communityAddress,\n account,\n });\n const communityKey = communityInput ? getCommunityRefKey(communityInput) : \"\";\n const storedCommunity = useCommunitiesStore((state: any) => state.communities[communityKey]);\n const addCommunityToStore = useCommunitiesStore((state: any) => state.addCommunityToStore);\n const errors = useCommunitiesStore((state: any) => state.errors[communityKey]);\n const syncStatus = useCommunitiesStore((state: any) => state.syncStatuses[communityKey]);\n const communityEditSummary = useAccountsStore((state: any) => {\n const accountEditsSummaries = state.accountsEditsSummaries[accountId] || {};\n const candidateCommunityKeys = [\n storedCommunity?.address,\n storedCommunity?.name,\n storedCommunity?.publicKey,\n communityInput?.name,\n communityInput?.publicKey,\n ];\n for (const candidateCommunityKey of candidateCommunityKeys) {\n if (\n typeof candidateCommunityKey === \"string\" &&\n accountEditsSummaries[candidateCommunityKey]\n ) {\n return accountEditsSummaries[candidateCommunityKey];\n }\n }\n });\n\n useEffect(() => {\n if (!communityInput || !account) {\n return;\n }\n if (!storedCommunity && !onlyIfCached) {\n // if community isn't already in store, add it\n addCommunityToStore(communityInput, account).catch((error: unknown) =>\n log.error(\"useCommunity addCommunityToStore error\", { communityInput, error }),\n );\n }\n }, [communityKey, account?.id]);\n\n if (account && communityInput) {\n log(\"useCommunity\", {\n community: communityInput,\n communityKey,\n storedCommunity,\n account,\n });\n }\n\n const mergedCommunity = useMemo(() => {\n if (!communityEditSummary) {\n return storedCommunity;\n }\n const localCommunityAddresses = getPkcCommunityAddresses(account?.pkc);\n const editedCommunityAddress = communityEditSummary.address?.value;\n const inputCommunityIdentifiers = [communityInput?.name, communityInput?.publicKey].filter(\n (communityIdentifier): communityIdentifier is string =>\n typeof communityIdentifier === \"string\",\n );\n if (\n !storedCommunity &&\n editedCommunityAddress &&\n !inputCommunityIdentifiers.some((communityIdentifier) =>\n localCommunityAddresses.includes(communityIdentifier),\n ) &&\n !localCommunityAddresses.includes(editedCommunityAddress)\n ) {\n return storedCommunity;\n }\n if (\n storedCommunity?.address &&\n editedCommunityAddress &&\n storedCommunity.address !== editedCommunityAddress\n ) {\n return storedCommunity;\n }\n const summaryValues = Object.fromEntries(\n Object.entries(communityEditSummary).map(([propertyName, propertySummary]: [string, any]) => [\n propertyName,\n propertySummary?.value,\n ]),\n );\n return {\n ...(storedCommunity || { address: communityInput?.name || communityInput?.publicKey }),\n ...summaryValues,\n };\n }, [account?.pkc, storedCommunity, communityInput, communityEditSummary]);\n\n let state = mergedCommunity?.updatingState || \"initializing\";\n // force succeeded even if the community is fecthing a new update\n if (mergedCommunity?.updatedAt) {\n state = \"succeeded\";\n }\n\n return useMemo(\n () => ({\n ...mergedCommunity,\n state,\n syncState: syncStatus?.syncState || (onlyIfCached ? \"stopped\" : \"initializing\"),\n hasCachedData: typeof mergedCommunity?.updatedAt === \"number\",\n lastFetchAttemptAt: syncStatus?.lastFetchAttemptAt,\n lastSuccessfulFetchAt: syncStatus?.lastSuccessfulFetchAt,\n error: errors?.[errors.length - 1],\n errors: errors || [],\n }),\n [mergedCommunity, communityKey, errors, onlyIfCached, syncStatus],\n );\n}\n\n/**\n * @param community - The community identifier, e.g. {name: 'memes.eth'} or {publicKey: '12D3KooW...'}\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 useCommunityStats(options?: UseCommunityStatsOptions): UseCommunityStatsResult {\n assert(\n !options || typeof options === \"object\",\n `useCommunityStats options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { community, accountName, onlyIfCached } = opts;\n validator.validateUseCommunityStatsArguments({\n community,\n communityAddress: (opts as any).communityAddress,\n });\n const account = useAccount({ accountName });\n const communityKey = community ? getCommunityRefKey(community) : \"\";\n const fetchedCommunity = useCommunity({ community, onlyIfCached });\n const communityStatsCid = fetchedCommunity?.statsCid;\n const communityStats = useCommunitiesStatsStore(\n (state: CommunitiesStatsState) => state.communitiesStats[communityKey],\n );\n const setCommunityStats = useCommunitiesStatsStore(\n (state: CommunitiesStatsState) => state.setCommunityStats,\n );\n const [fetchError, setFetchError] = useState<Error | undefined>();\n\n useEffect(() => {\n setFetchError(undefined);\n if (!communityKey || !communityStatsCid || !account) {\n return;\n }\n let cancelled = false;\n (async () => {\n let fetchedCid;\n try {\n fetchedCid = await account.pkc.fetchCid({ cid: communityStatsCid });\n fetchedCid = parseFetchedCommunityStats(fetchedCid);\n if (cancelled) {\n return;\n }\n setCommunityStats(communityKey, fetchedCid);\n } catch (error) {\n const normalizedError =\n error instanceof Error ? error : new Error(typeof error === \"string\" ? error : \"error\");\n if (cancelled) {\n return;\n }\n setFetchError(normalizedError);\n log.error(\"useCommunityStats pkc.fetchCid error\", {\n community,\n communityKey,\n communityStatsCid,\n fetchedCommunity,\n fetchedCid,\n error: normalizedError,\n });\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [communityStatsCid, account?.id, communityKey, setCommunityStats]);\n\n if (account && communityStatsCid) {\n log(\"useCommunityStats\", {\n community,\n communityKey,\n communityStatsCid,\n communityStats,\n fetchedCommunity,\n account,\n });\n }\n\n const state =\n !communityKey || !account || !communityStatsCid\n ? \"uninitialized\"\n : fetchError\n ? \"failed\"\n : communityStats\n ? \"succeeded\"\n : \"fetching-ipfs\";\n\n return useMemo(\n () => ({\n ...communityStats,\n state,\n error: fetchError,\n errors: fetchError ? [fetchError] : [],\n }),\n [communityStats, state, fetchError],\n );\n}\n\ntype CommunitiesStatsState = {\n communitiesStats: { [communityAddress: string]: CommunityStats };\n setCommunityStats: Function;\n};\n\nconst useCommunitiesStatsStore = createStore<CommunitiesStatsState>((setState: Function) => ({\n communitiesStats: {},\n setCommunityStats: (communityAddress: string, communityStats: CommunityStats) =>\n setState((state: CommunitiesStatsState) => ({\n communitiesStats: { ...state.communitiesStats, [communityAddress]: communityStats },\n })),\n}));\n\n/**\n * @param communities - The communities to fetch, e.g. [{name: 'memes.eth'}, {publicKey: '12D3KooW...'}]\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 useCommunities(options?: UseCommunitiesOptions): UseCommunitiesResult {\n assert(\n !options || typeof options === \"object\",\n `useCommunities options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { communities: communitiesInput, accountName, onlyIfCached } = opts;\n const account = useAccount({ accountName });\n validator.validateUseCommunitiesArguments({\n communities: communitiesInput,\n communityRefs: (opts as any).communityRefs,\n communityAddresses: (opts as any).communityAddresses,\n account,\n });\n const normalizedCommunityRefs = useMemo(() => communitiesInput || [], [communitiesInput]);\n const communityKeys = useMemo(\n () => normalizedCommunityRefs.map(getCommunityRefKey),\n [normalizedCommunityRefs],\n );\n const communities: (Community | undefined)[] = useCommunitiesStore(\n (state: any) => communityKeys.map((communityKey) => state.communities[communityKey || \"\"]),\n shallow,\n );\n const communitiesErrors: (Error[] | undefined)[] = useCommunitiesStore(\n (state: any) => communityKeys.map((communityKey) => state.errors[communityKey || \"\"]),\n shallow,\n );\n const addCommunityToStore = useCommunitiesStore((state: any) => state.addCommunityToStore);\n\n useEffect(() => {\n if (!normalizedCommunityRefs.length || !account) {\n return;\n }\n if (onlyIfCached) {\n return;\n }\n const uniqueCommunityRefs = getUniqueSortedCommunityRefs(normalizedCommunityRefs);\n for (const communityRef of uniqueCommunityRefs) {\n addCommunityToStore(communityRef, account).catch((error: unknown) =>\n log.error(\"useCommunities addCommunityToStore error\", { communityRef, error }),\n );\n }\n }, [account?.id, communityKeys.toString(), onlyIfCached, normalizedCommunityRefs]);\n\n if (account && normalizedCommunityRefs.length) {\n log(\"useCommunities\", {\n requestedCommunities: normalizedCommunityRefs,\n communityKeys,\n communities,\n account,\n });\n }\n\n const errors = useMemo(\n () => communitiesErrors.flatMap((communityErrors) => communityErrors || []),\n [communitiesErrors],\n );\n const hasFailedCommunity = communities.some(\n (community, index) => !community && Boolean(communitiesErrors[index]?.length),\n );\n const state = hasFailedCommunity\n ? \"failed\"\n : communities.indexOf(undefined) === -1\n ? \"succeeded\"\n : \"fetching-ipns\";\n\n return useMemo(\n () => ({\n communities,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [communities, state, errors, communityKeys.toString()],\n );\n}\n\n// TODO: pkc.listCommunities() has been removed, rename this and use event communitieschanged instead of polling\n/**\n * Returns all the owner communities created by pkc-js by calling pkc.listCommunities()\n */\nexport function useListCommunities(accountName?: string) {\n const account = useAccount({ accountName });\n const [communityAddresses, setCommunityAddresses] = useState<string[]>([]);\n\n const delay = 1000;\n const immediate = true;\n useInterval(\n () => {\n const pkc = account?.pkc;\n if (!pkc) return;\n const newAddrs = getPkcCommunityAddresses(pkc);\n if (newAddrs.toString() !== communityAddresses.toString()) {\n log(\"useListCommunities\", { communityAddresses });\n setCommunityAddresses(newAddrs);\n }\n },\n delay,\n immediate,\n );\n\n return communityAddresses;\n}\n\n/**\n * @param communityAddress - The community address to resolve to a public key, e.g. 'news.eth' resolves to '12D3KooW...'.\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\n// NOTE: useResolvedCommunityAddress tests are skipped, if changes are made they must be tested manually\nexport function useResolvedCommunityAddress(\n options?: UseResolvedCommunityAddressOptions,\n): UseResolvedCommunityAddressResult {\n assert(\n !options || typeof options === \"object\",\n `useResolvedCommunityAddress options argument '${options}' not an object`,\n );\n let { communityAddress, accountName, cache } = options ?? {};\n\n // cache by default\n if (typeof cache !== \"boolean\") {\n cache = true;\n }\n\n // poll every 15 seconds, about the duration of an eth block\n let interval = 15000;\n // no point in polling often if caching is on\n if (cache) {\n interval = 1000 * 60 * 60 * 25;\n }\n\n const account = useAccount({ accountName });\n const chainProviders = getChainProviders(account);\n const [resolvedAddress, setResolvedAddress] = useState<string>();\n const [errors, setErrors] = useState<Error[]>([]);\n const [state, setState] = useState<string>();\n\n let initialState = \"initializing\";\n // before those defined, nothing can happen\n if (options && account && communityAddress) {\n initialState = \"ready\";\n }\n\n useInterval(\n () => {\n if (!account || !communityAddress) {\n setResolvedAddress(undefined);\n setState(undefined);\n setErrors((prevErrors) => (prevErrors.length ? [] : prevErrors));\n return;\n }\n\n // address isn't a crypto domain, can't be resolved\n if (!communityAddress?.includes(\".\")) {\n if (state !== \"failed\") {\n setErrors([Error(\"not a crypto domain\")]);\n setState(\"failed\");\n setResolvedAddress(undefined);\n }\n return;\n }\n\n // only support resolving '.eth' for now\n if (!communityAddress?.endsWith(\".eth\")) {\n if (state !== \"failed\") {\n setErrors([Error(\"crypto domain type unsupported\")]);\n setState(\"failed\");\n setResolvedAddress(undefined);\n }\n return;\n }\n\n (async () => {\n try {\n setState(\"resolving\");\n const res = await resolveCommunityAddress(communityAddress, chainProviders);\n setState(\"succeeded\");\n if (res !== resolvedAddress) {\n setResolvedAddress(res);\n }\n } catch (error: any) {\n setErrors([...errors, error]);\n setState(\"failed\");\n setResolvedAddress(undefined);\n log.error(\"useResolvedCommunityAddress resolveCommunityAddress error\", {\n communityAddress,\n chainProviders,\n error,\n });\n }\n })();\n },\n interval,\n true,\n [communityAddress, chainProviders],\n );\n\n // only support ENS at the moment\n const chainProvider = chainProviders?.[\"eth\"];\n\n // log('useResolvedCommunityAddress', {communityAddress, state, errors, resolvedAddress, chainProviders})\n return {\n resolvedAddress,\n chainProvider,\n state: state || initialState,\n error: errors[errors.length - 1],\n errors,\n };\n}\n\n// NOTE: resolveCommunityAddress tests are skipped, if changes are made they must be tested manually\nexport const resolveCommunityAddress = async (\n communityAddress: string,\n chainProviders: ChainProviders,\n) => {\n let resolvedCommunityAddress;\n if (communityAddress.endsWith(\".eth\")) {\n resolvedCommunityAddress = await resolveEnsTxtRecord(\n communityAddress,\n \"community-address\",\n \"eth\",\n chainProviders?.[\"eth\"]?.urls?.[0],\n chainProviders?.[\"eth\"]?.chainId,\n );\n } else {\n throw Error(`resolveCommunityAddress invalid communityAddress '${communityAddress}'`);\n }\n return resolvedCommunityAddress;\n};\n"]}
1
+ {"version":3,"file":"communities.js","sourceRoot":"","sources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,CACjC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,CAAC,qDAAqD,gBAAgB,GAAG,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAA,CAAC","sourcesContent":["import { useEffect, useState, useMemo } from \"react\";\nimport { useAccount } from \"./accounts\";\nimport validator from \"../lib/validator\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:communities:hooks\");\nimport assert from \"../lib/assert\";\nimport {\n Community,\n CommunityStats,\n ChainProviders,\n UseResolvedCommunityAddressOptions,\n UseResolvedCommunityAddressResult,\n UseCommunityOptions,\n UseCommunityResult,\n UseCommunitiesOptions,\n UseCommunitiesResult,\n UseCommunityStatsOptions,\n UseCommunityStatsResult,\n} from \"../types\";\nimport useInterval from \"./utils/use-interval\";\nimport createStore from \"zustand\";\nimport { resolveEnsTxtRecord } from \"../lib/chain\";\nimport useCommunitiesStore from \"../stores/communities\";\nimport useAccountsStore from \"../stores/accounts\";\nimport shallow from \"zustand/shallow\";\nimport { getChainProviders, getPkcCommunityAddresses } from \"../lib/pkc-compat\";\nimport { getCommunityRefKey, getUniqueSortedCommunityRefs } from \"../lib/community-ref\";\n\nconst parseMaybeJson = (value: unknown) => (typeof value === \"string\" ? JSON.parse(value) : value);\n\nconst tryParseMaybeJson = (value: unknown) => {\n try {\n return parseMaybeJson(value);\n } catch {\n return value;\n }\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === \"object\";\n\nconst isCommunityStatsPayload = (value: unknown): value is CommunityStats =>\n isRecord(value) &&\n (\"hourActiveUserCount\" in value || \"weekActiveUserCount\" in value || \"allPostCount\" in value);\n\nconst parseFetchedCommunityStats = (fetchedCid: unknown): CommunityStats => {\n const parsedCid = parseMaybeJson(fetchedCid);\n if (isCommunityStatsPayload(parsedCid)) {\n return parsedCid;\n }\n if (isRecord(parsedCid) && \"content\" in parsedCid) {\n const parsedContent = tryParseMaybeJson(parsedCid.content);\n if (isCommunityStatsPayload(parsedContent)) {\n return parsedContent;\n }\n }\n return parsedCid as CommunityStats;\n};\n\n/**\n * @param community - The community identifier, e.g. {name: 'memes.eth'} or {publicKey: '12D3KooW...'}\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 useCommunity(options?: UseCommunityOptions): UseCommunityResult {\n assert(\n !options || typeof options === \"object\",\n `useCommunity options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { community: communityInput, accountName, onlyIfCached } = opts;\n const account = useAccount({ accountName });\n const accountId = account?.id || \"\";\n validator.validateUseCommunityArguments({\n community: communityInput,\n communityAddress: (opts as any).communityAddress,\n account,\n });\n const communityKey = communityInput ? getCommunityRefKey(communityInput) : \"\";\n const storedCommunity = useCommunitiesStore((state: any) => state.communities[communityKey]);\n const addCommunityToStore = useCommunitiesStore((state: any) => state.addCommunityToStore);\n const errors = useCommunitiesStore((state: any) => state.errors[communityKey]);\n const syncStatus = useCommunitiesStore((state: any) => state.syncStatuses[communityKey]);\n const communityEditSummary = useAccountsStore((state: any) => {\n const accountEditsSummaries = state.accountsEditsSummaries[accountId] || {};\n const candidateCommunityKeys = [\n storedCommunity?.address,\n storedCommunity?.name,\n storedCommunity?.publicKey,\n communityInput?.name,\n communityInput?.publicKey,\n ];\n for (const candidateCommunityKey of candidateCommunityKeys) {\n if (\n typeof candidateCommunityKey === \"string\" &&\n accountEditsSummaries[candidateCommunityKey]\n ) {\n return accountEditsSummaries[candidateCommunityKey];\n }\n }\n });\n\n useEffect(() => {\n if (!communityInput || !account) {\n return;\n }\n if (!storedCommunity && !onlyIfCached) {\n // if community isn't already in store, add it\n addCommunityToStore(communityInput, account).catch((error: unknown) =>\n log.error(\"useCommunity addCommunityToStore error\", { communityInput, error }),\n );\n }\n }, [communityKey, account?.id]);\n\n if (account && communityInput) {\n log(\"useCommunity\", {\n community: communityInput,\n communityKey,\n storedCommunity,\n account,\n });\n }\n\n const mergedCommunity = useMemo(() => {\n if (!communityEditSummary) {\n return storedCommunity;\n }\n const localCommunityAddresses = getPkcCommunityAddresses(account?.pkc);\n const editedCommunityAddress = communityEditSummary.address?.value;\n const inputCommunityIdentifiers = [communityInput?.name, communityInput?.publicKey].filter(\n (communityIdentifier): communityIdentifier is string =>\n typeof communityIdentifier === \"string\",\n );\n if (\n !storedCommunity &&\n editedCommunityAddress &&\n !inputCommunityIdentifiers.some((communityIdentifier) =>\n localCommunityAddresses.includes(communityIdentifier),\n ) &&\n !localCommunityAddresses.includes(editedCommunityAddress)\n ) {\n return storedCommunity;\n }\n if (\n storedCommunity?.address &&\n editedCommunityAddress &&\n storedCommunity.address !== editedCommunityAddress\n ) {\n return storedCommunity;\n }\n const summaryValues = Object.fromEntries(\n Object.entries(communityEditSummary).map(([propertyName, propertySummary]: [string, any]) => [\n propertyName,\n propertySummary?.value,\n ]),\n );\n return {\n ...(storedCommunity || { address: communityInput?.name || communityInput?.publicKey }),\n ...summaryValues,\n };\n }, [account?.pkc, storedCommunity, communityInput, communityEditSummary]);\n\n let state = mergedCommunity?.updatingState || \"initializing\";\n // force succeeded even if the community is fecthing a new update\n if (mergedCommunity?.updatedAt) {\n state = \"succeeded\";\n }\n\n return useMemo(\n () => ({\n ...mergedCommunity,\n state,\n syncState: syncStatus?.syncState || (onlyIfCached ? \"stopped\" : \"initializing\"),\n hasCachedData: typeof mergedCommunity?.updatedAt === \"number\",\n lastFetchAttemptAt: syncStatus?.lastFetchAttemptAt,\n lastSuccessfulFetchAt: syncStatus?.lastSuccessfulFetchAt,\n lastRetriableError: syncStatus?.lastRetriableError,\n error: errors?.[errors.length - 1],\n errors: errors || [],\n }),\n [mergedCommunity, communityKey, errors, onlyIfCached, syncStatus],\n );\n}\n\n/**\n * @param community - The community identifier, e.g. {name: 'memes.eth'} or {publicKey: '12D3KooW...'}\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 useCommunityStats(options?: UseCommunityStatsOptions): UseCommunityStatsResult {\n assert(\n !options || typeof options === \"object\",\n `useCommunityStats options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { community, accountName, onlyIfCached } = opts;\n validator.validateUseCommunityStatsArguments({\n community,\n communityAddress: (opts as any).communityAddress,\n });\n const account = useAccount({ accountName });\n const communityKey = community ? getCommunityRefKey(community) : \"\";\n const fetchedCommunity = useCommunity({ community, onlyIfCached });\n const communityStatsCid = fetchedCommunity?.statsCid;\n const communityStats = useCommunitiesStatsStore(\n (state: CommunitiesStatsState) => state.communitiesStats[communityKey],\n );\n const setCommunityStats = useCommunitiesStatsStore(\n (state: CommunitiesStatsState) => state.setCommunityStats,\n );\n const [fetchError, setFetchError] = useState<Error | undefined>();\n\n useEffect(() => {\n setFetchError(undefined);\n if (!communityKey || !communityStatsCid || !account) {\n return;\n }\n let cancelled = false;\n (async () => {\n let fetchedCid;\n try {\n fetchedCid = await account.pkc.fetchCid({ cid: communityStatsCid });\n fetchedCid = parseFetchedCommunityStats(fetchedCid);\n if (cancelled) {\n return;\n }\n setCommunityStats(communityKey, fetchedCid);\n } catch (error) {\n const normalizedError =\n error instanceof Error ? error : new Error(typeof error === \"string\" ? error : \"error\");\n if (cancelled) {\n return;\n }\n setFetchError(normalizedError);\n log.error(\"useCommunityStats pkc.fetchCid error\", {\n community,\n communityKey,\n communityStatsCid,\n fetchedCommunity,\n fetchedCid,\n error: normalizedError,\n });\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [communityStatsCid, account?.id, communityKey, setCommunityStats]);\n\n if (account && communityStatsCid) {\n log(\"useCommunityStats\", {\n community,\n communityKey,\n communityStatsCid,\n communityStats,\n fetchedCommunity,\n account,\n });\n }\n\n const state =\n !communityKey || !account || !communityStatsCid\n ? \"uninitialized\"\n : fetchError\n ? \"failed\"\n : communityStats\n ? \"succeeded\"\n : \"fetching-ipfs\";\n\n return useMemo(\n () => ({\n ...communityStats,\n state,\n error: fetchError,\n errors: fetchError ? [fetchError] : [],\n }),\n [communityStats, state, fetchError],\n );\n}\n\ntype CommunitiesStatsState = {\n communitiesStats: { [communityAddress: string]: CommunityStats };\n setCommunityStats: Function;\n};\n\nconst useCommunitiesStatsStore = createStore<CommunitiesStatsState>((setState: Function) => ({\n communitiesStats: {},\n setCommunityStats: (communityAddress: string, communityStats: CommunityStats) =>\n setState((state: CommunitiesStatsState) => ({\n communitiesStats: { ...state.communitiesStats, [communityAddress]: communityStats },\n })),\n}));\n\n/**\n * @param communities - The communities to fetch, e.g. [{name: 'memes.eth'}, {publicKey: '12D3KooW...'}]\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 useCommunities(options?: UseCommunitiesOptions): UseCommunitiesResult {\n assert(\n !options || typeof options === \"object\",\n `useCommunities options argument '${options}' not an object`,\n );\n const opts = options ?? {};\n const { communities: communitiesInput, accountName, onlyIfCached } = opts;\n const account = useAccount({ accountName });\n validator.validateUseCommunitiesArguments({\n communities: communitiesInput,\n communityRefs: (opts as any).communityRefs,\n communityAddresses: (opts as any).communityAddresses,\n account,\n });\n const normalizedCommunityRefs = useMemo(() => communitiesInput || [], [communitiesInput]);\n const communityKeys = useMemo(\n () => normalizedCommunityRefs.map(getCommunityRefKey),\n [normalizedCommunityRefs],\n );\n const communities: (Community | undefined)[] = useCommunitiesStore(\n (state: any) => communityKeys.map((communityKey) => state.communities[communityKey || \"\"]),\n shallow,\n );\n const communitiesErrors: (Error[] | undefined)[] = useCommunitiesStore(\n (state: any) => communityKeys.map((communityKey) => state.errors[communityKey || \"\"]),\n shallow,\n );\n const addCommunityToStore = useCommunitiesStore((state: any) => state.addCommunityToStore);\n\n useEffect(() => {\n if (!normalizedCommunityRefs.length || !account) {\n return;\n }\n if (onlyIfCached) {\n return;\n }\n const uniqueCommunityRefs = getUniqueSortedCommunityRefs(normalizedCommunityRefs);\n for (const communityRef of uniqueCommunityRefs) {\n addCommunityToStore(communityRef, account).catch((error: unknown) =>\n log.error(\"useCommunities addCommunityToStore error\", { communityRef, error }),\n );\n }\n }, [account?.id, communityKeys.toString(), onlyIfCached, normalizedCommunityRefs]);\n\n if (account && normalizedCommunityRefs.length) {\n log(\"useCommunities\", {\n requestedCommunities: normalizedCommunityRefs,\n communityKeys,\n communities,\n account,\n });\n }\n\n const errors = useMemo(\n () => communitiesErrors.flatMap((communityErrors) => communityErrors || []),\n [communitiesErrors],\n );\n const hasFailedCommunity = communities.some(\n (community, index) => !community && Boolean(communitiesErrors[index]?.length),\n );\n const state = hasFailedCommunity\n ? \"failed\"\n : communities.indexOf(undefined) === -1\n ? \"succeeded\"\n : \"fetching-ipns\";\n\n return useMemo(\n () => ({\n communities,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [communities, state, errors, communityKeys.toString()],\n );\n}\n\n// TODO: pkc.listCommunities() has been removed, rename this and use event communitieschanged instead of polling\n/**\n * Returns all the owner communities created by pkc-js by calling pkc.listCommunities()\n */\nexport function useListCommunities(accountName?: string) {\n const account = useAccount({ accountName });\n const [communityAddresses, setCommunityAddresses] = useState<string[]>([]);\n\n const delay = 1000;\n const immediate = true;\n useInterval(\n () => {\n const pkc = account?.pkc;\n if (!pkc) return;\n const newAddrs = getPkcCommunityAddresses(pkc);\n if (newAddrs.toString() !== communityAddresses.toString()) {\n log(\"useListCommunities\", { communityAddresses });\n setCommunityAddresses(newAddrs);\n }\n },\n delay,\n immediate,\n );\n\n return communityAddresses;\n}\n\n/**\n * @param communityAddress - The community address to resolve to a public key, e.g. 'news.eth' resolves to '12D3KooW...'.\n * @param acountName - The nickname of the account, e.g. 'Account KoXpxTwfnjA5'. If no accountName is provided, use\n * the active account.\n */\n// NOTE: useResolvedCommunityAddress tests are skipped, if changes are made they must be tested manually\nexport function useResolvedCommunityAddress(\n options?: UseResolvedCommunityAddressOptions,\n): UseResolvedCommunityAddressResult {\n assert(\n !options || typeof options === \"object\",\n `useResolvedCommunityAddress options argument '${options}' not an object`,\n );\n let { communityAddress, accountName, cache } = options ?? {};\n\n // cache by default\n if (typeof cache !== \"boolean\") {\n cache = true;\n }\n\n // poll every 15 seconds, about the duration of an eth block\n let interval = 15000;\n // no point in polling often if caching is on\n if (cache) {\n interval = 1000 * 60 * 60 * 25;\n }\n\n const account = useAccount({ accountName });\n const chainProviders = getChainProviders(account);\n const [resolvedAddress, setResolvedAddress] = useState<string>();\n const [errors, setErrors] = useState<Error[]>([]);\n const [state, setState] = useState<string>();\n\n let initialState = \"initializing\";\n // before those defined, nothing can happen\n if (options && account && communityAddress) {\n initialState = \"ready\";\n }\n\n useInterval(\n () => {\n if (!account || !communityAddress) {\n setResolvedAddress(undefined);\n setState(undefined);\n setErrors((prevErrors) => (prevErrors.length ? [] : prevErrors));\n return;\n }\n\n // address isn't a crypto domain, can't be resolved\n if (!communityAddress?.includes(\".\")) {\n if (state !== \"failed\") {\n setErrors([Error(\"not a crypto domain\")]);\n setState(\"failed\");\n setResolvedAddress(undefined);\n }\n return;\n }\n\n // only support resolving '.eth' for now\n if (!communityAddress?.endsWith(\".eth\")) {\n if (state !== \"failed\") {\n setErrors([Error(\"crypto domain type unsupported\")]);\n setState(\"failed\");\n setResolvedAddress(undefined);\n }\n return;\n }\n\n (async () => {\n try {\n setState(\"resolving\");\n const res = await resolveCommunityAddress(communityAddress, chainProviders);\n setState(\"succeeded\");\n if (res !== resolvedAddress) {\n setResolvedAddress(res);\n }\n } catch (error: any) {\n setErrors([...errors, error]);\n setState(\"failed\");\n setResolvedAddress(undefined);\n log.error(\"useResolvedCommunityAddress resolveCommunityAddress error\", {\n communityAddress,\n chainProviders,\n error,\n });\n }\n })();\n },\n interval,\n true,\n [communityAddress, chainProviders],\n );\n\n // only support ENS at the moment\n const chainProvider = chainProviders?.[\"eth\"];\n\n // log('useResolvedCommunityAddress', {communityAddress, state, errors, resolvedAddress, chainProviders})\n return {\n resolvedAddress,\n chainProvider,\n state: state || initialState,\n error: errors[errors.length - 1],\n errors,\n };\n}\n\n// NOTE: resolveCommunityAddress tests are skipped, if changes are made they must be tested manually\nexport const resolveCommunityAddress = async (\n communityAddress: string,\n chainProviders: ChainProviders,\n) => {\n let resolvedCommunityAddress;\n if (communityAddress.endsWith(\".eth\")) {\n resolvedCommunityAddress = await resolveEnsTxtRecord(\n communityAddress,\n \"community-address\",\n \"eth\",\n chainProviders?.[\"eth\"]?.urls?.[0],\n chainProviders?.[\"eth\"]?.chainId,\n );\n } else {\n throw Error(`resolveCommunityAddress invalid communityAddress '${communityAddress}'`);\n }\n return resolvedCommunityAddress;\n};\n"]}
@@ -4,6 +4,7 @@ interface CommunitySyncStatus {
4
4
  syncState: CommunitySyncState;
5
5
  lastFetchAttemptAt?: number;
6
6
  lastSuccessfulFetchAt?: number;
7
+ lastRetriableError?: Error;
7
8
  }
8
9
  export declare const isRetriableCommunityLoadError: (error: Error) => boolean;
9
10
  export type CommunitiesState = {
@@ -1 +1 @@
1
- {"version":3,"file":"communities-store.d.ts","sourceRoot":"","sources":["../../../src/stores/communities/communities-store.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,WAAW,EAGX,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAcrB,eAAO,MAAM,4BAA4B,QAAiB,CAAC;AAmB3D,UAAU,mBAAmB;IAC3B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAyID,eAAO,MAAM,6BAA6B,GAAI,OAAO,KAAK,YAQzD,CAAC;AAoCF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE;QAAE,CAAC,gBAAgB,EAAE,MAAM,GAAG,KAAK,EAAE,CAAA;KAAE,CAAC;IAChD,YAAY,EAAE;QAAE,CAAC,gBAAgB,EAAE,MAAM,GAAG,mBAAmB,CAAA;KAAE,CAAC;IAClE,mBAAmB,EAAE,QAAQ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AGF,eAAO,MAAM,gCAAgC,qBAG5C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -29,6 +29,11 @@ const communityUpdatePollers = {};
29
29
  const listeners = [];
30
30
  const COMMUNITY_ERROR_UPDATE_GRACE_MS = 1000;
31
31
  const pendingCommunityErrorTimers = {};
32
+ const omitLastRetriableError = (syncStatus) => {
33
+ const nextSyncStatus = Object.assign({}, syncStatus);
34
+ delete nextSyncStatus.lastRetriableError;
35
+ return nextSyncStatus;
36
+ };
32
37
  const getNowSeconds = () => Math.floor(Date.now() / 1000);
33
38
  const normalizeCommunitySyncState = (updatingState) => {
34
39
  if (updatingState === "waiting-retry") {
@@ -43,7 +48,10 @@ const getNextSyncStatuses = (state, communityKey, syncState) => {
43
48
  const previousStatus = state.syncStatuses[communityKey];
44
49
  const timestamp = getNowSeconds();
45
50
  const shouldRecordAttempt = syncState === "loading" && (previousStatus === null || previousStatus === void 0 ? void 0 : previousStatus.syncState) !== "loading";
46
- return Object.assign(Object.assign({}, state.syncStatuses), { [communityKey]: Object.assign(Object.assign(Object.assign(Object.assign({}, previousStatus), { syncState }), (shouldRecordAttempt ? { lastFetchAttemptAt: timestamp } : undefined)), (syncState === "succeeded" ? { lastSuccessfulFetchAt: timestamp } : undefined)) });
51
+ const nextStatus = Object.assign(Object.assign(Object.assign(Object.assign({}, previousStatus), { syncState }), (shouldRecordAttempt ? { lastFetchAttemptAt: timestamp } : undefined)), (syncState === "succeeded" ? { lastSuccessfulFetchAt: timestamp } : undefined));
52
+ return Object.assign(Object.assign({}, state.syncStatuses), {
53
+ // a success ends the retries, so their error is no longer current
54
+ [communityKey]: syncState === "succeeded" ? omitLastRetriableError(nextStatus) : nextStatus });
47
55
  };
48
56
  const updateCommunitySyncStatus = (setState, communityKey, syncState) => {
49
57
  setState((state) => (Object.assign(Object.assign({}, state), { syncStatuses: getNextSyncStatuses(state, communityKey, syncState) })));
@@ -109,8 +117,15 @@ const clearStoredCommunityErrors = (state, communityKey) => {
109
117
  return nextErrors;
110
118
  };
111
119
  // returning the same state skips notifying subscribers when there is nothing to clear
112
- const clearStoredCommunityErrorsState = (state, communityKey) => state.errors[communityKey]
113
- ? Object.assign(Object.assign({}, state), { errors: clearStoredCommunityErrors(state, communityKey) }) : state;
120
+ const clearStoredCommunityErrorsState = (state, communityKey) => {
121
+ const syncStatus = state.syncStatuses[communityKey];
122
+ const hasRetriableError = (syncStatus === null || syncStatus === void 0 ? void 0 : syncStatus.lastRetriableError) !== undefined;
123
+ if (!state.errors[communityKey] && !hasRetriableError) {
124
+ return state;
125
+ }
126
+ return Object.assign(Object.assign({}, state), { errors: clearStoredCommunityErrors(state, communityKey), syncStatuses: hasRetriableError
127
+ ? Object.assign(Object.assign({}, state.syncStatuses), { [communityKey]: omitLastRetriableError(syncStatus) }) : state.syncStatuses });
128
+ };
114
129
  export const isRetriableCommunityLoadError = (error) => {
115
130
  const details = error.details;
116
131
  return Boolean(details &&
@@ -118,8 +133,21 @@ export const isRetriableCommunityLoadError = (error) => {
118
133
  "retriableError" in details &&
119
134
  details.retriableError === true);
120
135
  };
136
+ const recordRetriableCommunityError = (setState, communityKey, error) => {
137
+ setState((state) => {
138
+ const syncStatus = state.syncStatuses[communityKey];
139
+ // a deleted community has no sync status left to report on
140
+ if (!syncStatus) {
141
+ return state;
142
+ }
143
+ return {
144
+ syncStatuses: Object.assign(Object.assign({}, state.syncStatuses), { [communityKey]: Object.assign(Object.assign({}, syncStatus), { lastRetriableError: error }) }),
145
+ };
146
+ });
147
+ };
121
148
  const scheduleCommunityError = (setState, communityKey, error) => {
122
149
  if (isRetriableCommunityLoadError(error)) {
150
+ recordRetriableCommunityError(setState, communityKey, error);
123
151
  return;
124
152
  }
125
153
  const timeout = setTimeout(() => {
@@ -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,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AAK,CAAC,WAAW,KAAE,CAAC,gBAAgB,CAAC,EAAE,SAAS,GAAE;oBACpE,MAAM;oBACN,YAAY;iBACb,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CACH,CAAC;AAEF,+BAA+B;AAC/B,MAAM,aAAa,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC;AAClD,qDAAqD;AACrD,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAS,EAAE;IAC9C,sBAAsB,GAAG,EAAE,CAAC;IAC5B,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC9E,6BAA6B;IAC7B,SAAS,CAAC,OAAO,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACpE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACxE,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\nlet pkcGetCommunityPending: { [key: string]: boolean } = {};\n// Key pollers by community so delete/reset can stop the matching live instance.\nconst communityUpdatePollers: {\n [communityKey: string]: {\n community: any;\n updateInterval: ReturnType<typeof setInterval>;\n };\n} = {};\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}\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 return {\n ...state.syncStatuses,\n [communityKey]: {\n ...previousStatus,\n syncState,\n ...(shouldRecordAttempt ? { lastFetchAttemptAt: timestamp } : undefined),\n ...(syncState === \"succeeded\" ? { lastSuccessfulFetchAt: timestamp } : undefined),\n },\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 updateCommunity = (\n community: Community,\n {\n communityAddressOrRef,\n communityKey,\n }: { communityAddressOrRef: string | CommunityIdentifier; communityKey: string },\n) => {\n community.update().catch((error: unknown) =>\n log.trace(\"community.update error\", {\n communityAddressOrRef,\n communityKey,\n community,\n error,\n }),\n );\n};\n\nconst startCommunityUpdatePolling = (\n community: Community,\n {\n communityAddressOrRef,\n communityKey,\n }: { communityAddressOrRef: string | CommunityIdentifier; communityKey: string },\n) => {\n stopCommunityUpdatePolling(communityKey);\n updateCommunity(community, { communityAddressOrRef, communityKey });\n communityUpdatePollers[communityKey] = {\n community,\n updateInterval: setInterval(\n () => updateCommunity(community, { communityAddressOrRef, communityKey }),\n COMMUNITY_UPDATE_INTERVAL_MS,\n ),\n };\n};\n\nconst stopCommunityUpdatePolling = (communityKey: string) => {\n const polling = communityUpdatePollers[communityKey];\n if (!polling) {\n return;\n }\n\n clearPendingCommunityErrors(communityKey);\n clearInterval(polling.updateInterval);\n polling.community.removeAllListeners();\n const listenerIndex = listeners.indexOf(polling.community);\n if (listenerIndex >= 0) {\n listeners.splice(listenerIndex, 1);\n }\n delete communityUpdatePollers[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 state.errors[communityKey]\n ? { ...state, errors: clearStoredCommunityErrors(state, communityKey) }\n : state;\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 scheduleCommunityError = (setState: Function, communityKey: string, error: Error) => {\n if (isRetriableCommunityLoadError(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 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 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 // pkc-js re-emits the record a community was created with when update() starts\n let cachedRecordId = isFromCache ? getCommunityRecordId(firstCommunityState) : undefined;\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 isCachedRecordReplay =\n cachedRecordId !== undefined &&\n getCommunityRecordId(updatedCommunity) === cachedRecordId;\n cachedRecordId = undefined;\n if (isCachedRecordReplay) {\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 await communitiesDatabase.setItem(communityKey, updatedCommunity);\n log(\"communitiesStore community update\", {\n communityAddressOrRef,\n communityKey,\n updatedCommunity,\n account,\n });\n setState((state: any) => ({\n ...state,\n communities: { ...state.communities, [communityKey]: updatedCommunity },\n }));\n\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 community.on(\"updatingstatechange\", (updatingState: string) => {\n setState((state: CommunitiesState) => ({\n syncStatuses: getNextSyncStatuses(\n state,\n communityKey,\n normalizeCommunitySyncState(updatingState),\n ),\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], updatingState },\n },\n }));\n });\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 startCommunityUpdatePolling(community, { communityAddressOrRef, communityKey });\n } catch (error) {\n updateCommunitySyncStatus(setState, communityKey, \"failed\");\n throw error;\n } finally {\n pkcGetCommunityPending[pendingKey] = false;\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(communityUpdatePollers).forEach(stopCommunityUpdatePolling);\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,IAAI,sBAAsB,GAA+B,EAAE,CAAC;AAC5D,gFAAgF;AAChF,MAAM,sBAAsB,GAKxB,EAAE,CAAC;AAEP,6CAA6C;AAC7C,MAAM,SAAS,GAAQ,EAAE,CAAC;AAE1B,MAAM,+BAA+B,GAAG,IAAI,CAAC;AAC7C,MAAM,2BAA2B,GAE7B,EAAE,CAAC;AAWP,MAAM,sBAAsB,GAAG,CAAC,UAA+B,EAAuB,EAAE;IACtF,MAAM,cAAc,qBAAQ,UAAU,CAAE,CAAC;IACzC,OAAO,cAAc,CAAC,kBAAkB,CA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EF,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\nlet pkcGetCommunityPending: { [key: string]: boolean } = {};\n// Key pollers by community so delete/reset can stop the matching live instance.\nconst communityUpdatePollers: {\n [communityKey: string]: {\n community: any;\n updateInterval: ReturnType<typeof setInterval>;\n };\n} = {};\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}\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 updateCommunity = (\n community: Community,\n {\n communityAddressOrRef,\n communityKey,\n }: { communityAddressOrRef: string | CommunityIdentifier; communityKey: string },\n) => {\n community.update().catch((error: unknown) =>\n log.trace(\"community.update error\", {\n communityAddressOrRef,\n communityKey,\n community,\n error,\n }),\n );\n};\n\nconst startCommunityUpdatePolling = (\n community: Community,\n {\n communityAddressOrRef,\n communityKey,\n }: { communityAddressOrRef: string | CommunityIdentifier; communityKey: string },\n) => {\n stopCommunityUpdatePolling(communityKey);\n updateCommunity(community, { communityAddressOrRef, communityKey });\n communityUpdatePollers[communityKey] = {\n community,\n updateInterval: setInterval(\n () => updateCommunity(community, { communityAddressOrRef, communityKey }),\n COMMUNITY_UPDATE_INTERVAL_MS,\n ),\n };\n};\n\nconst stopCommunityUpdatePolling = (communityKey: string) => {\n const polling = communityUpdatePollers[communityKey];\n if (!polling) {\n return;\n }\n\n clearPendingCommunityErrors(communityKey);\n clearInterval(polling.updateInterval);\n polling.community.removeAllListeners();\n const listenerIndex = listeners.indexOf(polling.community);\n if (listenerIndex >= 0) {\n listeners.splice(listenerIndex, 1);\n }\n delete communityUpdatePollers[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 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 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 // pkc-js re-emits the record a community was created with when update() starts\n let cachedRecordId = isFromCache ? getCommunityRecordId(firstCommunityState) : undefined;\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 isCachedRecordReplay =\n cachedRecordId !== undefined &&\n getCommunityRecordId(updatedCommunity) === cachedRecordId;\n cachedRecordId = undefined;\n if (isCachedRecordReplay) {\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 await communitiesDatabase.setItem(communityKey, updatedCommunity);\n log(\"communitiesStore community update\", {\n communityAddressOrRef,\n communityKey,\n updatedCommunity,\n account,\n });\n setState((state: any) => ({\n ...state,\n communities: { ...state.communities, [communityKey]: updatedCommunity },\n }));\n\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 community.on(\"updatingstatechange\", (updatingState: string) => {\n setState((state: CommunitiesState) => ({\n syncStatuses: getNextSyncStatuses(\n state,\n communityKey,\n normalizeCommunitySyncState(updatingState),\n ),\n communities: {\n ...state.communities,\n [communityKey]: { ...state.communities[communityKey], updatingState },\n },\n }));\n });\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 startCommunityUpdatePolling(community, { communityAddressOrRef, communityKey });\n } catch (error) {\n updateCommunitySyncStatus(setState, communityKey, \"failed\");\n throw error;\n } finally {\n pkcGetCommunityPending[pendingKey] = false;\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(communityUpdatePollers).forEach(stopCommunityUpdatePolling);\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"]}
package/dist/types.d.ts CHANGED
@@ -203,6 +203,8 @@ export interface UseCommunityResult extends Result, Community {
203
203
  hasCachedData: boolean;
204
204
  lastFetchAttemptAt: number | undefined;
205
205
  lastSuccessfulFetchAt: number | undefined;
206
+ /** The transient error behind the current retries, cleared once the community updates. */
207
+ lastRetriableError: Error | undefined;
206
208
  }
207
209
  export interface UseCommunitiesOptions extends Options {
208
210
  communities?: CommunityIdentifier[];
@@ -477,7 +479,6 @@ export type AccountsActions = {
477
479
  [key: string]: any;
478
480
  };
479
481
  export type PublishCommentOptions = {
480
- gallery?: CommentGalleryItem[];
481
482
  [key: string]: any;
482
483
  };
483
484
  export type PublishVoteOptions = {
@@ -505,7 +506,6 @@ export type ChallengeVerification = {
505
506
  [key: string]: any;
506
507
  };
507
508
  export type CreateCommentOptions = {
508
- gallery?: CommentGalleryItem[];
509
509
  [key: string]: any;
510
510
  };
511
511
  export type CreateCommunityOptions = {
@@ -515,7 +515,6 @@ export type CreateVoteOptions = {
515
515
  [key: string]: any;
516
516
  };
517
517
  export type Comment = {
518
- gallery?: CommentGalleryItem[];
519
518
  [key: string]: any;
520
519
  };
521
520
  export type Vote = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,MAAM,WAAW,OAAO;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,mBAAmB,GAC3B;IACE,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACD;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAGN,MAAM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EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG;IAAE,CAAC,kBAAkB,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAAE,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sEAAsE","sourcesContent":["// Note: the commented out types are TODO functionalities to implement\n\n/**\n * Public interface\n */\n\nexport interface Options {\n accountName?: string;\n onError?(error: Error): void;\n}\n\nexport interface Result {\n state: string;\n error: Error | undefined;\n errors: Error[];\n}\n\nexport interface NameResolverInfo {\n key: string;\n nameSystem: string;\n chainTicker: string;\n provider: string;\n providerLabel: string;\n}\n\nexport type CommunityIdentifier =\n | {\n name: string;\n publicKey?: string;\n }\n | {\n name?: string;\n publicKey: string;\n };\n\n// useAccount(options): result\nexport interface UseAccountOptions extends Options {}\nexport interface UseAccountResult extends Result, Account {}\n\n// useAccounts(options): result\nexport interface UseAccountsOptions extends Options {}\nexport interface UseAccountsResult extends Result {\n accounts: Account[];\n}\n\n// useAccountComments(options): result\nexport interface UseAccountCommentsOptions extends Options {\n filter?: AccountPublicationsFilter;\n commentCid?: string;\n commentIndices?: number[];\n communityAddress?: string;\n parentCid?: string;\n newerThan?: number;\n page?: number;\n pageSize?: number;\n sortType?: \"new\" | \"old\";\n /** @deprecated use sortType */\n order?: \"asc\" | \"desc\";\n}\nexport interface UseAccountCommentsResult extends Result {\n accountComments: AccountComment[];\n}\n\n// useAccountComment(options): result\nexport interface UseAccountCommentOptions extends Options {\n commentIndex?: number;\n commentCid?: string;\n}\nexport interface UseAccountCommentResult extends Result, AccountComment {}\n\n// useAccountVotes(options): result\nexport interface UseAccountVotesOptions extends Options {\n filter?: AccountPublicationsFilter;\n vote?: number;\n commentCid?: string;\n communityAddress?: string;\n newerThan?: number;\n page?: number;\n pageSize?: number;\n sortType?: \"new\" | \"old\";\n /** @deprecated use sortType */\n order?: \"asc\" | \"desc\";\n}\nexport interface UseAccountVotesResult extends Result {\n accountVotes: AccountVote[];\n}\n\n// useAccountVote(options): result\nexport interface UseAccountVoteOptions extends Options {\n commentCid?: string;\n}\nexport interface UseAccountVoteResult extends Result, AccountVote {\n commentCid: string | undefined;\n vote: number | undefined;\n}\n\n// useAccountEdits(options): result\nexport interface UseAccountEditsOptions extends Options {\n filter?: AccountPublicationsFilter;\n}\nexport interface UseAccountEditsResult extends Result {\n accountEdits: AccountEdit[];\n}\n\n// useNotifications(options): result\nexport interface UseNotificationsOptions extends Options {}\nexport interface UseNotificationsResult extends Result {\n notifications: Notification[];\n markAsRead(): Promise<void>;\n}\n\n// useAccountCommunities(options): result\nexport interface UseAccountCommunitiesOptions extends Options {\n onlyIfCached?: boolean;\n}\nexport interface UseAccountCommunitiesResult extends Result {\n accountCommunities: { [communityAddress: string]: AccountCommunity & Partial<Community> };\n}\n\n// usePubsubSubscribe(options): result\nexport interface UsePubsubSubscribeOptions extends Options {\n communityAddress?: string;\n}\nexport interface UsePubsubSubscribeResult extends Result {}\n\n// useComment(options): result\nexport interface UseCommentOptions extends Options {\n commentCid?: string;\n community?: CommunityIdentifier;\n /** Initial data passed to pkc.createComment, for example an embedded crosspost record. */\n initialComment?: Comment;\n onlyIfCached?: boolean;\n autoUpdate?: boolean;\n}\nexport interface UseCommentResult extends Result, Comment {\n refresh(): Promise<void>;\n}\n\nexport interface Crosspost {\n cid: string;\n comment: Comment;\n}\n\nexport interface UseCrosspostOptions extends Options {\n crosspost?: Crosspost;\n autoUpdate?: boolean;\n}\n\nexport interface UseCrosspostResult extends UseCommentResult {\n /** True once the referenced community's signed CommentUpdate has been loaded. */\n isCommunityVerified: boolean;\n}\n\n// useComments(options): result\nexport interface UseCommentsOptions extends Options {\n commentCids?: string[];\n onlyIfCached?: boolean;\n autoUpdate?: boolean;\n}\nexport interface UseCommentsResult extends Result {\n // TODO: remove | undefined, that shouldn't happen when comments have comment.state\n comments: (Comment | undefined)[];\n refresh(): Promise<void>;\n}\n\n// useValidateComment(options): result\nexport interface UseValidateCommentOptions extends Options {\n comment?: Comment;\n validateReplies?: boolean;\n}\nexport interface UseValidateCommentResult extends Result {\n valid: boolean;\n}\n\n// validateComment(comment, options): result\nexport interface ValidateCommentOptions {\n /** @deprecated Ignored, validateComment no longer uses an account. */\n accountName?: string;\n /** Also validate the replies preloaded in comment.raw.commentUpdate.replies. Defaults to true. */\n validateReplies?: boolean;\n /**\n * The comment's community as loaded by useCommunity. Its signer must have signed the\n * commentUpdate. Without it, the signer must be the communityPublicKey the author signed.\n */\n community?: Community;\n}\nexport type ValidateCommentResult = { valid: true } | { valid: false; reason: string };\n\n// useCommentThumbnailUrl(options): result\n// export interface UseCommentThumbnailUrlOptions extends Options {\n// comment?: Comment\n// }\n// export interface UseCommentThumbnailUrlResult extends Result {\n// thumnbailUrl: string | undefined\n// }\n\n// useReplies(options): result\nexport interface UseRepliesOptions extends Options {\n comment?: Comment;\n onlyIfCached?: boolean;\n sortType?: string;\n repliesPerPage?: number;\n flat?: boolean;\n flatDepth?: number;\n accountComments?: FeedOptionsAccountComments;\n filter?: CommentsFilter;\n validateOptimistically?: boolean; // assume replies are valid to first render immediately, then validate, then remove invalid replies, generally safe because validation takes less than 100ms\n streamPage?: boolean; // by default, replies with depth > 1 won't continuously fill the page until repliesPerPage is reached, to not displace the UI\n}\nexport interface UseRepliesResult extends Result {\n replies: Comment[];\n bufferedReplies: Comment[];\n updatedReplies: Comment[];\n hasMore: boolean;\n loadMore(): Promise<void>;\n reset(): Promise<void>;\n}\n\n// useEditedComment(options): result\nexport interface UseEditedCommentOptions extends Options {\n comment?: Comment;\n}\nexport interface UseEditedCommentResult extends Result {\n // editedComment only contains the succeeded and pending props, failed props aren't added\n editedComment: Comment | undefined;\n succeededEdits: { [succeededEditPropertyName: string]: any };\n pendingEdits: { [pendingEditPropertyName: string]: any };\n failedEdits: { [failedEditPropertyName: string]: any };\n // state: 'initializing' | 'unedited' | 'succeeded' | 'pending' | 'failed'\n}\n\n// useCommunity(options): result\nexport type CommunitySyncState =\n | \"initializing\"\n | \"loading\"\n | \"retrying\"\n | \"succeeded\"\n | \"failed\"\n | \"stopped\";\n\nexport interface UseCommunityOptions extends Options {\n community?: CommunityIdentifier;\n onlyIfCached?: boolean;\n}\nexport interface UseCommunityResult extends Result, Community {\n syncState: CommunitySyncState;\n hasCachedData: boolean;\n lastFetchAttemptAt: number | undefined;\n lastSuccessfulFetchAt: number | undefined;\n}\n\n// useCommunities(options): result\nexport interface UseCommunitiesOptions extends Options {\n communities?: CommunityIdentifier[];\n onlyIfCached?: boolean;\n}\nexport interface UseCommunitiesResult extends Result {\n communities: (Community | undefined)[];\n}\n\n// useCommunityStats(options): result\nexport interface UseCommunityStatsOptions extends Options {\n community?: CommunityIdentifier;\n onlyIfCached?: boolean;\n}\nexport interface UseCommunityStatsResult extends Result, CommunityStats {}\n\n// useResolvedCommunityAddress(options): result\nexport interface UseResolvedCommunityAddressOptions extends Options {\n communityAddress: string | undefined;\n cache?: boolean;\n}\nexport interface UseResolvedCommunityAddressResult extends Result {\n resolvedAddress: string | undefined;\n chainProvider: ChainProvider | undefined;\n}\n\n// useFeed(options): result\nexport interface UseFeedOptions extends Options {\n communities?: CommunityIdentifier[];\n sortType?: string;\n postsPerPage?: number;\n newerThan?: number;\n accountComments?: FeedOptionsAccountComments;\n filter?: CommentsFilter;\n modQueue?: string[];\n}\nexport interface UseFeedResult extends Result {\n feed: Comment[];\n hasMore: boolean;\n loadMore(): Promise<void>;\n expandTimeWindow(newerThan?: number): Promise<void>;\n communityKeysWithNewerPosts: string[];\n // communities that still have posts to load, until each has loaded and fetched its last page\n communityKeysWithMore: string[];\n reset(): Promise<void>;\n}\n\n// useBufferedFeeds(options): result\nexport interface UseBufferedFeedsOptions extends Options {\n feedsOptions?: UseFeedOptions[];\n}\nexport interface UseBufferedFeedsResult extends Result {\n bufferedFeeds: Comment[][];\n}\n\n// useAuthor(options): result\nexport interface UseAuthorOptions extends Options {\n authorAddress?: string;\n // the last known comment cid of this author (required, can't fetch author from author address alone)\n commentCid?: string;\n}\nexport interface UseAuthorResult extends Result {\n author: Author | undefined;\n}\n\n// useAuthorComments(options): result\nexport interface UseAuthorCommentsOptions extends Options {\n authorAddress?: string;\n // the last known comment cid of this author (required, can't fetch author comment from author address alone)\n commentCid?: string;\n // TODO: add filter\n filter?: CommentsFilter;\n}\nexport interface UseAuthorCommentsResult extends Result {\n // TODO: remove | undefined, that shouldn't happen when comments have comment.state\n authorComments: (Comment | undefined)[];\n lastCommentCid: string | undefined;\n hasMore: boolean;\n loadMore(): Promise<void>;\n}\n\n// useResolvedAuthorAddress(options): result\nexport interface UseResolvedAuthorAddressOptions extends Options {\n author?: Author;\n cache?: boolean;\n}\nexport interface UseResolvedAuthorAddressResult extends Result {\n resolvedAddress: string | undefined;\n chainProvider: ChainProvider | undefined;\n nameResolver: NameResolverInfo | undefined;\n}\n\n// useAuthorAvatar(options): result\nexport interface UseAuthorAvatarOptions extends Options {\n author?: Author;\n}\nexport interface UseAuthorAvatarResult extends Result {\n imageUrl: string | undefined;\n metadataUrl: string | undefined;\n chainProvider: ChainProvider | undefined;\n}\n\n// useAuthorAddress(options): result\nexport interface UseAuthorAddressOptions extends Options {\n comment?: Comment;\n}\nexport interface UseAuthorAddressResult extends Result {\n authorAddress: string | undefined;\n shortAuthorAddress: string | undefined;\n authorAddressChanged: boolean;\n}\n\n// useCreateAccount(options): result\n// export interface UseCreateAccountOptions extends Options {}\n// export interface UseCreateAccountResult extends Result {\n// createdAccount: Account | undefined\n// createAccount(): Promise<void>\n// }\n\n// useDeleteAccount(options): result\n// export interface UseDeleteAccountOptions extends Options {}\n// export interface UseDeleteAccountResult extends Result {\n// deletedAccount: Account | undefined\n// deleteAccount(): Promise<void>\n// }\n\n// useSetAccount(options): result\n// export interface UseSetAccountOptions extends Options {\n// account?: Account\n// }\n// export interface UseSetAccountResult extends Result {\n// account: Account | undefined\n// setAccount(): Promise<void>\n// }\n\n// useSetActiveAccount(options): result\n// export interface UseSetActiveAccountOptions extends Options {\n// activeAccount?: string\n// }\n// export interface UseSetActiveAccountResult extends Result {\n// activeAccount: string | undefined\n// setActiveAccount(): Promise<void>\n// }\n\n// useSetAccountsOrder(options): result\n// export interface UseSetAccountsOrderOptions extends Options {\n// accountsOrder?: string[]\n// }\n// export interface UseSetAccountsOrderResult extends Result {\n// accountsOrder: string[]\n// setAccountsOrder(): Promise<void>\n// }\n\n// useImportAccount(options): result\n// export interface UseImportAccountOptions extends Options {\n// account?: string\n// }\n// export interface UseImportAccountResult extends Result {\n// importedAccount: Account | undefined\n// importAccount(): Promise<void>\n// }\n\n// useExportAccount(options): result\n// export interface UseExportAccountOptions extends Options {}\n// export interface UseExportAccountResult extends Result {\n// exportedAccount: string | undefined\n// exportAccount(): Promise<void>\n// }\n\n// usePublishComment(options): result\n/** An author-signed image, video or audio attachment. Additional protocol fields are preserved. */\nexport interface CommentGalleryItem {\n url: string;\n htmlTagName: \"img\" | \"video\" | \"audio\";\n width?: number;\n height?: number;\n alt?: string;\n [key: string]: unknown;\n}\n\nexport interface UsePublishCommentOptions extends Options {\n /** Requires the community to enable maxPostGalleryItems or maxReplyGalleryItems. */\n gallery?: CommentGalleryItem[];\n /** Called immediately with the provisional comment, then again if persistence shifts its index. */\n onPendingComment?(accountCommentIndex: number, comment: AccountComment): void;\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishCommentResult extends Result {\n index: number | undefined;\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishComment(): Promise<void>;\n abandonPublish(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// usePublishVote(options): result\nexport interface UsePublishVoteOptions extends Options {\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishVoteResult extends Result {\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishVote(): Promise<void>;\n abandonPublish(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// usePublishCommentEdit(options): result\nexport interface UsePublishCommentEditOptions extends Options {\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishCommentEditResult extends Result {\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishCommentEdit(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// usePublishCommentModeration(options): result\nexport interface UsePublishCommentModerationOptions extends Options {\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishCommentModerationResult extends Result {\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishCommentModeration(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// usePublishCommunityEdit(options): result\nexport interface UsePublishCommunityEditOptions extends Options {\n communityAddress?: string;\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishCommunityEditResult extends Result {\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishCommunityEdit(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// useCreateCommunity(options): result\nexport interface UseCreateCommunityOptions extends Options {\n [createCommunityOption: string]: any;\n}\nexport interface UseCreateCommunityResult extends Result {\n createdCommunity: Community | undefined;\n createCommunity(): Promise<void>;\n}\n\n// useExportCommunity(options): result\nexport interface UseExportCommunityOptions extends Options {\n communityAddress?: string;\n communityAddresses?: string[];\n includePrivateKey?: boolean;\n exportPath?: string;\n signal?: AbortSignal;\n}\nexport interface UseExportCommunityResult extends Result {\n communityExports: CommunityExport[];\n exportCommunity(): Promise<void>;\n}\n\n// useDeleteCommunity(options): result\n// export interface UseDeleteCommunityOptions extends Options {\n// communityAddress?: string\n// }\n// export interface UseDeleteCommunityResult extends Result {\n// deletedCommunity: Community | undefined\n// deleteCommunity(): Promise<void>\n// }\n\n// useSubscribe(options): result\nexport interface UseSubscribeOptions extends Options {\n communityAddress?: string;\n multisubAddress?: string;\n authorAddress?: string;\n}\nexport interface UseSubscribeResult extends Result {\n subscribed: boolean | undefined;\n subscribe(): Promise<void>;\n unsubscribe(): Promise<void>;\n}\n\n// useBlock(options): result\nexport interface UseBlockOptions extends Options {\n address?: string;\n cid?: string;\n}\nexport interface UseBlockResult extends Result {\n blocked: boolean | undefined;\n block(): Promise<void>;\n unblock(): Promise<void>;\n}\n\n// useSaveComment(options): result\nexport interface UseSaveCommentOptions extends Options {\n commentCid?: string;\n}\nexport interface UseSaveCommentResult extends Result {\n saved: boolean | undefined;\n saveComment(): Promise<void>;\n unsaveComment(): Promise<void>;\n}\n\n// useNotify(options): result\n// export interface UseNotifyOptions extends Options {\n// communityAddress?: string\n// multisubAddress?: string\n// authorAddress?: string\n// commentCid?: string\n// }\n// export interface UseNotifyCommunityResult extends Result {\n// notifying: boolean | undefined\n// notify(): Promise<void>\n// unnotify(): Promise<void>\n// }\n\n// useLimit(options): result\n// export interface UseLimitOptions extends Options {\n// address?: string\n// }\n// export interface UseLimitResult extends Result {\n// limited: number | undefined\n// limit(): Promise<void>\n// unlimit(): Promise<void>\n// }\n\n// useSave(options): result\n// export interface UseSaveOptions extends Options {\n// commentCid?: string\n// }\n// export interface UseSaveResult extends Result {\n// saved: boolean | undefined\n// save(): Promise<void>\n// unsave(): Promise<void>\n// }\n\n// useDeleteComment(options): result\n// export interface UseDeleteCommentOptions extends Options {\n// commentCid?: string\n// accountCommentIndex?: number\n// }\n// export interface UseDeleteCommentResult extends Result {\n// deletedComment: Comment | undefined\n// deleteComment(): Promise<void>\n// undeleteComment(): Promise<void>\n// }\n\nexport interface UseClientsStatesOptions extends Options {\n comment?: Comment;\n community?: Community;\n}\ntype ClientUrls = string[];\ntype Peer = string;\nexport interface UseClientsStatesResult extends Result {\n states: { [state: string]: ClientUrls };\n peers: { [clientUrl: string]: Peer[] };\n}\n\nexport interface UseCommunitiesStatesOptions extends Options {\n communities?: CommunityIdentifier[];\n}\nexport interface UseCommunitiesStatesResult extends Result {\n states: { [state: string]: { communityAddresses: string[]; clientUrls: string[] } };\n peers: { [clientUrl: string]: Peer[] };\n}\n\nexport type PkcRpcChallengeOptionInput = {\n option: string;\n label: string;\n default?: string;\n description?: string;\n placeholder?: string;\n required?: boolean;\n [key: string]: unknown;\n};\nexport type PkcRpcChallengeSettings = {\n optionInputs?: PkcRpcChallengeOptionInput[];\n type?: string;\n challenge?: string;\n caseInsensitive?: boolean;\n description?: string;\n [key: string]: unknown;\n};\nexport type PkcRpcSettings = {\n pkcOptions?: Record<string, unknown>;\n challenges?: Record<string, PkcRpcChallengeSettings>;\n [key: string]: any;\n};\nexport interface UsePkcRpcSettingsOptions extends Options {}\nexport interface UsePkcRpcSettingsResult extends Result {\n pkcRpcSettings: PkcRpcSettings | undefined;\n setPkcRpcSettings(pkcRpcSettings: PkcRpcSettings): Promise<void>;\n}\n\n/**\n * TODO: define these types more in depth, most are already defined in:\n * https://github.com/pkcprotocol/pkc-js or\n * https://github.com/bitsocialnet/bitsocial-react-hooks/blob/master/docs/schema.md\n */\nexport type Account = { [key: string]: any };\nexport type AccountsActions = { [key: string]: any };\nexport type PublishCommentOptions = { gallery?: CommentGalleryItem[]; [key: string]: any };\nexport type PublishVoteOptions = { [key: string]: any };\nexport type PublishCommentEditOptions = { [key: string]: any };\nexport type PublishCommentModerationOptions = { [key: string]: any };\nexport type PublishCommunityEditOptions = { [key: string]: any };\nexport interface ExportCommunityOptions {\n includePrivateKey?: boolean;\n exportPath?: string;\n signal?: AbortSignal;\n [key: string]: unknown;\n}\nexport type Challenge = { [key: string]: any };\nexport type ChallengeVerification = { [key: string]: any };\nexport type CreateCommentOptions = { gallery?: CommentGalleryItem[]; [key: string]: any };\nexport type CreateCommunityOptions = { [key: string]: any };\nexport type CreateVoteOptions = { [key: string]: any };\nexport type Comment = { gallery?: CommentGalleryItem[]; [key: string]: any };\nexport type Vote = { [key: string]: any };\nexport type CommentEdit = { [key: string]: any };\nexport type CommentModeration = { [key: string]: any };\nexport type CommunityEdit = { [key: string]: any };\nexport type Community = { [key: string]: any };\nexport type CommunityExport = {\n communityAddress: string;\n exportId: string;\n name?: string;\n publicKey?: string;\n includePrivateKey?: boolean;\n progress?: number;\n url?: string;\n [key: string]: unknown;\n};\nexport type CommunityStats = { [key: string]: any };\nexport type Notification = { [key: string]: any };\nexport type Nft = { [key: string]: any };\nexport type Author = { [key: string]: any };\nexport type Wallet = { [key: string]: any };\n\n/**\n * Communities and comments store\n */\nexport type Communities = { [communityAddress: string]: Community };\nexport type Comments = { [commentCid: string]: Comment };\n\n/**\n * Accounts store\n */\nexport type Accounts = { [accountId: string]: Account };\nexport type AccountNamesToAccountIds = { [accountName: string]: string };\nexport interface AccountComment extends Comment {\n index: number;\n accountId: string;\n}\nexport type AccountComments = AccountComment[];\nexport type AccountsComments = { [accountId: string]: AccountComments };\nexport type AccountCommentsIndex = {\n byCommunityAddress: { [communityAddress: string]: number[] };\n byParentCid: { [parentCid: string]: number[] };\n};\nexport type AccountsCommentsIndexes = { [accountId: string]: AccountCommentsIndex };\nexport type CommentCidsToAccountsComments = {\n [commentCid: string]: { accountId: string; accountCommentIndex: number };\n};\nexport interface AccountCommentReply extends Comment {\n markedAsRead: boolean;\n}\nexport type AccountCommentsReplies = { [replyCid: string]: AccountCommentReply };\nexport type AccountsCommentsReplies = { [accountId: string]: AccountCommentsReplies };\nexport type AccountsNotifications = { [accountId: string]: Notification[] };\nexport type Role = {\n role: \"owner\" | \"admin\" | \"moderator\";\n};\nexport type AccountCommunity = {\n role: Role;\n};\nexport type AccountsVotes = { [accountId: string]: AccountVotes };\nexport type AccountVotes = { [commentCid: string]: AccountVote };\nexport type AccountVote = {\n // has all the publish options like commentCid, vote, timestamp, etc\n [publishOption: string]: any;\n};\nexport type AccountsEdits = { [accountId: string]: AccountEdits };\nexport type AccountEdits = { [commentCidOrCommunityAddress: string]: AccountEdit[] };\nexport type AccountEditPropertySummary = {\n timestamp: number;\n value: any;\n};\nexport type AccountEditsSummary = {\n [commentCidOrCommunityAddress: string]: {\n [propertyName: string]: AccountEditPropertySummary;\n };\n};\nexport type AccountsEditsSummaries = { [accountId: string]: AccountEditsSummary };\nexport type AccountEdit = {\n // has all the publish options like commentCid, vote, timestamp, etc (both comment edits and community edits)\n [publishOption: string]: any;\n};\nexport type AccountPublicationsFilter = (\n publication: AccountComment | AccountVote | AccountEdit,\n) => Boolean;\n\n/**\n * Feeds store\n */\nexport type Feed = Comment[];\nexport type Feeds = { [feedName: string]: Feed };\nexport type FeedOptions = {\n communities: CommunityIdentifier[];\n communityKeys: string[];\n sortType?: string;\n /** @deprecated Ignored. Feed sort names are no longer derived from time windows. */\n requestedSortType?: string;\n accountId: string;\n pageNumber: number;\n postsPerPage: number;\n filter: CommentsFilter;\n newerThan?: number;\n accountComments?: FeedOptionsAccountComments;\n modQueue?: string[];\n};\nexport type FeedOptionsAccountComments = {\n newerThan?: number;\n append?: boolean; // default to prepend, set append: true to append instead\n};\nexport type FeedsOptions = { [feedName: string]: FeedOptions };\nexport type FeedCommunitiesPostCounts = { [communityAddress: string]: number };\nexport type FeedsCommunitiesPostCounts = { [feedName: string]: FeedCommunitiesPostCounts };\nexport type CommunityPage = {\n nextCid?: string;\n comments: Comment[];\n};\nexport type CommunitiesPages = { [pageCid: string]: CommunityPage };\nexport type CommentsFilter = {\n filter(comment: Comment): Boolean;\n key: string;\n};\n\n/**\n * Replies store\n */\n// NOTE: to have different replies options for different depth, eg smaller repliesPerPage for depth > 1,\n// we will need another prop, eg `{depth: '>1': {repliesPerPage: 3}}`, because of how react renders work\nexport type RepliesFeedOptions = {\n commentCid: string;\n commentDepth: number;\n postCid: string;\n sortType?: string;\n accountId: string;\n pageNumber: number;\n repliesPerPage: number;\n onlyIfCached?: boolean;\n flat?: boolean;\n accountComments?: FeedOptionsAccountComments;\n filter?: CommentsFilter;\n streamPage?: boolean; // by default, replies with depth > 1 won't continuously fill the page until repliesPerPage is reached, to not displace the UI\n};\nexport type RepliesFeedsOptions = { [feedName: string]: RepliesFeedOptions };\nexport type RepliesPage = CommunityPage;\nexport type RepliesPages = { [pageCid: string]: RepliesPage };\n\n/**\n * Authors comments store\n */\n// authorCommentsName is a string used a key to represent authorAddress + filter + accountId\nexport type AuthorsComments = { [authorCommentsName: string]: Comment[] };\nexport type AuthorCommentsOptions = {\n authorAddress: string;\n pageNumber: number;\n filter?: CommentsFilter;\n accountId: string;\n};\nexport type AuthorsCommentsOptions = { [authorCommentsName: string]: FeedOptions };\n\n/**\n * Other\n */\nexport type ChainProvider = {\n chainId?: number;\n urls?: string[];\n};\nexport type ChainProviders = { [chainTicker: string]: ChainProvider };\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sEAAsE","sourcesContent":["// Note: the commented out types are TODO functionalities to implement\n\n/**\n * Public interface\n */\n\nexport interface Options {\n accountName?: string;\n onError?(error: Error): void;\n}\n\nexport interface Result {\n state: string;\n error: Error | undefined;\n errors: Error[];\n}\n\nexport interface NameResolverInfo {\n key: string;\n nameSystem: string;\n chainTicker: string;\n provider: string;\n providerLabel: string;\n}\n\nexport type CommunityIdentifier =\n | {\n name: string;\n publicKey?: string;\n }\n | {\n name?: string;\n publicKey: string;\n };\n\n// useAccount(options): result\nexport interface UseAccountOptions extends Options {}\nexport interface UseAccountResult extends Result, Account {}\n\n// useAccounts(options): result\nexport interface UseAccountsOptions extends Options {}\nexport interface UseAccountsResult extends Result {\n accounts: Account[];\n}\n\n// useAccountComments(options): result\nexport interface UseAccountCommentsOptions extends Options {\n filter?: AccountPublicationsFilter;\n commentCid?: string;\n commentIndices?: number[];\n communityAddress?: string;\n parentCid?: string;\n newerThan?: number;\n page?: number;\n pageSize?: number;\n sortType?: \"new\" | \"old\";\n /** @deprecated use sortType */\n order?: \"asc\" | \"desc\";\n}\nexport interface UseAccountCommentsResult extends Result {\n accountComments: AccountComment[];\n}\n\n// useAccountComment(options): result\nexport interface UseAccountCommentOptions extends Options {\n commentIndex?: number;\n commentCid?: string;\n}\nexport interface UseAccountCommentResult extends Result, AccountComment {}\n\n// useAccountVotes(options): result\nexport interface UseAccountVotesOptions extends Options {\n filter?: AccountPublicationsFilter;\n vote?: number;\n commentCid?: string;\n communityAddress?: string;\n newerThan?: number;\n page?: number;\n pageSize?: number;\n sortType?: \"new\" | \"old\";\n /** @deprecated use sortType */\n order?: \"asc\" | \"desc\";\n}\nexport interface UseAccountVotesResult extends Result {\n accountVotes: AccountVote[];\n}\n\n// useAccountVote(options): result\nexport interface UseAccountVoteOptions extends Options {\n commentCid?: string;\n}\nexport interface UseAccountVoteResult extends Result, AccountVote {\n commentCid: string | undefined;\n vote: number | undefined;\n}\n\n// useAccountEdits(options): result\nexport interface UseAccountEditsOptions extends Options {\n filter?: AccountPublicationsFilter;\n}\nexport interface UseAccountEditsResult extends Result {\n accountEdits: AccountEdit[];\n}\n\n// useNotifications(options): result\nexport interface UseNotificationsOptions extends Options {}\nexport interface UseNotificationsResult extends Result {\n notifications: Notification[];\n markAsRead(): Promise<void>;\n}\n\n// useAccountCommunities(options): result\nexport interface UseAccountCommunitiesOptions extends Options {\n onlyIfCached?: boolean;\n}\nexport interface UseAccountCommunitiesResult extends Result {\n accountCommunities: { [communityAddress: string]: AccountCommunity & Partial<Community> };\n}\n\n// usePubsubSubscribe(options): result\nexport interface UsePubsubSubscribeOptions extends Options {\n communityAddress?: string;\n}\nexport interface UsePubsubSubscribeResult extends Result {}\n\n// useComment(options): result\nexport interface UseCommentOptions extends Options {\n commentCid?: string;\n community?: CommunityIdentifier;\n /** Initial data passed to pkc.createComment, for example an embedded crosspost record. */\n initialComment?: Comment;\n onlyIfCached?: boolean;\n autoUpdate?: boolean;\n}\nexport interface UseCommentResult extends Result, Comment {\n refresh(): Promise<void>;\n}\n\nexport interface Crosspost {\n cid: string;\n comment: Comment;\n}\n\nexport interface UseCrosspostOptions extends Options {\n crosspost?: Crosspost;\n autoUpdate?: boolean;\n}\n\nexport interface UseCrosspostResult extends UseCommentResult {\n /** True once the referenced community's signed CommentUpdate has been loaded. */\n isCommunityVerified: boolean;\n}\n\n// useComments(options): result\nexport interface UseCommentsOptions extends Options {\n commentCids?: string[];\n onlyIfCached?: boolean;\n autoUpdate?: boolean;\n}\nexport interface UseCommentsResult extends Result {\n // TODO: remove | undefined, that shouldn't happen when comments have comment.state\n comments: (Comment | undefined)[];\n refresh(): Promise<void>;\n}\n\n// useValidateComment(options): result\nexport interface UseValidateCommentOptions extends Options {\n comment?: Comment;\n validateReplies?: boolean;\n}\nexport interface UseValidateCommentResult extends Result {\n valid: boolean;\n}\n\n// validateComment(comment, options): result\nexport interface ValidateCommentOptions {\n /** @deprecated Ignored, validateComment no longer uses an account. */\n accountName?: string;\n /** Also validate the replies preloaded in comment.raw.commentUpdate.replies. Defaults to true. */\n validateReplies?: boolean;\n /**\n * The comment's community as loaded by useCommunity. Its signer must have signed the\n * commentUpdate. Without it, the signer must be the communityPublicKey the author signed.\n */\n community?: Community;\n}\nexport type ValidateCommentResult = { valid: true } | { valid: false; reason: string };\n\n// useCommentThumbnailUrl(options): result\n// export interface UseCommentThumbnailUrlOptions extends Options {\n// comment?: Comment\n// }\n// export interface UseCommentThumbnailUrlResult extends Result {\n// thumnbailUrl: string | undefined\n// }\n\n// useReplies(options): result\nexport interface UseRepliesOptions extends Options {\n comment?: Comment;\n onlyIfCached?: boolean;\n sortType?: string;\n repliesPerPage?: number;\n flat?: boolean;\n flatDepth?: number;\n accountComments?: FeedOptionsAccountComments;\n filter?: CommentsFilter;\n validateOptimistically?: boolean; // assume replies are valid to first render immediately, then validate, then remove invalid replies, generally safe because validation takes less than 100ms\n streamPage?: boolean; // by default, replies with depth > 1 won't continuously fill the page until repliesPerPage is reached, to not displace the UI\n}\nexport interface UseRepliesResult extends Result {\n replies: Comment[];\n bufferedReplies: Comment[];\n updatedReplies: Comment[];\n hasMore: boolean;\n loadMore(): Promise<void>;\n reset(): Promise<void>;\n}\n\n// useEditedComment(options): result\nexport interface UseEditedCommentOptions extends Options {\n comment?: Comment;\n}\nexport interface UseEditedCommentResult extends Result {\n // editedComment only contains the succeeded and pending props, failed props aren't added\n editedComment: Comment | undefined;\n succeededEdits: { [succeededEditPropertyName: string]: any };\n pendingEdits: { [pendingEditPropertyName: string]: any };\n failedEdits: { [failedEditPropertyName: string]: any };\n // state: 'initializing' | 'unedited' | 'succeeded' | 'pending' | 'failed'\n}\n\n// useCommunity(options): result\nexport type CommunitySyncState =\n | \"initializing\"\n | \"loading\"\n | \"retrying\"\n | \"succeeded\"\n | \"failed\"\n | \"stopped\";\n\nexport interface UseCommunityOptions extends Options {\n community?: CommunityIdentifier;\n onlyIfCached?: boolean;\n}\nexport interface UseCommunityResult extends Result, Community {\n syncState: CommunitySyncState;\n hasCachedData: boolean;\n lastFetchAttemptAt: number | undefined;\n lastSuccessfulFetchAt: number | undefined;\n /** The transient error behind the current retries, cleared once the community updates. */\n lastRetriableError: Error | undefined;\n}\n\n// useCommunities(options): result\nexport interface UseCommunitiesOptions extends Options {\n communities?: CommunityIdentifier[];\n onlyIfCached?: boolean;\n}\nexport interface UseCommunitiesResult extends Result {\n communities: (Community | undefined)[];\n}\n\n// useCommunityStats(options): result\nexport interface UseCommunityStatsOptions extends Options {\n community?: CommunityIdentifier;\n onlyIfCached?: boolean;\n}\nexport interface UseCommunityStatsResult extends Result, CommunityStats {}\n\n// useResolvedCommunityAddress(options): result\nexport interface UseResolvedCommunityAddressOptions extends Options {\n communityAddress: string | undefined;\n cache?: boolean;\n}\nexport interface UseResolvedCommunityAddressResult extends Result {\n resolvedAddress: string | undefined;\n chainProvider: ChainProvider | undefined;\n}\n\n// useFeed(options): result\nexport interface UseFeedOptions extends Options {\n communities?: CommunityIdentifier[];\n sortType?: string;\n postsPerPage?: number;\n newerThan?: number;\n accountComments?: FeedOptionsAccountComments;\n filter?: CommentsFilter;\n modQueue?: string[];\n}\nexport interface UseFeedResult extends Result {\n feed: Comment[];\n hasMore: boolean;\n loadMore(): Promise<void>;\n expandTimeWindow(newerThan?: number): Promise<void>;\n communityKeysWithNewerPosts: string[];\n // communities that still have posts to load, until each has loaded and fetched its last page\n communityKeysWithMore: string[];\n reset(): Promise<void>;\n}\n\n// useBufferedFeeds(options): result\nexport interface UseBufferedFeedsOptions extends Options {\n feedsOptions?: UseFeedOptions[];\n}\nexport interface UseBufferedFeedsResult extends Result {\n bufferedFeeds: Comment[][];\n}\n\n// useAuthor(options): result\nexport interface UseAuthorOptions extends Options {\n authorAddress?: string;\n // the last known comment cid of this author (required, can't fetch author from author address alone)\n commentCid?: string;\n}\nexport interface UseAuthorResult extends Result {\n author: Author | undefined;\n}\n\n// useAuthorComments(options): result\nexport interface UseAuthorCommentsOptions extends Options {\n authorAddress?: string;\n // the last known comment cid of this author (required, can't fetch author comment from author address alone)\n commentCid?: string;\n // TODO: add filter\n filter?: CommentsFilter;\n}\nexport interface UseAuthorCommentsResult extends Result {\n // TODO: remove | undefined, that shouldn't happen when comments have comment.state\n authorComments: (Comment | undefined)[];\n lastCommentCid: string | undefined;\n hasMore: boolean;\n loadMore(): Promise<void>;\n}\n\n// useResolvedAuthorAddress(options): result\nexport interface UseResolvedAuthorAddressOptions extends Options {\n author?: Author;\n cache?: boolean;\n}\nexport interface UseResolvedAuthorAddressResult extends Result {\n resolvedAddress: string | undefined;\n chainProvider: ChainProvider | undefined;\n nameResolver: NameResolverInfo | undefined;\n}\n\n// useAuthorAvatar(options): result\nexport interface UseAuthorAvatarOptions extends Options {\n author?: Author;\n}\nexport interface UseAuthorAvatarResult extends Result {\n imageUrl: string | undefined;\n metadataUrl: string | undefined;\n chainProvider: ChainProvider | undefined;\n}\n\n// useAuthorAddress(options): result\nexport interface UseAuthorAddressOptions extends Options {\n comment?: Comment;\n}\nexport interface UseAuthorAddressResult extends Result {\n authorAddress: string | undefined;\n shortAuthorAddress: string | undefined;\n authorAddressChanged: boolean;\n}\n\n// useCreateAccount(options): result\n// export interface UseCreateAccountOptions extends Options {}\n// export interface UseCreateAccountResult extends Result {\n// createdAccount: Account | undefined\n// createAccount(): Promise<void>\n// }\n\n// useDeleteAccount(options): result\n// export interface UseDeleteAccountOptions extends Options {}\n// export interface UseDeleteAccountResult extends Result {\n// deletedAccount: Account | undefined\n// deleteAccount(): Promise<void>\n// }\n\n// useSetAccount(options): result\n// export interface UseSetAccountOptions extends Options {\n// account?: Account\n// }\n// export interface UseSetAccountResult extends Result {\n// account: Account | undefined\n// setAccount(): Promise<void>\n// }\n\n// useSetActiveAccount(options): result\n// export interface UseSetActiveAccountOptions extends Options {\n// activeAccount?: string\n// }\n// export interface UseSetActiveAccountResult extends Result {\n// activeAccount: string | undefined\n// setActiveAccount(): Promise<void>\n// }\n\n// useSetAccountsOrder(options): result\n// export interface UseSetAccountsOrderOptions extends Options {\n// accountsOrder?: string[]\n// }\n// export interface UseSetAccountsOrderResult extends Result {\n// accountsOrder: string[]\n// setAccountsOrder(): Promise<void>\n// }\n\n// useImportAccount(options): result\n// export interface UseImportAccountOptions extends Options {\n// account?: string\n// }\n// export interface UseImportAccountResult extends Result {\n// importedAccount: Account | undefined\n// importAccount(): Promise<void>\n// }\n\n// useExportAccount(options): result\n// export interface UseExportAccountOptions extends Options {}\n// export interface UseExportAccountResult extends Result {\n// exportedAccount: string | undefined\n// exportAccount(): Promise<void>\n// }\n\n// usePublishComment(options): result\n/** An author-signed image, video or audio attachment. Additional protocol fields are preserved. */\nexport interface CommentGalleryItem {\n url: string;\n htmlTagName: \"img\" | \"video\" | \"audio\";\n width?: number;\n height?: number;\n alt?: string;\n [key: string]: unknown;\n}\n\nexport interface UsePublishCommentOptions extends Options {\n /** Requires the community to enable maxPostGalleryItems or maxReplyGalleryItems. */\n gallery?: CommentGalleryItem[];\n /** Called immediately with the provisional comment, then again if persistence shifts its index. */\n onPendingComment?(accountCommentIndex: number, comment: AccountComment): void;\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishCommentResult extends Result {\n index: number | undefined;\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishComment(): Promise<void>;\n abandonPublish(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// usePublishVote(options): result\nexport interface UsePublishVoteOptions extends Options {\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishVoteResult extends Result {\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishVote(): Promise<void>;\n abandonPublish(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// usePublishCommentEdit(options): result\nexport interface UsePublishCommentEditOptions extends Options {\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishCommentEditResult extends Result {\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishCommentEdit(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// usePublishCommentModeration(options): result\nexport interface UsePublishCommentModerationOptions extends Options {\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishCommentModerationResult extends Result {\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishCommentModeration(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// usePublishCommunityEdit(options): result\nexport interface UsePublishCommunityEditOptions extends Options {\n communityAddress?: string;\n onChallenge?(challenge: Challenge, comment?: Comment): Promise<void>;\n onChallengeVerification?(\n challengeVerification: ChallengeVerification,\n comment?: Comment,\n ): Promise<void>;\n [publishOption: string]: any;\n}\nexport interface UsePublishCommunityEditResult extends Result {\n challenge: Challenge | undefined;\n challengeVerification: ChallengeVerification | undefined;\n publishCommunityEdit(): Promise<void>;\n publishChallengeAnswers(challengeAnswers?: string[]): Promise<void>;\n}\n\n// useCreateCommunity(options): result\nexport interface UseCreateCommunityOptions extends Options {\n [createCommunityOption: string]: any;\n}\nexport interface UseCreateCommunityResult extends Result {\n createdCommunity: Community | undefined;\n createCommunity(): Promise<void>;\n}\n\n// useExportCommunity(options): result\nexport interface UseExportCommunityOptions extends Options {\n communityAddress?: string;\n communityAddresses?: string[];\n includePrivateKey?: boolean;\n exportPath?: string;\n signal?: AbortSignal;\n}\nexport interface UseExportCommunityResult extends Result {\n communityExports: CommunityExport[];\n exportCommunity(): Promise<void>;\n}\n\n// useDeleteCommunity(options): result\n// export interface UseDeleteCommunityOptions extends Options {\n// communityAddress?: string\n// }\n// export interface UseDeleteCommunityResult extends Result {\n// deletedCommunity: Community | undefined\n// deleteCommunity(): Promise<void>\n// }\n\n// useSubscribe(options): result\nexport interface UseSubscribeOptions extends Options {\n communityAddress?: string;\n multisubAddress?: string;\n authorAddress?: string;\n}\nexport interface UseSubscribeResult extends Result {\n subscribed: boolean | undefined;\n subscribe(): Promise<void>;\n unsubscribe(): Promise<void>;\n}\n\n// useBlock(options): result\nexport interface UseBlockOptions extends Options {\n address?: string;\n cid?: string;\n}\nexport interface UseBlockResult extends Result {\n blocked: boolean | undefined;\n block(): Promise<void>;\n unblock(): Promise<void>;\n}\n\n// useSaveComment(options): result\nexport interface UseSaveCommentOptions extends Options {\n commentCid?: string;\n}\nexport interface UseSaveCommentResult extends Result {\n saved: boolean | undefined;\n saveComment(): Promise<void>;\n unsaveComment(): Promise<void>;\n}\n\n// useNotify(options): result\n// export interface UseNotifyOptions extends Options {\n// communityAddress?: string\n// multisubAddress?: string\n// authorAddress?: string\n// commentCid?: string\n// }\n// export interface UseNotifyCommunityResult extends Result {\n// notifying: boolean | undefined\n// notify(): Promise<void>\n// unnotify(): Promise<void>\n// }\n\n// useLimit(options): result\n// export interface UseLimitOptions extends Options {\n// address?: string\n// }\n// export interface UseLimitResult extends Result {\n// limited: number | undefined\n// limit(): Promise<void>\n// unlimit(): Promise<void>\n// }\n\n// useSave(options): result\n// export interface UseSaveOptions extends Options {\n// commentCid?: string\n// }\n// export interface UseSaveResult extends Result {\n// saved: boolean | undefined\n// save(): Promise<void>\n// unsave(): Promise<void>\n// }\n\n// useDeleteComment(options): result\n// export interface UseDeleteCommentOptions extends Options {\n// commentCid?: string\n// accountCommentIndex?: number\n// }\n// export interface UseDeleteCommentResult extends Result {\n// deletedComment: Comment | undefined\n// deleteComment(): Promise<void>\n// undeleteComment(): Promise<void>\n// }\n\nexport interface UseClientsStatesOptions extends Options {\n comment?: Comment;\n community?: Community;\n}\ntype ClientUrls = string[];\ntype Peer = string;\nexport interface UseClientsStatesResult extends Result {\n states: { [state: string]: ClientUrls };\n peers: { [clientUrl: string]: Peer[] };\n}\n\nexport interface UseCommunitiesStatesOptions extends Options {\n communities?: CommunityIdentifier[];\n}\nexport interface UseCommunitiesStatesResult extends Result {\n states: { [state: string]: { communityAddresses: string[]; clientUrls: string[] } };\n peers: { [clientUrl: string]: Peer[] };\n}\n\nexport type PkcRpcChallengeOptionInput = {\n option: string;\n label: string;\n default?: string;\n description?: string;\n placeholder?: string;\n required?: boolean;\n [key: string]: unknown;\n};\nexport type PkcRpcChallengeSettings = {\n optionInputs?: PkcRpcChallengeOptionInput[];\n type?: string;\n challenge?: string;\n caseInsensitive?: boolean;\n description?: string;\n [key: string]: unknown;\n};\nexport type PkcRpcSettings = {\n pkcOptions?: Record<string, unknown>;\n challenges?: Record<string, PkcRpcChallengeSettings>;\n [key: string]: any;\n};\nexport interface UsePkcRpcSettingsOptions extends Options {}\nexport interface UsePkcRpcSettingsResult extends Result {\n pkcRpcSettings: PkcRpcSettings | undefined;\n setPkcRpcSettings(pkcRpcSettings: PkcRpcSettings): Promise<void>;\n}\n\n/**\n * TODO: define these types more in depth, most are already defined in:\n * https://github.com/pkcprotocol/pkc-js or\n * https://github.com/bitsocialnet/bitsocial-react-hooks/blob/master/docs/schema.md\n */\nexport type Account = { [key: string]: any };\nexport type AccountsActions = { [key: string]: any };\nexport type PublishCommentOptions = { [key: string]: any };\nexport type PublishVoteOptions = { [key: string]: any };\nexport type PublishCommentEditOptions = { [key: string]: any };\nexport type PublishCommentModerationOptions = { [key: string]: any };\nexport type PublishCommunityEditOptions = { [key: string]: any };\nexport interface ExportCommunityOptions {\n includePrivateKey?: boolean;\n exportPath?: string;\n signal?: AbortSignal;\n [key: string]: unknown;\n}\nexport type Challenge = { [key: string]: any };\nexport type ChallengeVerification = { [key: string]: any };\nexport type CreateCommentOptions = { [key: string]: any };\nexport type CreateCommunityOptions = { [key: string]: any };\nexport type CreateVoteOptions = { [key: string]: any };\n// Keep this open shape assignable to consumers selecting arbitrary optional comment fields.\n// Adding a named optional field triggers TypeScript weak-target checks (see types.compat.test.ts).\nexport type Comment = { [key: string]: any };\nexport type Vote = { [key: string]: any };\nexport type CommentEdit = { [key: string]: any };\nexport type CommentModeration = { [key: string]: any };\nexport type CommunityEdit = { [key: string]: any };\nexport type Community = { [key: string]: any };\nexport type CommunityExport = {\n communityAddress: string;\n exportId: string;\n name?: string;\n publicKey?: string;\n includePrivateKey?: boolean;\n progress?: number;\n url?: string;\n [key: string]: unknown;\n};\nexport type CommunityStats = { [key: string]: any };\nexport type Notification = { [key: string]: any };\nexport type Nft = { [key: string]: any };\nexport type Author = { [key: string]: any };\nexport type Wallet = { [key: string]: any };\n\n/**\n * Communities and comments store\n */\nexport type Communities = { [communityAddress: string]: Community };\nexport type Comments = { [commentCid: string]: Comment };\n\n/**\n * Accounts store\n */\nexport type Accounts = { [accountId: string]: Account };\nexport type AccountNamesToAccountIds = { [accountName: string]: string };\nexport interface AccountComment extends Comment {\n index: number;\n accountId: string;\n}\nexport type AccountComments = AccountComment[];\nexport type AccountsComments = { [accountId: string]: AccountComments };\nexport type AccountCommentsIndex = {\n byCommunityAddress: { [communityAddress: string]: number[] };\n byParentCid: { [parentCid: string]: number[] };\n};\nexport type AccountsCommentsIndexes = { [accountId: string]: AccountCommentsIndex };\nexport type CommentCidsToAccountsComments = {\n [commentCid: string]: { accountId: string; accountCommentIndex: number };\n};\nexport interface AccountCommentReply extends Comment {\n markedAsRead: boolean;\n}\nexport type AccountCommentsReplies = { [replyCid: string]: AccountCommentReply };\nexport type AccountsCommentsReplies = { [accountId: string]: AccountCommentsReplies };\nexport type AccountsNotifications = { [accountId: string]: Notification[] };\nexport type Role = {\n role: \"owner\" | \"admin\" | \"moderator\";\n};\nexport type AccountCommunity = {\n role: Role;\n};\nexport type AccountsVotes = { [accountId: string]: AccountVotes };\nexport type AccountVotes = { [commentCid: string]: AccountVote };\nexport type AccountVote = {\n // has all the publish options like commentCid, vote, timestamp, etc\n [publishOption: string]: any;\n};\nexport type AccountsEdits = { [accountId: string]: AccountEdits };\nexport type AccountEdits = { [commentCidOrCommunityAddress: string]: AccountEdit[] };\nexport type AccountEditPropertySummary = {\n timestamp: number;\n value: any;\n};\nexport type AccountEditsSummary = {\n [commentCidOrCommunityAddress: string]: {\n [propertyName: string]: AccountEditPropertySummary;\n };\n};\nexport type AccountsEditsSummaries = { [accountId: string]: AccountEditsSummary };\nexport type AccountEdit = {\n // has all the publish options like commentCid, vote, timestamp, etc (both comment edits and community edits)\n [publishOption: string]: any;\n};\nexport type AccountPublicationsFilter = (\n publication: AccountComment | AccountVote | AccountEdit,\n) => Boolean;\n\n/**\n * Feeds store\n */\nexport type Feed = Comment[];\nexport type Feeds = { [feedName: string]: Feed };\nexport type FeedOptions = {\n communities: CommunityIdentifier[];\n communityKeys: string[];\n sortType?: string;\n /** @deprecated Ignored. Feed sort names are no longer derived from time windows. */\n requestedSortType?: string;\n accountId: string;\n pageNumber: number;\n postsPerPage: number;\n filter: CommentsFilter;\n newerThan?: number;\n accountComments?: FeedOptionsAccountComments;\n modQueue?: string[];\n};\nexport type FeedOptionsAccountComments = {\n newerThan?: number;\n append?: boolean; // default to prepend, set append: true to append instead\n};\nexport type FeedsOptions = { [feedName: string]: FeedOptions };\nexport type FeedCommunitiesPostCounts = { [communityAddress: string]: number };\nexport type FeedsCommunitiesPostCounts = { [feedName: string]: FeedCommunitiesPostCounts };\nexport type CommunityPage = {\n nextCid?: string;\n comments: Comment[];\n};\nexport type CommunitiesPages = { [pageCid: string]: CommunityPage };\nexport type CommentsFilter = {\n filter(comment: Comment): Boolean;\n key: string;\n};\n\n/**\n * Replies store\n */\n// NOTE: to have different replies options for different depth, eg smaller repliesPerPage for depth > 1,\n// we will need another prop, eg `{depth: '>1': {repliesPerPage: 3}}`, because of how react renders work\nexport type RepliesFeedOptions = {\n commentCid: string;\n commentDepth: number;\n postCid: string;\n sortType?: string;\n accountId: string;\n pageNumber: number;\n repliesPerPage: number;\n onlyIfCached?: boolean;\n flat?: boolean;\n accountComments?: FeedOptionsAccountComments;\n filter?: CommentsFilter;\n streamPage?: boolean; // by default, replies with depth > 1 won't continuously fill the page until repliesPerPage is reached, to not displace the UI\n};\nexport type RepliesFeedsOptions = { [feedName: string]: RepliesFeedOptions };\nexport type RepliesPage = CommunityPage;\nexport type RepliesPages = { [pageCid: string]: RepliesPage };\n\n/**\n * Authors comments store\n */\n// authorCommentsName is a string used a key to represent authorAddress + filter + accountId\nexport type AuthorsComments = { [authorCommentsName: string]: Comment[] };\nexport type AuthorCommentsOptions = {\n authorAddress: string;\n pageNumber: number;\n filter?: CommentsFilter;\n accountId: string;\n};\nexport type AuthorsCommentsOptions = { [authorCommentsName: string]: FeedOptions };\n\n/**\n * Other\n */\nexport type ChainProvider = {\n chainId?: number;\n urls?: string[];\n};\nexport type ChainProviders = { [chainTicker: string]: ChainProvider };\n"]}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
- "version": "0.1.63",
17
+ "version": "0.1.65",
18
18
  "packageManager": "yarn@4.13.0",
19
19
  "files": [
20
20
  "CHANGELOG.md",