@bitsocial/bitsocial-react-hooks 0.1.6 → 0.1.7
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 +9 -0
- package/README.md +3 -3
- package/dist/hooks/comments.d.ts +1 -0
- package/dist/hooks/comments.d.ts.map +1 -1
- package/dist/hooks/comments.js +58 -7
- package/dist/hooks/comments.js.map +1 -1
- package/dist/stores/comments/comments-store.d.ts.map +1 -1
- package/dist/stores/comments/comments-store.js +21 -12
- package/dist/stores/comments/comments-store.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [0.1.7](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.6...v0.1.7) (2026-05-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **comments:** pass community identity to pkc comments ([8db8b8c](https://github.com/bitsocialnet/bitsocial-react-hooks/commit/8db8b8c033e3d4c39e5a17e069405560014826fa))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
## [0.1.6](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.5...v0.1.6) (2026-05-05)
|
|
2
11
|
|
|
3
12
|
|
package/README.md
CHANGED
|
@@ -119,7 +119,7 @@ useNotifications(): {notifications: Notification[], markAsRead: Function}
|
|
|
119
119
|
#### Comments Hooks
|
|
120
120
|
|
|
121
121
|
```
|
|
122
|
-
useComment({commentCid: string, onlyIfCached?: boolean, autoUpdate?: boolean}): Comment & {refresh: Function}
|
|
122
|
+
useComment({commentCid: string, community?: CommunityIdentifier, onlyIfCached?: boolean, autoUpdate?: boolean}): Comment & {refresh: Function}
|
|
123
123
|
useReplies({comment: Comment, onlyIfCached?: boolean, sortType?: string, flat?: boolean, repliesPerPage?: number, filter?: CommentsFilter, accountComments?: {newerThan: number, append?: boolean}}): {replies: Comment[], hasMore: boolean, loadMore: function, reset: function, updatedReplies: Comment[], bufferedReplies: Comment[]}
|
|
124
124
|
useComments({commentCids: string[], onlyIfCached?: boolean, autoUpdate?: boolean}): {comments: Comment[], refresh: Function}
|
|
125
125
|
useEditedComment({comment: Comment}): {editedComment: Comment | undefined}
|
|
@@ -256,7 +256,7 @@ await publishComment();
|
|
|
256
256
|
#### Get a post
|
|
257
257
|
|
|
258
258
|
```jsx
|
|
259
|
-
const post = useComment({ commentCid });
|
|
259
|
+
const post = useComment({ commentCid, community: { name: communityAddress, publicKey: communityPublicKey } });
|
|
260
260
|
|
|
261
261
|
// manual refresh is always available
|
|
262
262
|
await post.refresh();
|
|
@@ -290,7 +290,7 @@ if (valid === false) {
|
|
|
290
290
|
#### Get a comment
|
|
291
291
|
|
|
292
292
|
```jsx
|
|
293
|
-
const comment = useComment({ commentCid });
|
|
293
|
+
const comment = useComment({ commentCid, community: { name: communityAddress, publicKey: communityPublicKey } });
|
|
294
294
|
const { comments, refresh } = useComments({ commentCids: [commentCid1, commentCid2, commentCid3] });
|
|
295
295
|
await refresh();
|
|
296
296
|
|
package/dist/hooks/comments.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare function getCommentFreshness(comment: Comment | undefined): numbe
|
|
|
3
3
|
export declare function preferFresher(current: Comment | undefined, candidate: Comment | undefined): Comment | undefined;
|
|
4
4
|
/**
|
|
5
5
|
* @param commentCid - The IPFS CID of the comment to get
|
|
6
|
+
* @param community - The community identifier, e.g. {name: 'memes.eth', publicKey: '12D3KooW...'}.
|
|
6
7
|
* @param acountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, use
|
|
7
8
|
* the active account.
|
|
8
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/hooks/comments.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/hooks/comments.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAalB,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAGxE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,SAAS,EAAE,OAAO,GAAG,SAAS,GAC7B,OAAO,GAAG,SAAS,CAIrB;AA0ED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,CAuMxE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,CA0K3E;AAED,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,wBAAwB,CAmDhG"}
|
package/dist/hooks/comments.js
CHANGED
|
@@ -20,6 +20,7 @@ import { addCommentModeration, addCommentModerationToComments, } from "../lib/ut
|
|
|
20
20
|
import useCommunitiesPagesStore from "../stores/communities-pages/index.js";
|
|
21
21
|
import useRepliesPagesStore from "../stores/replies-pages/index.js";
|
|
22
22
|
import shallow from "zustand/shallow";
|
|
23
|
+
import { assertCommunityRef } from "../lib/community-ref.js";
|
|
23
24
|
export function getCommentFreshness(comment) {
|
|
24
25
|
var _a, _b;
|
|
25
26
|
if (!comment)
|
|
@@ -60,14 +61,47 @@ const getCommentsState = (comments) => comments.every((comment) => getCommentSta
|
|
|
60
61
|
: "fetching-ipfs";
|
|
61
62
|
let commentAutoUpdateSubscriptionCount = 0;
|
|
62
63
|
let commentsAutoUpdateSubscriptionCount = 0;
|
|
64
|
+
const getCommentCreateCommentData = (commentCid, community, ...comments) => {
|
|
65
|
+
if (!commentCid) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const createCommentData = { cid: commentCid };
|
|
69
|
+
let hasCommunityData = false;
|
|
70
|
+
for (const comment of comments) {
|
|
71
|
+
if (!comment) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (!createCommentData.communityPublicKey && comment.communityPublicKey) {
|
|
75
|
+
createCommentData.communityPublicKey = comment.communityPublicKey;
|
|
76
|
+
hasCommunityData = true;
|
|
77
|
+
}
|
|
78
|
+
if (!createCommentData.communityName && comment.communityName) {
|
|
79
|
+
createCommentData.communityName = comment.communityName;
|
|
80
|
+
hasCommunityData = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (community === null || community === void 0 ? void 0 : community.publicKey) {
|
|
84
|
+
createCommentData.communityPublicKey = community.publicKey;
|
|
85
|
+
hasCommunityData = true;
|
|
86
|
+
}
|
|
87
|
+
if (community === null || community === void 0 ? void 0 : community.name) {
|
|
88
|
+
createCommentData.communityName = community.name;
|
|
89
|
+
hasCommunityData = true;
|
|
90
|
+
}
|
|
91
|
+
return hasCommunityData ? createCommentData : undefined;
|
|
92
|
+
};
|
|
63
93
|
/**
|
|
64
94
|
* @param commentCid - The IPFS CID of the comment to get
|
|
95
|
+
* @param community - The community identifier, e.g. {name: 'memes.eth', publicKey: '12D3KooW...'}.
|
|
65
96
|
* @param acountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, use
|
|
66
97
|
* the active account.
|
|
67
98
|
*/
|
|
68
99
|
export function useComment(options) {
|
|
69
100
|
assert(!options || typeof options === "object", `useComment options argument '${options}' not an object`);
|
|
70
|
-
const { commentCid, accountName, onlyIfCached, autoUpdate = true } = options !== null && options !== void 0 ? options : {};
|
|
101
|
+
const { commentCid, community, accountName, onlyIfCached, autoUpdate = true } = options !== null && options !== void 0 ? options : {};
|
|
102
|
+
if (community !== undefined) {
|
|
103
|
+
assertCommunityRef(community, "useComment community");
|
|
104
|
+
}
|
|
71
105
|
const account = useAccount({ accountName });
|
|
72
106
|
const commentFromStore = useCommentsStore((state) => state.comments[commentCid || ""]);
|
|
73
107
|
const addCommentToStore = useCommentsStore((state) => state.addCommentToStore);
|
|
@@ -83,6 +117,15 @@ export function useComment(options) {
|
|
|
83
117
|
var _a;
|
|
84
118
|
return (_a = state.accountsComments[(accountCommentInfo === null || accountCommentInfo === void 0 ? void 0 : accountCommentInfo.accountId) || ""]) === null || _a === void 0 ? void 0 : _a[Number(accountCommentInfo === null || accountCommentInfo === void 0 ? void 0 : accountCommentInfo.accountCommentIndex)];
|
|
85
119
|
});
|
|
120
|
+
const createCommentData = useMemo(() => getCommentCreateCommentData(commentCid, community, communitiesPagesComment, repliesPagesComment), [
|
|
121
|
+
commentCid,
|
|
122
|
+
community === null || community === void 0 ? void 0 : community.name,
|
|
123
|
+
community === null || community === void 0 ? void 0 : community.publicKey,
|
|
124
|
+
communitiesPagesComment === null || communitiesPagesComment === void 0 ? void 0 : communitiesPagesComment.communityName,
|
|
125
|
+
communitiesPagesComment === null || communitiesPagesComment === void 0 ? void 0 : communitiesPagesComment.communityPublicKey,
|
|
126
|
+
repliesPagesComment === null || repliesPagesComment === void 0 ? void 0 : repliesPagesComment.communityName,
|
|
127
|
+
repliesPagesComment === null || repliesPagesComment === void 0 ? void 0 : repliesPagesComment.communityPublicKey,
|
|
128
|
+
]);
|
|
86
129
|
const autoUpdateSubscriptionId = useRef(`useComment-${++commentAutoUpdateSubscriptionCount}`);
|
|
87
130
|
const currentCommentCidRef = useRef(commentCid);
|
|
88
131
|
currentCommentCidRef.current = commentCid;
|
|
@@ -95,18 +138,24 @@ export function useComment(options) {
|
|
|
95
138
|
validator.validateUseCommentArguments(commentCid, account);
|
|
96
139
|
if (!commentFromStore && !onlyIfCached) {
|
|
97
140
|
// if comment isn't already in store, add it
|
|
98
|
-
|
|
141
|
+
const addCommentPromise = createCommentData
|
|
142
|
+
? addCommentToStore(commentCid, account, createCommentData)
|
|
143
|
+
: addCommentToStore(commentCid, account);
|
|
144
|
+
addCommentPromise.catch((error) => log.error("useComment addCommentToStore error", { commentCid, error }));
|
|
99
145
|
}
|
|
100
|
-
}, [commentCid, account === null || account === void 0 ? void 0 : account.id, onlyIfCached]);
|
|
146
|
+
}, [commentCid, account === null || account === void 0 ? void 0 : account.id, onlyIfCached, createCommentData]);
|
|
101
147
|
useEffect(() => {
|
|
102
148
|
if (!commentCid || !account || onlyIfCached || !autoUpdate) {
|
|
103
149
|
return;
|
|
104
150
|
}
|
|
105
|
-
|
|
151
|
+
const startAutoUpdatePromise = createCommentData
|
|
152
|
+
? startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account, createCommentData)
|
|
153
|
+
: startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account);
|
|
154
|
+
startAutoUpdatePromise.catch((error) => log.error("useComment startCommentAutoUpdate error", { commentCid, error }));
|
|
106
155
|
return () => {
|
|
107
156
|
stopCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current).catch((error) => log.error("useComment stopCommentAutoUpdate error", { commentCid, error }));
|
|
108
157
|
};
|
|
109
|
-
}, [commentCid, account === null || account === void 0 ? void 0 : account.id, onlyIfCached, autoUpdate]);
|
|
158
|
+
}, [commentCid, account === null || account === void 0 ? void 0 : account.id, onlyIfCached, autoUpdate, createCommentData]);
|
|
110
159
|
let selectedComment = commentFromStore;
|
|
111
160
|
if (commentCid && communitiesPagesComment) {
|
|
112
161
|
selectedComment = preferFresher(selectedComment, communitiesPagesComment);
|
|
@@ -177,12 +226,14 @@ export function useComment(options) {
|
|
|
177
226
|
throw Error("useComment cannot refresh comment not initialized yet");
|
|
178
227
|
}
|
|
179
228
|
const refreshCommentCid = commentCid;
|
|
180
|
-
const refreshedComment =
|
|
229
|
+
const refreshedComment = createCommentData
|
|
230
|
+
? yield refreshCommentInStore(refreshCommentCid, account, createCommentData)
|
|
231
|
+
: yield refreshCommentInStore(refreshCommentCid, account);
|
|
181
232
|
if (!autoUpdate && refreshedComment && currentCommentCidRef.current === refreshCommentCid) {
|
|
182
233
|
setFrozenComment(refreshedComment);
|
|
183
234
|
setFreezeSettledCid(refreshCommentCid);
|
|
184
235
|
}
|
|
185
|
-
}), [account, autoUpdate, commentCid, refreshCommentInStore]);
|
|
236
|
+
}), [account, autoUpdate, commentCid, createCommentData, refreshCommentInStore]);
|
|
186
237
|
return useMemo(() => (Object.assign(Object.assign({}, comment), { replyCount,
|
|
187
238
|
state,
|
|
188
239
|
refresh, error: errors === null || errors === void 0 ? void 0 : errors[errors.length - 1], errors: errors || [] })), [comment, commentCid, errors, refresh, state, replyCount]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/hooks/comments.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,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,sCAAsC,CAAC,CAAC;AAC3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAU5B,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,wBAAwB,MAAM,6BAA6B,CAAC;AACnE,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,OAAO,MAAM,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W,CAAC;IACtB,CAAC;IACD,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;QACxB,KAAK,GAAG,QAAQ,CAAC;IACnB,CAAC;IAED,kHAAkH;IAClH,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QACvB,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;IACD,uEAAuE;IACvE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;IAED,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,KAAK;QACL,KAAK;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM;KACP,CAAC,EACF,CAAC,KAAK,EAAE,KAAK,CAAC,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAccount } from \"./accounts\";\nimport validator from \"../lib/validator\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:comments:hooks\");\nimport assert from \"assert\";\nimport {\n Comment,\n UseCommentsOptions,\n UseCommentsResult,\n UseCommentOptions,\n UseCommentResult,\n UseValidateCommentOptions,\n UseValidateCommentResult,\n} from \"../types\";\nimport useCommentsStore from \"../stores/comments\";\nimport useAccountsStore from \"../stores/accounts\";\nimport { commentIsValid } from \"../lib/utils\";\nimport {\n addCommentModeration,\n addCommentModerationToComments,\n} from \"../lib/utils/comment-moderation\";\nimport useCommunitiesPagesStore from \"../stores/communities-pages\";\nimport useRepliesPagesStore from \"../stores/replies-pages\";\nimport shallow from \"zustand/shallow\";\n\nexport function getCommentFreshness(comment: Comment | undefined): number {\n if (!comment) return 0;\n return Math.max(comment.updatedAt ?? 0, comment.timestamp ?? 0, 0);\n}\n\nexport function preferFresher(\n current: Comment | undefined,\n candidate: Comment | undefined,\n): Comment | undefined {\n if (!candidate) return current;\n if (!current) return candidate;\n return getCommentFreshness(candidate) > getCommentFreshness(current) ? candidate : current;\n}\n\nconst getCommentStateAndReplyCount = (comment: Comment | undefined) => {\n let state = comment?.updatingState || \"initializing\";\n // force 'fetching-ipns' even if could be something else, so the frontend can use\n // the correct loading skeleton\n if (comment?.timestamp) {\n state = \"fetching-update-ipns\";\n }\n // force succeeded even if the comment is fecthing a new update\n if (comment?.updatedAt) {\n state = \"succeeded\";\n }\n\n // force succeeded if the comment is newer than 5 minutes, no need to display loading skeleton if comment was just created\n let replyCount = comment?.replyCount;\n if (\n comment?.replyCount === undefined &&\n comment?.timestamp &&\n comment?.timestamp > Date.now() / 1000 - 5 * 60\n ) {\n state = \"succeeded\";\n // set replyCount because some frontend are likely to check if replyCount === undefined to show a loading skeleton\n replyCount = 0;\n }\n\n return { state, replyCount };\n};\n\nconst getCommentsState = (comments: (Comment | undefined)[]) =>\n comments.every((comment) => getCommentStateAndReplyCount(comment).state === \"succeeded\")\n ? \"succeeded\"\n : \"fetching-ipfs\";\n\nlet commentAutoUpdateSubscriptionCount = 0;\nlet commentsAutoUpdateSubscriptionCount = 0;\n\n/**\n * @param commentCid - The IPFS CID of the comment to get\n * @param acountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, use\n * the active account.\n */\nexport function useComment(options?: UseCommentOptions): UseCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useComment options argument '${options}' not an object`,\n );\n const { commentCid, accountName, onlyIfCached, autoUpdate = true } = options ?? {};\n const account = useAccount({ accountName });\n const commentFromStore = useCommentsStore((state: any) => state.comments[commentCid || \"\"]);\n const addCommentToStore = useCommentsStore((state: any) => state.addCommentToStore);\n const startCommentAutoUpdate = useCommentsStore((state: any) => state.startCommentAutoUpdate);\n const stopCommentAutoUpdate = useCommentsStore((state: any) => state.stopCommentAutoUpdate);\n const refreshCommentInStore = useCommentsStore((state: any) => state.refreshComment);\n const communitiesPagesComment = useCommunitiesPagesStore(\n (state: any) => state.comments[commentCid || \"\"],\n );\n const repliesPagesComment = useRepliesPagesStore(\n (state: any) => state.comments[commentCid || \"\"],\n );\n const errors = useCommentsStore((state: any) => state.errors[commentCid || \"\"]);\n\n // get account comment of the cid if any\n const accountCommentInfo = useAccountsStore(\n (state: any) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const accountComment = useAccountsStore(\n (state: any) =>\n state.accountsComments[accountCommentInfo?.accountId || \"\"]?.[\n Number(accountCommentInfo?.accountCommentIndex)\n ],\n );\n const autoUpdateSubscriptionId = useRef(`useComment-${++commentAutoUpdateSubscriptionCount}`);\n const currentCommentCidRef = useRef<string | undefined>(commentCid);\n currentCommentCidRef.current = commentCid;\n const [frozenComment, setFrozenComment] = useState<Comment | undefined>();\n const [freezeSettledCid, setFreezeSettledCid] = useState<string>();\n\n useEffect(() => {\n if (!commentCid || !account) {\n return;\n }\n validator.validateUseCommentArguments(commentCid, account);\n if (!commentFromStore && !onlyIfCached) {\n // if comment isn't already in store, add it\n addCommentToStore(commentCid, account).catch((error: unknown) =>\n log.error(\"useComment addCommentToStore error\", { commentCid, error }),\n );\n }\n }, [commentCid, account?.id, onlyIfCached]);\n\n useEffect(() => {\n if (!commentCid || !account || onlyIfCached || !autoUpdate) {\n return;\n }\n\n startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account).catch(\n (error: unknown) =>\n log.error(\"useComment startCommentAutoUpdate error\", { commentCid, error }),\n );\n\n return () => {\n stopCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current).catch((error: unknown) =>\n log.error(\"useComment stopCommentAutoUpdate error\", { commentCid, error }),\n );\n };\n }, [commentCid, account?.id, onlyIfCached, autoUpdate]);\n\n let selectedComment = commentFromStore;\n\n if (commentCid && communitiesPagesComment) {\n selectedComment = preferFresher(selectedComment, communitiesPagesComment);\n }\n if (commentCid && repliesPagesComment) {\n selectedComment = preferFresher(selectedComment, repliesPagesComment);\n }\n\n // if comment is still not defined, but account comment is, use account comment\n // check `comment.timestamp` instead of `comment` in case comment exists but in a loading state\n const commentFromStoreNotLoaded = !selectedComment?.timestamp;\n if (commentCid && commentFromStoreNotLoaded && accountComment) {\n selectedComment = accountComment;\n }\n\n const selectedCommentState = getCommentStateAndReplyCount(selectedComment).state;\n const freezeSettledForCurrentCid = freezeSettledCid === commentCid;\n\n useEffect(() => {\n if (autoUpdate) {\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n return;\n }\n\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n }, [commentCid, autoUpdate]);\n\n useEffect(() => {\n if (autoUpdate) {\n return;\n }\n if (!commentCid) {\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n return;\n }\n if (freezeSettledForCurrentCid || !selectedComment) {\n return;\n }\n\n setFrozenComment(selectedComment);\n if (selectedCommentState === \"succeeded\") {\n setFreezeSettledCid(commentCid);\n }\n }, [autoUpdate, commentCid, selectedComment, selectedCommentState, freezeSettledForCurrentCid]);\n\n const frozenCommentForCurrentCid = frozenComment?.cid === commentCid ? frozenComment : undefined;\n let comment = autoUpdate\n ? selectedComment\n : freezeSettledForCurrentCid\n ? frozenCommentForCurrentCid\n : frozenCommentForCurrentCid || selectedComment;\n comment = addCommentModeration(comment);\n\n const { state, replyCount } = getCommentStateAndReplyCount(comment);\n\n if (account && commentCid) {\n log(\"useComment\", {\n commentCid,\n comment,\n replyCount,\n state,\n commentFromStore,\n communitiesPagesComment,\n repliesPagesComment,\n accountComment,\n commentsStore: useCommentsStore.getState().comments,\n account,\n onlyIfCached,\n autoUpdate,\n });\n }\n\n const refresh = useCallback(async () => {\n if (!commentCid || !account) {\n throw Error(\"useComment cannot refresh comment not initialized yet\");\n }\n\n const refreshCommentCid = commentCid;\n const refreshedComment = await refreshCommentInStore(refreshCommentCid, account);\n if (!autoUpdate && refreshedComment && currentCommentCidRef.current === refreshCommentCid) {\n setFrozenComment(refreshedComment);\n setFreezeSettledCid(refreshCommentCid);\n }\n }, [account, autoUpdate, commentCid, refreshCommentInStore]);\n\n return useMemo(\n () => ({\n ...comment,\n replyCount,\n state,\n refresh,\n error: errors?.[errors.length - 1],\n errors: errors || [],\n }),\n [comment, commentCid, errors, refresh, state, replyCount],\n );\n}\n\n/**\n * @param commentCids - The IPFS CIDs of the comments to get\n * @param acountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, use\n * the active account.\n */\nexport function useComments(options?: UseCommentsOptions): UseCommentsResult {\n assert(\n !options || typeof options === \"object\",\n `useComments options argument '${options}' not an object`,\n );\n const { commentCids = [], accountName, onlyIfCached, autoUpdate = true } = options ?? {};\n const account = useAccount({ accountName });\n const commentsStoreComments: (Comment | undefined)[] = useCommentsStore(\n (state: any) => commentCids.map((commentCid) => state.comments[commentCid || \"\"]),\n shallow,\n );\n const communitiesPagesComments: (Comment | undefined)[] = useCommunitiesPagesStore(\n (state: any) => commentCids.map((commentCid) => state.comments[commentCid || \"\"]),\n shallow,\n );\n\n const addCommentToStore = useCommentsStore((state: any) => state.addCommentToStore);\n const startCommentAutoUpdate = useCommentsStore((state: any) => state.startCommentAutoUpdate);\n const stopCommentAutoUpdate = useCommentsStore((state: any) => state.stopCommentAutoUpdate);\n const refreshCommentInStore = useCommentsStore((state: any) => state.refreshComment);\n const autoUpdateSubscriptionId = useRef(`useComments-${++commentsAutoUpdateSubscriptionCount}`);\n const commentCidsKey = JSON.stringify(commentCids);\n const commentsKey = `${account?.id || \"\"}:${commentCidsKey}`;\n const currentCommentsKeyRef = useRef(commentsKey);\n currentCommentsKeyRef.current = commentsKey;\n const [frozenComments, setFrozenComments] = useState<(Comment | undefined)[]>([]);\n const [frozenCommentsKey, setFrozenCommentsKey] = useState<string>();\n const [freezeSettledKey, setFreezeSettledKey] = useState<string>();\n\n useEffect(() => {\n if (!commentCids || !account) {\n return;\n }\n validator.validateUseCommentsArguments(commentCids, account);\n if (onlyIfCached) {\n return;\n }\n const uniqueCommentCids = new Set(commentCids);\n for (const commentCid of uniqueCommentCids) {\n addCommentToStore(commentCid, account).catch((error: unknown) =>\n log.error(\"useComments addCommentToStore error\", { commentCid, error }),\n );\n }\n }, [commentCidsKey, account?.id, onlyIfCached]);\n\n useEffect(() => {\n if (!commentCids || !account || onlyIfCached || !autoUpdate) {\n return;\n }\n\n const uniqueCommentCids = [...new Set(commentCids)];\n for (const commentCid of uniqueCommentCids) {\n startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account).catch(\n (error: unknown) =>\n log.error(\"useComments startCommentAutoUpdate error\", { commentCid, error }),\n );\n }\n\n return () => {\n for (const commentCid of uniqueCommentCids) {\n stopCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current).catch(\n (error: unknown) =>\n log.error(\"useComments stopCommentAutoUpdate error\", { commentCid, error }),\n );\n }\n };\n }, [commentCidsKey, account?.id, onlyIfCached, autoUpdate]);\n\n if (account && commentCids?.length) {\n log(\"useComments\", {\n commentCids,\n commentsStoreComments,\n commentsStore: useCommentsStore.getState().comments,\n account,\n });\n }\n\n // if comment from community pages exists and is fresher (or current missing), use it instead\n const liveComments = useMemo(() => {\n const result = [...commentsStoreComments];\n for (const i in result) {\n const candidate = communitiesPagesComments[i];\n if (candidate) result[i] = preferFresher(result[i], candidate);\n }\n return result;\n }, [commentsStoreComments, communitiesPagesComments]);\n\n const liveCommentsSettled = liveComments.every(\n (comment) => getCommentStateAndReplyCount(comment).state === \"succeeded\",\n );\n const freezeSettledForCurrentKey = freezeSettledKey === commentsKey;\n\n useEffect(() => {\n if (autoUpdate) {\n setFrozenComments([]);\n setFrozenCommentsKey(undefined);\n setFreezeSettledKey(undefined);\n return;\n }\n\n setFrozenComments([]);\n setFrozenCommentsKey(undefined);\n setFreezeSettledKey(undefined);\n }, [commentsKey, autoUpdate]);\n\n useEffect(() => {\n if (autoUpdate || freezeSettledForCurrentKey) {\n return;\n }\n\n setFrozenComments(liveComments);\n setFrozenCommentsKey(commentsKey);\n if (liveCommentsSettled) {\n setFreezeSettledKey(commentsKey);\n }\n }, [autoUpdate, commentsKey, freezeSettledForCurrentKey, liveComments, liveCommentsSettled]);\n\n const frozenCommentsForCurrentSelection =\n frozenCommentsKey === commentsKey ? frozenComments : undefined;\n const comments = autoUpdate ? liveComments : frozenCommentsForCurrentSelection || liveComments;\n const normalizedComments = useMemo(() => addCommentModerationToComments(comments), [comments]);\n\n // succeed if no comments are undefined\n const state = getCommentsState(normalizedComments);\n\n const refresh = useCallback(async () => {\n if (!account) {\n throw Error(\"useComments cannot refresh comments not initialized yet\");\n }\n const uniqueCommentCids = [...new Set(commentCids)];\n const refreshedComments = await Promise.all(\n uniqueCommentCids.map((commentCid) => refreshCommentInStore(commentCid, account)),\n );\n\n if (!autoUpdate && currentCommentsKeyRef.current === commentsKey) {\n const latestCommunitiesPagesComments = useCommunitiesPagesStore.getState().comments;\n const refreshedCommentsByCid = uniqueCommentCids.reduce(\n (\n refreshedCommentsMap: { [commentCid: string]: Comment | undefined },\n commentCid,\n index,\n ) => {\n refreshedCommentsMap[commentCid] = refreshedComments[index];\n return refreshedCommentsMap;\n },\n {},\n );\n setFrozenComments(\n commentCids.map((commentCid) =>\n preferFresher(\n refreshedCommentsByCid[commentCid || \"\"],\n latestCommunitiesPagesComments[commentCid || \"\"],\n ),\n ),\n );\n setFrozenCommentsKey(commentsKey);\n setFreezeSettledKey(commentsKey);\n }\n }, [account, autoUpdate, commentCids, commentsKey, refreshCommentInStore]);\n\n return useMemo(\n () => ({\n comments: normalizedComments,\n state,\n refresh,\n error: undefined,\n errors: [],\n }),\n [normalizedComments, commentsKey, refresh, state],\n );\n}\n\nexport function useValidateComment(options?: UseValidateCommentOptions): UseValidateCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useValidateComment options argument '${options}' not an object`,\n );\n let { comment, validateReplies, accountName } = options ?? {};\n validateReplies = validateReplies ?? true;\n const [validated, setValidated] = useState<boolean | undefined>();\n const [errors] = useState([]);\n const account = useAccount({ accountName });\n\n useEffect(() => {\n if (!comment || !account?.pkc) {\n setValidated(undefined);\n return;\n }\n // don't automatically block community because what community it comes from\n // a malicious community could try to block other communities, etc\n const blockCommunity = false;\n commentIsValid(comment, { validateReplies, blockCommunity }, account.pkc).then((validated) =>\n setValidated(validated),\n );\n }, [comment, validateReplies, account?.pkc]);\n\n let state = \"initializing\";\n if (validated === true) {\n state = \"succeeded\";\n }\n if (validated === false) {\n state = \"failed\";\n }\n\n // start valid at true always because most of the time the value will be true and we dont want to cause a rerender\n let valid = true;\n if (validated == false) {\n valid = false;\n }\n // if comment isn't defined, it would be confusing for valid to be true\n if (!comment) {\n valid = false;\n }\n\n return useMemo(\n () => ({\n valid,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [valid, state],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/hooks/comments.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,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,sCAAsC,CAAC,CAAC;AAC3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAU5B,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,wBAAwB,MAAM,6BAA6B,CAAC;AACnE,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,mBAAmB,CAAC,OAA4B;;IAC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E,CAAC;QACb,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;IAED,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,KAAK;QACL,KAAK;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM;KACP,CAAC,EACF,CAAC,KAAK,EAAE,KAAK,CAAC,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAccount } from \"./accounts\";\nimport validator from \"../lib/validator\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:comments:hooks\");\nimport assert from \"assert\";\nimport {\n Comment,\n UseCommentsOptions,\n UseCommentsResult,\n UseCommentOptions,\n UseCommentResult,\n UseValidateCommentOptions,\n UseValidateCommentResult,\n} from \"../types\";\nimport useCommentsStore from \"../stores/comments\";\nimport useAccountsStore from \"../stores/accounts\";\nimport { commentIsValid } from \"../lib/utils\";\nimport {\n addCommentModeration,\n addCommentModerationToComments,\n} from \"../lib/utils/comment-moderation\";\nimport useCommunitiesPagesStore from \"../stores/communities-pages\";\nimport useRepliesPagesStore from \"../stores/replies-pages\";\nimport shallow from \"zustand/shallow\";\nimport { assertCommunityRef } from \"../lib/community-ref\";\n\nexport function getCommentFreshness(comment: Comment | undefined): number {\n if (!comment) return 0;\n return Math.max(comment.updatedAt ?? 0, comment.timestamp ?? 0, 0);\n}\n\nexport function preferFresher(\n current: Comment | undefined,\n candidate: Comment | undefined,\n): Comment | undefined {\n if (!candidate) return current;\n if (!current) return candidate;\n return getCommentFreshness(candidate) > getCommentFreshness(current) ? candidate : current;\n}\n\nconst getCommentStateAndReplyCount = (comment: Comment | undefined) => {\n let state = comment?.updatingState || \"initializing\";\n // force 'fetching-ipns' even if could be something else, so the frontend can use\n // the correct loading skeleton\n if (comment?.timestamp) {\n state = \"fetching-update-ipns\";\n }\n // force succeeded even if the comment is fecthing a new update\n if (comment?.updatedAt) {\n state = \"succeeded\";\n }\n\n // force succeeded if the comment is newer than 5 minutes, no need to display loading skeleton if comment was just created\n let replyCount = comment?.replyCount;\n if (\n comment?.replyCount === undefined &&\n comment?.timestamp &&\n comment?.timestamp > Date.now() / 1000 - 5 * 60\n ) {\n state = \"succeeded\";\n // set replyCount because some frontend are likely to check if replyCount === undefined to show a loading skeleton\n replyCount = 0;\n }\n\n return { state, replyCount };\n};\n\nconst getCommentsState = (comments: (Comment | undefined)[]) =>\n comments.every((comment) => getCommentStateAndReplyCount(comment).state === \"succeeded\")\n ? \"succeeded\"\n : \"fetching-ipfs\";\n\nlet commentAutoUpdateSubscriptionCount = 0;\nlet commentsAutoUpdateSubscriptionCount = 0;\n\nconst getCommentCreateCommentData = (\n commentCid: string | undefined,\n community: UseCommentOptions[\"community\"] | undefined,\n ...comments: (Comment | undefined)[]\n) => {\n if (!commentCid) {\n return undefined;\n }\n\n const createCommentData: Comment = { cid: commentCid };\n let hasCommunityData = false;\n for (const comment of comments) {\n if (!comment) {\n continue;\n }\n if (!createCommentData.communityPublicKey && comment.communityPublicKey) {\n createCommentData.communityPublicKey = comment.communityPublicKey;\n hasCommunityData = true;\n }\n if (!createCommentData.communityName && comment.communityName) {\n createCommentData.communityName = comment.communityName;\n hasCommunityData = true;\n }\n }\n\n if (community?.publicKey) {\n createCommentData.communityPublicKey = community.publicKey;\n hasCommunityData = true;\n }\n if (community?.name) {\n createCommentData.communityName = community.name;\n hasCommunityData = true;\n }\n\n return hasCommunityData ? createCommentData : undefined;\n};\n\n/**\n * @param commentCid - The IPFS CID of the comment to get\n * @param community - The community identifier, e.g. {name: 'memes.eth', publicKey: '12D3KooW...'}.\n * @param acountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, use\n * the active account.\n */\nexport function useComment(options?: UseCommentOptions): UseCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useComment options argument '${options}' not an object`,\n );\n const { commentCid, community, accountName, onlyIfCached, autoUpdate = true } = options ?? {};\n if (community !== undefined) {\n assertCommunityRef(community, \"useComment community\");\n }\n const account = useAccount({ accountName });\n const commentFromStore = useCommentsStore((state: any) => state.comments[commentCid || \"\"]);\n const addCommentToStore = useCommentsStore((state: any) => state.addCommentToStore);\n const startCommentAutoUpdate = useCommentsStore((state: any) => state.startCommentAutoUpdate);\n const stopCommentAutoUpdate = useCommentsStore((state: any) => state.stopCommentAutoUpdate);\n const refreshCommentInStore = useCommentsStore((state: any) => state.refreshComment);\n const communitiesPagesComment = useCommunitiesPagesStore(\n (state: any) => state.comments[commentCid || \"\"],\n );\n const repliesPagesComment = useRepliesPagesStore(\n (state: any) => state.comments[commentCid || \"\"],\n );\n const errors = useCommentsStore((state: any) => state.errors[commentCid || \"\"]);\n\n // get account comment of the cid if any\n const accountCommentInfo = useAccountsStore(\n (state: any) => state.commentCidsToAccountsComments[commentCid || \"\"],\n );\n const accountComment = useAccountsStore(\n (state: any) =>\n state.accountsComments[accountCommentInfo?.accountId || \"\"]?.[\n Number(accountCommentInfo?.accountCommentIndex)\n ],\n );\n const createCommentData = useMemo(\n () =>\n getCommentCreateCommentData(\n commentCid,\n community,\n communitiesPagesComment,\n repliesPagesComment,\n ),\n [\n commentCid,\n community?.name,\n community?.publicKey,\n communitiesPagesComment?.communityName,\n communitiesPagesComment?.communityPublicKey,\n repliesPagesComment?.communityName,\n repliesPagesComment?.communityPublicKey,\n ],\n );\n const autoUpdateSubscriptionId = useRef(`useComment-${++commentAutoUpdateSubscriptionCount}`);\n const currentCommentCidRef = useRef<string | undefined>(commentCid);\n currentCommentCidRef.current = commentCid;\n const [frozenComment, setFrozenComment] = useState<Comment | undefined>();\n const [freezeSettledCid, setFreezeSettledCid] = useState<string>();\n\n useEffect(() => {\n if (!commentCid || !account) {\n return;\n }\n validator.validateUseCommentArguments(commentCid, account);\n if (!commentFromStore && !onlyIfCached) {\n // if comment isn't already in store, add it\n const addCommentPromise = createCommentData\n ? addCommentToStore(commentCid, account, createCommentData)\n : addCommentToStore(commentCid, account);\n addCommentPromise.catch((error: unknown) =>\n log.error(\"useComment addCommentToStore error\", { commentCid, error }),\n );\n }\n }, [commentCid, account?.id, onlyIfCached, createCommentData]);\n\n useEffect(() => {\n if (!commentCid || !account || onlyIfCached || !autoUpdate) {\n return;\n }\n\n const startAutoUpdatePromise = createCommentData\n ? startCommentAutoUpdate(\n commentCid,\n autoUpdateSubscriptionId.current,\n account,\n createCommentData,\n )\n : startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account);\n startAutoUpdatePromise.catch((error: unknown) =>\n log.error(\"useComment startCommentAutoUpdate error\", { commentCid, error }),\n );\n\n return () => {\n stopCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current).catch((error: unknown) =>\n log.error(\"useComment stopCommentAutoUpdate error\", { commentCid, error }),\n );\n };\n }, [commentCid, account?.id, onlyIfCached, autoUpdate, createCommentData]);\n\n let selectedComment = commentFromStore;\n\n if (commentCid && communitiesPagesComment) {\n selectedComment = preferFresher(selectedComment, communitiesPagesComment);\n }\n if (commentCid && repliesPagesComment) {\n selectedComment = preferFresher(selectedComment, repliesPagesComment);\n }\n\n // if comment is still not defined, but account comment is, use account comment\n // check `comment.timestamp` instead of `comment` in case comment exists but in a loading state\n const commentFromStoreNotLoaded = !selectedComment?.timestamp;\n if (commentCid && commentFromStoreNotLoaded && accountComment) {\n selectedComment = accountComment;\n }\n\n const selectedCommentState = getCommentStateAndReplyCount(selectedComment).state;\n const freezeSettledForCurrentCid = freezeSettledCid === commentCid;\n\n useEffect(() => {\n if (autoUpdate) {\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n return;\n }\n\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n }, [commentCid, autoUpdate]);\n\n useEffect(() => {\n if (autoUpdate) {\n return;\n }\n if (!commentCid) {\n setFrozenComment(undefined);\n setFreezeSettledCid(undefined);\n return;\n }\n if (freezeSettledForCurrentCid || !selectedComment) {\n return;\n }\n\n setFrozenComment(selectedComment);\n if (selectedCommentState === \"succeeded\") {\n setFreezeSettledCid(commentCid);\n }\n }, [autoUpdate, commentCid, selectedComment, selectedCommentState, freezeSettledForCurrentCid]);\n\n const frozenCommentForCurrentCid = frozenComment?.cid === commentCid ? frozenComment : undefined;\n let comment = autoUpdate\n ? selectedComment\n : freezeSettledForCurrentCid\n ? frozenCommentForCurrentCid\n : frozenCommentForCurrentCid || selectedComment;\n comment = addCommentModeration(comment);\n\n const { state, replyCount } = getCommentStateAndReplyCount(comment);\n\n if (account && commentCid) {\n log(\"useComment\", {\n commentCid,\n comment,\n replyCount,\n state,\n commentFromStore,\n communitiesPagesComment,\n repliesPagesComment,\n accountComment,\n commentsStore: useCommentsStore.getState().comments,\n account,\n onlyIfCached,\n autoUpdate,\n });\n }\n\n const refresh = useCallback(async () => {\n if (!commentCid || !account) {\n throw Error(\"useComment cannot refresh comment not initialized yet\");\n }\n\n const refreshCommentCid = commentCid;\n const refreshedComment = createCommentData\n ? await refreshCommentInStore(refreshCommentCid, account, createCommentData)\n : await refreshCommentInStore(refreshCommentCid, account);\n if (!autoUpdate && refreshedComment && currentCommentCidRef.current === refreshCommentCid) {\n setFrozenComment(refreshedComment);\n setFreezeSettledCid(refreshCommentCid);\n }\n }, [account, autoUpdate, commentCid, createCommentData, refreshCommentInStore]);\n\n return useMemo(\n () => ({\n ...comment,\n replyCount,\n state,\n refresh,\n error: errors?.[errors.length - 1],\n errors: errors || [],\n }),\n [comment, commentCid, errors, refresh, state, replyCount],\n );\n}\n\n/**\n * @param commentCids - The IPFS CIDs of the comments to get\n * @param acountName - The nickname of the account, e.g. 'Account 1'. If no accountName is provided, use\n * the active account.\n */\nexport function useComments(options?: UseCommentsOptions): UseCommentsResult {\n assert(\n !options || typeof options === \"object\",\n `useComments options argument '${options}' not an object`,\n );\n const { commentCids = [], accountName, onlyIfCached, autoUpdate = true } = options ?? {};\n const account = useAccount({ accountName });\n const commentsStoreComments: (Comment | undefined)[] = useCommentsStore(\n (state: any) => commentCids.map((commentCid) => state.comments[commentCid || \"\"]),\n shallow,\n );\n const communitiesPagesComments: (Comment | undefined)[] = useCommunitiesPagesStore(\n (state: any) => commentCids.map((commentCid) => state.comments[commentCid || \"\"]),\n shallow,\n );\n\n const addCommentToStore = useCommentsStore((state: any) => state.addCommentToStore);\n const startCommentAutoUpdate = useCommentsStore((state: any) => state.startCommentAutoUpdate);\n const stopCommentAutoUpdate = useCommentsStore((state: any) => state.stopCommentAutoUpdate);\n const refreshCommentInStore = useCommentsStore((state: any) => state.refreshComment);\n const autoUpdateSubscriptionId = useRef(`useComments-${++commentsAutoUpdateSubscriptionCount}`);\n const commentCidsKey = JSON.stringify(commentCids);\n const commentsKey = `${account?.id || \"\"}:${commentCidsKey}`;\n const currentCommentsKeyRef = useRef(commentsKey);\n currentCommentsKeyRef.current = commentsKey;\n const [frozenComments, setFrozenComments] = useState<(Comment | undefined)[]>([]);\n const [frozenCommentsKey, setFrozenCommentsKey] = useState<string>();\n const [freezeSettledKey, setFreezeSettledKey] = useState<string>();\n\n useEffect(() => {\n if (!commentCids || !account) {\n return;\n }\n validator.validateUseCommentsArguments(commentCids, account);\n if (onlyIfCached) {\n return;\n }\n const uniqueCommentCids = new Set(commentCids);\n for (const commentCid of uniqueCommentCids) {\n addCommentToStore(commentCid, account).catch((error: unknown) =>\n log.error(\"useComments addCommentToStore error\", { commentCid, error }),\n );\n }\n }, [commentCidsKey, account?.id, onlyIfCached]);\n\n useEffect(() => {\n if (!commentCids || !account || onlyIfCached || !autoUpdate) {\n return;\n }\n\n const uniqueCommentCids = [...new Set(commentCids)];\n for (const commentCid of uniqueCommentCids) {\n startCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current, account).catch(\n (error: unknown) =>\n log.error(\"useComments startCommentAutoUpdate error\", { commentCid, error }),\n );\n }\n\n return () => {\n for (const commentCid of uniqueCommentCids) {\n stopCommentAutoUpdate(commentCid, autoUpdateSubscriptionId.current).catch(\n (error: unknown) =>\n log.error(\"useComments stopCommentAutoUpdate error\", { commentCid, error }),\n );\n }\n };\n }, [commentCidsKey, account?.id, onlyIfCached, autoUpdate]);\n\n if (account && commentCids?.length) {\n log(\"useComments\", {\n commentCids,\n commentsStoreComments,\n commentsStore: useCommentsStore.getState().comments,\n account,\n });\n }\n\n // if comment from community pages exists and is fresher (or current missing), use it instead\n const liveComments = useMemo(() => {\n const result = [...commentsStoreComments];\n for (const i in result) {\n const candidate = communitiesPagesComments[i];\n if (candidate) result[i] = preferFresher(result[i], candidate);\n }\n return result;\n }, [commentsStoreComments, communitiesPagesComments]);\n\n const liveCommentsSettled = liveComments.every(\n (comment) => getCommentStateAndReplyCount(comment).state === \"succeeded\",\n );\n const freezeSettledForCurrentKey = freezeSettledKey === commentsKey;\n\n useEffect(() => {\n if (autoUpdate) {\n setFrozenComments([]);\n setFrozenCommentsKey(undefined);\n setFreezeSettledKey(undefined);\n return;\n }\n\n setFrozenComments([]);\n setFrozenCommentsKey(undefined);\n setFreezeSettledKey(undefined);\n }, [commentsKey, autoUpdate]);\n\n useEffect(() => {\n if (autoUpdate || freezeSettledForCurrentKey) {\n return;\n }\n\n setFrozenComments(liveComments);\n setFrozenCommentsKey(commentsKey);\n if (liveCommentsSettled) {\n setFreezeSettledKey(commentsKey);\n }\n }, [autoUpdate, commentsKey, freezeSettledForCurrentKey, liveComments, liveCommentsSettled]);\n\n const frozenCommentsForCurrentSelection =\n frozenCommentsKey === commentsKey ? frozenComments : undefined;\n const comments = autoUpdate ? liveComments : frozenCommentsForCurrentSelection || liveComments;\n const normalizedComments = useMemo(() => addCommentModerationToComments(comments), [comments]);\n\n // succeed if no comments are undefined\n const state = getCommentsState(normalizedComments);\n\n const refresh = useCallback(async () => {\n if (!account) {\n throw Error(\"useComments cannot refresh comments not initialized yet\");\n }\n const uniqueCommentCids = [...new Set(commentCids)];\n const refreshedComments = await Promise.all(\n uniqueCommentCids.map((commentCid) => refreshCommentInStore(commentCid, account)),\n );\n\n if (!autoUpdate && currentCommentsKeyRef.current === commentsKey) {\n const latestCommunitiesPagesComments = useCommunitiesPagesStore.getState().comments;\n const refreshedCommentsByCid = uniqueCommentCids.reduce(\n (\n refreshedCommentsMap: { [commentCid: string]: Comment | undefined },\n commentCid,\n index,\n ) => {\n refreshedCommentsMap[commentCid] = refreshedComments[index];\n return refreshedCommentsMap;\n },\n {},\n );\n setFrozenComments(\n commentCids.map((commentCid) =>\n preferFresher(\n refreshedCommentsByCid[commentCid || \"\"],\n latestCommunitiesPagesComments[commentCid || \"\"],\n ),\n ),\n );\n setFrozenCommentsKey(commentsKey);\n setFreezeSettledKey(commentsKey);\n }\n }, [account, autoUpdate, commentCids, commentsKey, refreshCommentInStore]);\n\n return useMemo(\n () => ({\n comments: normalizedComments,\n state,\n refresh,\n error: undefined,\n errors: [],\n }),\n [normalizedComments, commentsKey, refresh, state],\n );\n}\n\nexport function useValidateComment(options?: UseValidateCommentOptions): UseValidateCommentResult {\n assert(\n !options || typeof options === \"object\",\n `useValidateComment options argument '${options}' not an object`,\n );\n let { comment, validateReplies, accountName } = options ?? {};\n validateReplies = validateReplies ?? true;\n const [validated, setValidated] = useState<boolean | undefined>();\n const [errors] = useState([]);\n const account = useAccount({ accountName });\n\n useEffect(() => {\n if (!comment || !account?.pkc) {\n setValidated(undefined);\n return;\n }\n // don't automatically block community because what community it comes from\n // a malicious community could try to block other communities, etc\n const blockCommunity = false;\n commentIsValid(comment, { validateReplies, blockCommunity }, account.pkc).then((validated) =>\n setValidated(validated),\n );\n }, [comment, validateReplies, account?.pkc]);\n\n let state = \"initializing\";\n if (validated === true) {\n state = \"succeeded\";\n }\n if (validated === false) {\n state = \"failed\";\n }\n\n // start valid at true always because most of the time the value will be true and we dont want to cause a rerender\n let valid = true;\n if (validated == false) {\n valid = false;\n }\n // if comment isn't defined, it would be confusing for valid to be true\n if (!comment) {\n valid = false;\n }\n\n return useMemo(\n () => ({\n valid,\n state,\n error: errors[errors.length - 1],\n errors,\n }),\n [valid, state],\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments-store.d.ts","sourceRoot":"","sources":["../../../src/stores/comments/comments-store.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,eAAO,MAAM,GAAG,QAAkD,CAAC;AACnE,OAAO,EAAW,QAAQ,EAAW,MAAM,aAAa,CAAC;AAkBzD,eAAO,MAAM,SAAS,EAAE,GAAQ,CAAC;AAEjC,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,EAAE,CAAA;KAAE,CAAC;IAC1C,iBAAiB,EAAE,QAAQ,CAAC;IAC5B,sBAAsB,EAAE,QAAQ,CAAC;IACjC,qBAAqB,EAAE,QAAQ,CAAC;IAChC,cAAc,EAAE,QAAQ,CAAC;CAC1B,CAAC;
|
|
1
|
+
{"version":3,"file":"comments-store.d.ts","sourceRoot":"","sources":["../../../src/stores/comments/comments-store.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,eAAO,MAAM,GAAG,QAAkD,CAAC;AACnE,OAAO,EAAW,QAAQ,EAAW,MAAM,aAAa,CAAC;AAkBzD,eAAO,MAAM,SAAS,EAAE,GAAQ,CAAC;AAEjC,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,EAAE,CAAA;KAAE,CAAC;IAC1C,iBAAiB,EAAE,QAAQ,CAAC;IAC5B,sBAAsB,EAAE,QAAQ,CAAC;IACjC,qBAAqB,EAAE,QAAQ,CAAC;IAChC,cAAc,EAAE,QAAQ,CAAC;CAC1B,CAAC;AAuDF,QAAA,MAAM,aAAa,4EA2UjB,CAAC;AA8BH,eAAO,MAAM,kBAAkB,qBAgC9B,CAAC;AAGF,eAAO,MAAM,6BAA6B,qBAGzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -39,6 +39,16 @@ const removeCommentListener = (comment, event, listener) => {
|
|
|
39
39
|
};
|
|
40
40
|
const getCommentAutoUpdateSubscribersCount = (commentCid) => Object.keys(commentAutoUpdateSubscribers[commentCid] || {}).length;
|
|
41
41
|
const hasCommentAutoUpdateSubscribers = (commentCid) => getCommentAutoUpdateSubscribersCount(commentCid) > 0;
|
|
42
|
+
const mergeCommentData = (commentCid, ...commentDataList) => {
|
|
43
|
+
const mergedCommentData = { cid: commentCid };
|
|
44
|
+
for (const commentData of commentDataList) {
|
|
45
|
+
if (commentData && typeof commentData === "object") {
|
|
46
|
+
Object.assign(mergedCommentData, utils.clone(commentData));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
mergedCommentData.cid = commentCid;
|
|
50
|
+
return mergedCommentData;
|
|
51
|
+
};
|
|
42
52
|
const releaseLiveComment = (commentCid, comment) => {
|
|
43
53
|
const liveComment = comment || liveComments[commentCid];
|
|
44
54
|
if (liveComment) {
|
|
@@ -172,8 +182,7 @@ const commentsStore = createStore((setState, getState) => {
|
|
|
172
182
|
return liveCommentPromises[commentCid];
|
|
173
183
|
}
|
|
174
184
|
const liveCommentPromise = (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
175
|
-
const initialComment = normalizeCommentCommunityAddress(
|
|
176
|
-
{ cid: commentCid };
|
|
185
|
+
const initialComment = normalizeCommentCommunityAddress(mergeCommentData(commentCid, commentData));
|
|
177
186
|
const liveComment = normalizeCommentCommunityAddress(yield account.pkc.createComment(initialComment));
|
|
178
187
|
initializeComment(commentCid, liveComment, account);
|
|
179
188
|
return liveComment;
|
|
@@ -226,7 +235,7 @@ const commentsStore = createStore((setState, getState) => {
|
|
|
226
235
|
return {
|
|
227
236
|
comments: {},
|
|
228
237
|
errors: {},
|
|
229
|
-
addCommentToStore(commentCid, account) {
|
|
238
|
+
addCommentToStore(commentCid, account, commentData) {
|
|
230
239
|
return __awaiter(this, void 0, void 0, function* () {
|
|
231
240
|
const { comments } = getState();
|
|
232
241
|
const pendingKey = commentCid + account.id;
|
|
@@ -238,9 +247,9 @@ const commentsStore = createStore((setState, getState) => {
|
|
|
238
247
|
pkcGetCommentPending[pendingKey] = true;
|
|
239
248
|
try {
|
|
240
249
|
// try to find comment in database
|
|
241
|
-
comment = yield getCommentFromDatabase(commentCid, account);
|
|
250
|
+
comment = yield getCommentFromDatabase(commentCid, account, commentData);
|
|
242
251
|
if (!comment) {
|
|
243
|
-
comment = yield ensureLiveComment(commentCid, account,
|
|
252
|
+
comment = yield ensureLiveComment(commentCid, account, commentData);
|
|
244
253
|
comment = normalizeCommentCommunityAddress(comment);
|
|
245
254
|
log("commentsStore.addCommentToStore", { commentCid, comment, account });
|
|
246
255
|
setState((state) => ({
|
|
@@ -254,7 +263,7 @@ const commentsStore = createStore((setState, getState) => {
|
|
|
254
263
|
}));
|
|
255
264
|
// add comment replies pages to repliesPagesStore so they can be used in useComment
|
|
256
265
|
repliesPagesStore.getState().addRepliesPageCommentsToStore(comment);
|
|
257
|
-
comment = yield ensureLiveComment(commentCid, account, comment);
|
|
266
|
+
comment = yield ensureLiveComment(commentCid, account, mergeCommentData(commentCid, comment, commentData));
|
|
258
267
|
}
|
|
259
268
|
if (comment) {
|
|
260
269
|
requestCommentUpdate(commentCid, comment, { stopAfterNextUpdate: true });
|
|
@@ -269,7 +278,7 @@ const commentsStore = createStore((setState, getState) => {
|
|
|
269
278
|
}
|
|
270
279
|
});
|
|
271
280
|
},
|
|
272
|
-
startCommentAutoUpdate(commentCid, subscriberId, account) {
|
|
281
|
+
startCommentAutoUpdate(commentCid, subscriberId, account, commentData) {
|
|
273
282
|
return __awaiter(this, void 0, void 0, function* () {
|
|
274
283
|
const hadAutoUpdateSubscribers = hasCommentAutoUpdateSubscribers(commentCid);
|
|
275
284
|
commentAutoUpdateSubscribers[commentCid] = Object.assign(Object.assign({}, (commentAutoUpdateSubscribers[commentCid] || {})), { [subscriberId]: true });
|
|
@@ -277,7 +286,7 @@ const commentsStore = createStore((setState, getState) => {
|
|
|
277
286
|
return;
|
|
278
287
|
}
|
|
279
288
|
const storedComment = getState().comments[commentCid];
|
|
280
|
-
const liveComment = yield ensureLiveComment(commentCid, account, storedComment
|
|
289
|
+
const liveComment = yield ensureLiveComment(commentCid, account, mergeCommentData(commentCid, storedComment, commentData));
|
|
281
290
|
if (!storedComment) {
|
|
282
291
|
setState((state) => ({
|
|
283
292
|
comments: Object.assign(Object.assign({}, state.comments), { [commentCid]: utils.clone(liveComment) }),
|
|
@@ -308,10 +317,10 @@ const commentsStore = createStore((setState, getState) => {
|
|
|
308
317
|
maybeReleaseStoppedLiveComment(commentCid, liveComment);
|
|
309
318
|
});
|
|
310
319
|
},
|
|
311
|
-
refreshComment(commentCid, account) {
|
|
320
|
+
refreshComment(commentCid, account, commentData) {
|
|
312
321
|
return __awaiter(this, void 0, void 0, function* () {
|
|
313
322
|
const storedComment = getState().comments[commentCid];
|
|
314
|
-
const liveComment = yield ensureLiveComment(commentCid, account, storedComment
|
|
323
|
+
const liveComment = yield ensureLiveComment(commentCid, account, mergeCommentData(commentCid, storedComment, commentData));
|
|
315
324
|
if (!hasCommentAutoUpdateSubscribers(commentCid) &&
|
|
316
325
|
(liveComment === null || liveComment === void 0 ? void 0 : liveComment.updatingState) !== "stopped") {
|
|
317
326
|
yield stopLiveComment(commentCid, liveComment);
|
|
@@ -325,13 +334,13 @@ const commentsStore = createStore((setState, getState) => {
|
|
|
325
334
|
},
|
|
326
335
|
};
|
|
327
336
|
});
|
|
328
|
-
const getCommentFromDatabase = (commentCid, account) => __awaiter(void 0, void 0, void 0, function* () {
|
|
337
|
+
const getCommentFromDatabase = (commentCid, account, initialCommentData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
329
338
|
const commentData = yield commentsDatabase.getItem(commentCid);
|
|
330
339
|
if (!commentData) {
|
|
331
340
|
return;
|
|
332
341
|
}
|
|
333
342
|
try {
|
|
334
|
-
const comment = normalizeCommentCommunityAddress(yield account.pkc.createComment(commentData));
|
|
343
|
+
const comment = normalizeCommentCommunityAddress(yield account.pkc.createComment(mergeCommentData(commentCid, commentData, initialCommentData)));
|
|
335
344
|
return comment;
|
|
336
345
|
}
|
|
337
346
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments-store.js","sourceRoot":"","sources":["../../../src/stores/comments/comments-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,MAAM,gBAAgB,GAAG,cAAc,CAAC,cAAc,CAAC;IACrD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;AACH,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAEnE,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,WAAW,MAAM,SAAS,CAAC;AAClC,OAAO,aAAa,MAAM,aAAa,CAAC;AACxC,OAAO,iBAAiB,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE,IAAI,oBAAoB,GAA+B,EAAE,CAAC;AAC1D,MAAM,YAAY,GAAsC,EAAE,CAAC;AAC3D,MAAM,mBAAmB,GAA2D,EAAE,CAAC;AACvF,MAAM,4BAA4B,GAE9B,EAAE,CAAC;AACP,MAAM,0BAA0B,GAAsC,EAAE,CAAC;AACzE,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAU,CAAC;AAClD,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAAU,CAAC;AAE/C,6CAA6C;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAQ,EAAE,CAAC;AAWjC,MAAM,qBAAqB,GAAG,CAAC,OAAY,EAAE,KAAa,EAAE,QAAkC,EAAE,EAAE;IAChG,IAAI,OAAO,CAAA,OAAO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QAAQ,CAAE,kBAAkB,wDAAI,CAAC;IACnC,CAAC,CAAA,CAAC,CACH,CAAC;IACF,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAErB,mDAAmD;IACnD,aAAa,CAAC,OAAO,EAAE,CAAC;IACxB,yBAAyB;IACzB,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AACxC,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAS,EAAE;IACtD,MAAM,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IACtF,MAAM,kBAAkB,EAAE,CAAC;AAC7B,CAAC,CAAA,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import localForageLru from \"../../lib/localforage-lru\";\nconst commentsDatabase = localForageLru.createInstance({\n name: \"bitsocialReactHooks-comments\",\n size: 5000,\n});\nimport Logger from \"@pkcprotocol/pkc-logger\";\nexport const log = Logger(\"bitsocial-react-hooks:comments:stores\");\nimport { Comment, Comments, Account } from \"../../types\";\nimport utils from \"../../lib/utils\";\nimport createStore from \"zustand\";\nimport accountsStore from \"../accounts\";\nimport repliesPagesStore from \"../replies-pages\";\nimport { normalizeCommentCommunityAddress } from \"../../lib/pkc-compat\";\n\nlet pkcGetCommentPending: { [key: string]: boolean } = {};\nconst liveComments: { [commentCid: string]: Comment } = {};\nconst liveCommentPromises: { [commentCid: string]: Promise<Comment> | undefined } = {};\nconst commentAutoUpdateSubscribers: {\n [commentCid: string]: { [subscriberId: string]: true };\n} = {};\nconst stopCommentAfterNextUpdate: { [commentCid: string]: boolean } = {};\nconst initializedComments = new WeakSet<object>();\nconst trackedListeners = new WeakSet<object>();\n\n// reset all event listeners in between tests\nexport const listeners: any = [];\n\nexport type CommentsState = {\n comments: Comments;\n errors: { [commentCid: string]: Error[] };\n addCommentToStore: Function;\n startCommentAutoUpdate: Function;\n stopCommentAutoUpdate: Function;\n refreshComment: Function;\n};\n\nconst removeCommentListener = (comment: any, event: string, listener: (...args: any[]) => void) => {\n if (typeof comment?.off === \"function\") {\n comment.off(event, listener);\n return;\n }\n if (typeof comment?.removeListener === \"function\") {\n comment.removeListener(event, listener);\n }\n};\n\nconst getCommentAutoUpdateSubscribersCount = (commentCid: string) =>\n Object.keys(commentAutoUpdateSubscribers[commentCid] || {}).length;\n\nconst hasCommentAutoUpdateSubscribers = (commentCid: string) =>\n getCommentAutoUpdateSubscribersCount(commentCid) > 0;\n\nconst releaseLiveComment = (commentCid: string, comment?: Comment) => {\n const liveComment = comment || liveComments[commentCid];\n if (liveComment) {\n const listenerIndex = listeners.indexOf(liveComment);\n if (listenerIndex !== -1) {\n listeners.splice(listenerIndex, 1);\n }\n }\n if (!comment || liveComments[commentCid] === liveComment) {\n delete liveComments[commentCid];\n }\n};\n\nconst maybeReleaseStoppedLiveComment = (commentCid: string, comment?: Comment) => {\n if (!comment || hasCommentAutoUpdateSubscribers(commentCid)) {\n return;\n }\n if (liveComments[commentCid] !== comment) {\n return;\n }\n releaseLiveComment(commentCid, comment);\n};\n\nconst commentsStore = createStore<CommentsState>((setState: Function, getState: Function) => {\n const addCommentError = (commentCid: string, error: Error) => {\n setState((state: CommentsState) => {\n let commentErrors = state.errors[commentCid] || [];\n commentErrors = [...commentErrors, error];\n return { ...state, errors: { ...state.errors, [commentCid]: commentErrors } };\n });\n };\n\n const persistComment = async (commentCid: string, nextComment: Comment) => {\n const normalizedComment = normalizeCommentCommunityAddress(utils.clone(nextComment)) as Comment;\n await commentsDatabase.setItem(commentCid, normalizedComment);\n log(\"commentsStore comment update\", { commentCid, updatedComment: normalizedComment });\n setState((state: CommentsState) => ({\n comments: { ...state.comments, [commentCid]: normalizedComment },\n }));\n\n // add comment replies pages to repliesPagesStore so they can be used in useComment\n repliesPagesStore.getState().addRepliesPageCommentsToStore(nextComment);\n\n return normalizedComment;\n };\n\n const stopLiveComment = async (commentCid: string, comment?: Comment) => {\n const liveComment = comment || liveComments[commentCid];\n if (typeof liveComment?.stop !== \"function\") {\n return;\n }\n try {\n await liveComment.stop();\n } catch (error) {\n log.trace(\"comment.stop error\", { commentCid, comment: liveComment, error });\n }\n };\n\n const maybeStopCommentAfterOneShotUpdate = (commentCid: string, comment: Comment) => {\n if (!stopCommentAfterNextUpdate[commentCid]) {\n return;\n }\n delete stopCommentAfterNextUpdate[commentCid];\n if (hasCommentAutoUpdateSubscribers(commentCid)) {\n return;\n }\n void stopLiveComment(commentCid, comment).finally(() => {\n maybeReleaseStoppedLiveComment(commentCid, comment);\n });\n };\n\n const initializeComment = (commentCid: string, comment: Comment, account: Account) => {\n if (initializedComments.has(comment as object)) {\n liveComments[commentCid] = comment;\n return;\n }\n initializedComments.add(comment as object);\n liveComments[commentCid] = comment;\n\n comment?.on?.(\"update\", async (updatedComment: Comment) => {\n updatedComment = normalizeCommentCommunityAddress(utils.clone(updatedComment)) as Comment;\n await persistComment(commentCid, updatedComment);\n });\n\n comment?.on?.(\"updatingstatechange\", (updatingState: string) => {\n setState((state: CommentsState) => ({\n comments: {\n ...state.comments,\n [commentCid]: { ...state.comments[commentCid], updatingState },\n },\n }));\n\n if (updatingState === \"succeeded\" || updatingState === \"failed\") {\n maybeStopCommentAfterOneShotUpdate(commentCid, comment);\n }\n });\n\n comment?.on?.(\"error\", (error: Error) => {\n addCommentError(commentCid, error);\n });\n\n // set clients on comment so the frontend can display it, dont persist in db because a reload cancels updating\n utils.clientsOnStateChange(\n comment?.clients,\n (clientState: string, clientType: string, clientUrl: string, chainTicker?: string) => {\n setState((state: CommentsState) => {\n // make sure not undefined, sometimes happens in e2e tests\n if (!state.comments[commentCid]) {\n return {};\n }\n const clients = { ...state.comments[commentCid]?.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 comments: {\n ...state.comments,\n [commentCid]: { ...state.comments[commentCid], clients },\n },\n };\n });\n },\n );\n\n // when publishing a comment, you don't yet know its CID\n // so when a new comment is fetched, check to see if it's your own\n // comment, and if yes, add the CID to your account comments database\n // if comment.timestamp isn't defined, it means the next update will contain the timestamp and author\n // which is used in addCidToAccountComment\n if (!comment?.timestamp) {\n comment?.once?.(\"update\", () =>\n accountsStore\n .getState()\n .accountsActionsInternal.addCidToAccountComment(comment)\n .catch((error: any) =>\n log.error(\"accountsActionsInternal.addCidToAccountComment error\", { comment, error }),\n ),\n );\n }\n\n if (!trackedListeners.has(comment as object)) {\n trackedListeners.add(comment as object);\n listeners.push(comment);\n }\n };\n\n const ensureLiveComment = async (commentCid: string, account: Account, commentData?: Comment) => {\n if (liveComments[commentCid]) {\n return liveComments[commentCid];\n }\n if (liveCommentPromises[commentCid]) {\n return liveCommentPromises[commentCid] as Promise<Comment>;\n }\n\n const liveCommentPromise = (async () => {\n const initialComment =\n normalizeCommentCommunityAddress(utils.clone(commentData || { cid: commentCid })) ||\n ({ cid: commentCid } as Comment);\n const liveComment = normalizeCommentCommunityAddress(\n await account.pkc.createComment(initialComment),\n ) as Comment;\n initializeComment(commentCid, liveComment, account);\n return liveComment;\n })();\n liveCommentPromises[commentCid] = liveCommentPromise;\n\n try {\n return await liveCommentPromise;\n } finally {\n if (liveCommentPromises[commentCid] === liveCommentPromise) {\n delete liveCommentPromises[commentCid];\n }\n }\n };\n\n const requestCommentUpdate = (\n commentCid: string,\n comment: Comment,\n options?: { stopAfterNextUpdate?: boolean },\n ) => {\n if (options?.stopAfterNextUpdate) {\n stopCommentAfterNextUpdate[commentCid] = true;\n } else {\n delete stopCommentAfterNextUpdate[commentCid];\n }\n\n comment\n ?.update?.()\n .catch((error: unknown) => log.trace(\"comment.update error\", { commentCid, comment, error }));\n };\n\n const waitForCommentUpdateCycle = (commentCid: string, comment: Comment) =>\n new Promise<Comment>((resolve, reject) => {\n const onUpdatingStateChange = (updatingState: string) => {\n if (updatingState === \"succeeded\") {\n cleanup();\n resolve(normalizeCommentCommunityAddress(utils.clone(comment)) as Comment);\n return;\n }\n if (updatingState === \"failed\") {\n cleanup();\n reject(getState().errors[commentCid]?.slice(-1)[0] || Error(\"comment update failed\"));\n }\n };\n\n const onError = (error: Error) => {\n cleanup();\n reject(error);\n };\n\n const cleanup = () => {\n removeCommentListener(comment, \"updatingstatechange\", onUpdatingStateChange);\n removeCommentListener(comment, \"error\", onError);\n };\n\n comment?.on?.(\"updatingstatechange\", onUpdatingStateChange);\n comment?.on?.(\"error\", onError);\n });\n\n return {\n comments: {},\n errors: {},\n\n async addCommentToStore(commentCid: string, account: Account) {\n const { comments } = getState();\n const pendingKey = commentCid + account.id;\n\n // comment is in store already, do nothing\n let comment: Comment | undefined = comments[commentCid];\n if (comment || pkcGetCommentPending[pendingKey]) {\n return;\n }\n pkcGetCommentPending[pendingKey] = true;\n\n try {\n // try to find comment in database\n comment = await getCommentFromDatabase(commentCid, account);\n\n if (!comment) {\n comment = await ensureLiveComment(commentCid, account, { cid: commentCid });\n comment = normalizeCommentCommunityAddress(comment);\n log(\"commentsStore.addCommentToStore\", { commentCid, comment, account });\n setState((state: CommentsState) => ({\n comments: { ...state.comments, [commentCid]: utils.clone(comment) },\n }));\n } else {\n comment = normalizeCommentCommunityAddress(comment);\n setState((state: CommentsState) => ({\n comments: { ...state.comments, [commentCid]: utils.clone(comment) },\n }));\n\n // add comment replies pages to repliesPagesStore so they can be used in useComment\n repliesPagesStore.getState().addRepliesPageCommentsToStore(comment);\n\n comment = await ensureLiveComment(commentCid, account, comment);\n }\n\n if (comment) {\n requestCommentUpdate(commentCid, comment, { stopAfterNextUpdate: true });\n }\n } catch (e: any) {\n addCommentError(commentCid, e);\n throw e;\n } finally {\n pkcGetCommentPending[pendingKey] = false;\n }\n },\n\n async startCommentAutoUpdate(commentCid: string, subscriberId: string, account: Account) {\n const hadAutoUpdateSubscribers = hasCommentAutoUpdateSubscribers(commentCid);\n commentAutoUpdateSubscribers[commentCid] = {\n ...(commentAutoUpdateSubscribers[commentCid] || {}),\n [subscriberId]: true,\n };\n\n if (hadAutoUpdateSubscribers && liveComments[commentCid]) {\n return;\n }\n\n const storedComment = getState().comments[commentCid];\n const liveComment = await ensureLiveComment(\n commentCid,\n account,\n storedComment || ({ cid: commentCid } as Comment),\n );\n\n if (!storedComment) {\n setState((state: CommentsState) => ({\n comments: { ...state.comments, [commentCid]: utils.clone(liveComment) },\n }));\n }\n\n if (!hasCommentAutoUpdateSubscribers(commentCid)) {\n await stopLiveComment(commentCid, liveComment);\n maybeReleaseStoppedLiveComment(commentCid, liveComment);\n return;\n }\n\n requestCommentUpdate(commentCid, liveComment);\n },\n\n async stopCommentAutoUpdate(commentCid: string, subscriberId: string) {\n if (commentAutoUpdateSubscribers[commentCid]) {\n delete commentAutoUpdateSubscribers[commentCid][subscriberId];\n if (Object.keys(commentAutoUpdateSubscribers[commentCid]).length === 0) {\n delete commentAutoUpdateSubscribers[commentCid];\n }\n }\n\n if (hasCommentAutoUpdateSubscribers(commentCid)) {\n return;\n }\n\n delete stopCommentAfterNextUpdate[commentCid];\n const liveComment = liveComments[commentCid];\n await stopLiveComment(commentCid, liveComment);\n maybeReleaseStoppedLiveComment(commentCid, liveComment);\n },\n\n async refreshComment(commentCid: string, account: Account) {\n const storedComment = getState().comments[commentCid];\n const liveComment = await ensureLiveComment(\n commentCid,\n account,\n storedComment || ({ cid: commentCid } as Comment),\n );\n\n if (\n !hasCommentAutoUpdateSubscribers(commentCid) &&\n liveComment?.updatingState !== \"stopped\"\n ) {\n await stopLiveComment(commentCid, liveComment);\n }\n\n const waitForUpdate = waitForCommentUpdateCycle(commentCid, liveComment);\n requestCommentUpdate(commentCid, liveComment, {\n stopAfterNextUpdate: !hasCommentAutoUpdateSubscribers(commentCid),\n });\n return waitForUpdate;\n },\n };\n});\n\nconst getCommentFromDatabase = async (commentCid: string, account: Account) => {\n const commentData: any = await commentsDatabase.getItem(commentCid);\n if (!commentData) {\n return;\n }\n try {\n const comment = normalizeCommentCommunityAddress(await account.pkc.createComment(commentData));\n return comment;\n } catch (e) {\n // need to log this always or it could silently fail in production and cache never be used\n console.error(\"failed pkc.createComment(cachedComment)\", {\n cachedComment: commentData,\n error: e,\n });\n }\n};\n\n// reset store in between tests\nconst originalState = commentsStore.getState();\n// async function because some stores have async init\nexport const resetCommentsStore = async () => {\n pkcGetCommentPending = {};\n for (const commentCid in commentAutoUpdateSubscribers) {\n delete commentAutoUpdateSubscribers[commentCid];\n }\n for (const commentCid in stopCommentAfterNextUpdate) {\n delete stopCommentAfterNextUpdate[commentCid];\n }\n for (const commentCid in liveCommentPromises) {\n delete liveCommentPromises[commentCid];\n }\n for (const commentCid in liveComments) {\n delete liveComments[commentCid];\n }\n\n // remove all event listeners\n await Promise.all(\n listeners.map(async (listener: any) => {\n try {\n if (typeof listener?.stop === \"function\") {\n await listener.stop();\n }\n } catch {}\n listener?.removeAllListeners?.();\n }),\n );\n listeners.length = 0;\n\n // destroy all component subscriptions to the store\n commentsStore.destroy();\n // restore original state\n commentsStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetCommentsDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-comments\" }).clear();\n await resetCommentsStore();\n};\n\nexport default commentsStore;\n"]}
|
|
1
|
+
{"version":3,"file":"comments-store.js","sourceRoot":"","sources":["../../../src/stores/comments/comments-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,MAAM,gBAAgB,GAAG,cAAc,CAAC,cAAc,CAAC;IACrD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;AACH,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAEnE,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACp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F,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAErB,mDAAmD;IACnD,aAAa,CAAC,OAAO,EAAE,CAAC;IACxB,yBAAyB;IACzB,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AACxC,CAAC,CAAA,CAAC;AAEF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAS,EAAE;IACtD,MAAM,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IACtF,MAAM,kBAAkB,EAAE,CAAC;AAC7B,CAAC,CAAA,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import localForageLru from \"../../lib/localforage-lru\";\nconst commentsDatabase = localForageLru.createInstance({\n name: \"bitsocialReactHooks-comments\",\n size: 5000,\n});\nimport Logger from \"@pkcprotocol/pkc-logger\";\nexport const log = Logger(\"bitsocial-react-hooks:comments:stores\");\nimport { Comment, Comments, Account } from \"../../types\";\nimport utils from \"../../lib/utils\";\nimport createStore from \"zustand\";\nimport accountsStore from \"../accounts\";\nimport repliesPagesStore from \"../replies-pages\";\nimport { normalizeCommentCommunityAddress } from \"../../lib/pkc-compat\";\n\nlet pkcGetCommentPending: { [key: string]: boolean } = {};\nconst liveComments: { [commentCid: string]: Comment } = {};\nconst liveCommentPromises: { [commentCid: string]: Promise<Comment> | undefined } = {};\nconst commentAutoUpdateSubscribers: {\n [commentCid: string]: { [subscriberId: string]: true };\n} = {};\nconst stopCommentAfterNextUpdate: { [commentCid: string]: boolean } = {};\nconst initializedComments = new WeakSet<object>();\nconst trackedListeners = new WeakSet<object>();\n\n// reset all event listeners in between tests\nexport const listeners: any = [];\n\nexport type CommentsState = {\n comments: Comments;\n errors: { [commentCid: string]: Error[] };\n addCommentToStore: Function;\n startCommentAutoUpdate: Function;\n stopCommentAutoUpdate: Function;\n refreshComment: Function;\n};\n\nconst removeCommentListener = (comment: any, event: string, listener: (...args: any[]) => void) => {\n if (typeof comment?.off === \"function\") {\n comment.off(event, listener);\n return;\n }\n if (typeof comment?.removeListener === \"function\") {\n comment.removeListener(event, listener);\n }\n};\n\nconst getCommentAutoUpdateSubscribersCount = (commentCid: string) =>\n Object.keys(commentAutoUpdateSubscribers[commentCid] || {}).length;\n\nconst hasCommentAutoUpdateSubscribers = (commentCid: string) =>\n getCommentAutoUpdateSubscribersCount(commentCid) > 0;\n\nconst mergeCommentData = (\n commentCid: string,\n ...commentDataList: (Comment | undefined)[]\n): Comment => {\n const mergedCommentData: Comment = { cid: commentCid };\n for (const commentData of commentDataList) {\n if (commentData && typeof commentData === \"object\") {\n Object.assign(mergedCommentData, utils.clone(commentData));\n }\n }\n mergedCommentData.cid = commentCid;\n return mergedCommentData;\n};\n\nconst releaseLiveComment = (commentCid: string, comment?: Comment) => {\n const liveComment = comment || liveComments[commentCid];\n if (liveComment) {\n const listenerIndex = listeners.indexOf(liveComment);\n if (listenerIndex !== -1) {\n listeners.splice(listenerIndex, 1);\n }\n }\n if (!comment || liveComments[commentCid] === liveComment) {\n delete liveComments[commentCid];\n }\n};\n\nconst maybeReleaseStoppedLiveComment = (commentCid: string, comment?: Comment) => {\n if (!comment || hasCommentAutoUpdateSubscribers(commentCid)) {\n return;\n }\n if (liveComments[commentCid] !== comment) {\n return;\n }\n releaseLiveComment(commentCid, comment);\n};\n\nconst commentsStore = createStore<CommentsState>((setState: Function, getState: Function) => {\n const addCommentError = (commentCid: string, error: Error) => {\n setState((state: CommentsState) => {\n let commentErrors = state.errors[commentCid] || [];\n commentErrors = [...commentErrors, error];\n return { ...state, errors: { ...state.errors, [commentCid]: commentErrors } };\n });\n };\n\n const persistComment = async (commentCid: string, nextComment: Comment) => {\n const normalizedComment = normalizeCommentCommunityAddress(utils.clone(nextComment)) as Comment;\n await commentsDatabase.setItem(commentCid, normalizedComment);\n log(\"commentsStore comment update\", { commentCid, updatedComment: normalizedComment });\n setState((state: CommentsState) => ({\n comments: { ...state.comments, [commentCid]: normalizedComment },\n }));\n\n // add comment replies pages to repliesPagesStore so they can be used in useComment\n repliesPagesStore.getState().addRepliesPageCommentsToStore(nextComment);\n\n return normalizedComment;\n };\n\n const stopLiveComment = async (commentCid: string, comment?: Comment) => {\n const liveComment = comment || liveComments[commentCid];\n if (typeof liveComment?.stop !== \"function\") {\n return;\n }\n try {\n await liveComment.stop();\n } catch (error) {\n log.trace(\"comment.stop error\", { commentCid, comment: liveComment, error });\n }\n };\n\n const maybeStopCommentAfterOneShotUpdate = (commentCid: string, comment: Comment) => {\n if (!stopCommentAfterNextUpdate[commentCid]) {\n return;\n }\n delete stopCommentAfterNextUpdate[commentCid];\n if (hasCommentAutoUpdateSubscribers(commentCid)) {\n return;\n }\n void stopLiveComment(commentCid, comment).finally(() => {\n maybeReleaseStoppedLiveComment(commentCid, comment);\n });\n };\n\n const initializeComment = (commentCid: string, comment: Comment, account: Account) => {\n if (initializedComments.has(comment as object)) {\n liveComments[commentCid] = comment;\n return;\n }\n initializedComments.add(comment as object);\n liveComments[commentCid] = comment;\n\n comment?.on?.(\"update\", async (updatedComment: Comment) => {\n updatedComment = normalizeCommentCommunityAddress(utils.clone(updatedComment)) as Comment;\n await persistComment(commentCid, updatedComment);\n });\n\n comment?.on?.(\"updatingstatechange\", (updatingState: string) => {\n setState((state: CommentsState) => ({\n comments: {\n ...state.comments,\n [commentCid]: { ...state.comments[commentCid], updatingState },\n },\n }));\n\n if (updatingState === \"succeeded\" || updatingState === \"failed\") {\n maybeStopCommentAfterOneShotUpdate(commentCid, comment);\n }\n });\n\n comment?.on?.(\"error\", (error: Error) => {\n addCommentError(commentCid, error);\n });\n\n // set clients on comment so the frontend can display it, dont persist in db because a reload cancels updating\n utils.clientsOnStateChange(\n comment?.clients,\n (clientState: string, clientType: string, clientUrl: string, chainTicker?: string) => {\n setState((state: CommentsState) => {\n // make sure not undefined, sometimes happens in e2e tests\n if (!state.comments[commentCid]) {\n return {};\n }\n const clients = { ...state.comments[commentCid]?.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 comments: {\n ...state.comments,\n [commentCid]: { ...state.comments[commentCid], clients },\n },\n };\n });\n },\n );\n\n // when publishing a comment, you don't yet know its CID\n // so when a new comment is fetched, check to see if it's your own\n // comment, and if yes, add the CID to your account comments database\n // if comment.timestamp isn't defined, it means the next update will contain the timestamp and author\n // which is used in addCidToAccountComment\n if (!comment?.timestamp) {\n comment?.once?.(\"update\", () =>\n accountsStore\n .getState()\n .accountsActionsInternal.addCidToAccountComment(comment)\n .catch((error: any) =>\n log.error(\"accountsActionsInternal.addCidToAccountComment error\", { comment, error }),\n ),\n );\n }\n\n if (!trackedListeners.has(comment as object)) {\n trackedListeners.add(comment as object);\n listeners.push(comment);\n }\n };\n\n const ensureLiveComment = async (commentCid: string, account: Account, commentData?: Comment) => {\n if (liveComments[commentCid]) {\n return liveComments[commentCid];\n }\n if (liveCommentPromises[commentCid]) {\n return liveCommentPromises[commentCid] as Promise<Comment>;\n }\n\n const liveCommentPromise = (async () => {\n const initialComment = normalizeCommentCommunityAddress(\n mergeCommentData(commentCid, commentData),\n );\n const liveComment = normalizeCommentCommunityAddress(\n await account.pkc.createComment(initialComment),\n ) as Comment;\n initializeComment(commentCid, liveComment, account);\n return liveComment;\n })();\n liveCommentPromises[commentCid] = liveCommentPromise;\n\n try {\n return await liveCommentPromise;\n } finally {\n if (liveCommentPromises[commentCid] === liveCommentPromise) {\n delete liveCommentPromises[commentCid];\n }\n }\n };\n\n const requestCommentUpdate = (\n commentCid: string,\n comment: Comment,\n options?: { stopAfterNextUpdate?: boolean },\n ) => {\n if (options?.stopAfterNextUpdate) {\n stopCommentAfterNextUpdate[commentCid] = true;\n } else {\n delete stopCommentAfterNextUpdate[commentCid];\n }\n\n comment\n ?.update?.()\n .catch((error: unknown) => log.trace(\"comment.update error\", { commentCid, comment, error }));\n };\n\n const waitForCommentUpdateCycle = (commentCid: string, comment: Comment) =>\n new Promise<Comment>((resolve, reject) => {\n const onUpdatingStateChange = (updatingState: string) => {\n if (updatingState === \"succeeded\") {\n cleanup();\n resolve(normalizeCommentCommunityAddress(utils.clone(comment)) as Comment);\n return;\n }\n if (updatingState === \"failed\") {\n cleanup();\n reject(getState().errors[commentCid]?.slice(-1)[0] || Error(\"comment update failed\"));\n }\n };\n\n const onError = (error: Error) => {\n cleanup();\n reject(error);\n };\n\n const cleanup = () => {\n removeCommentListener(comment, \"updatingstatechange\", onUpdatingStateChange);\n removeCommentListener(comment, \"error\", onError);\n };\n\n comment?.on?.(\"updatingstatechange\", onUpdatingStateChange);\n comment?.on?.(\"error\", onError);\n });\n\n return {\n comments: {},\n errors: {},\n\n async addCommentToStore(commentCid: string, account: Account, commentData?: Comment) {\n const { comments } = getState();\n const pendingKey = commentCid + account.id;\n\n // comment is in store already, do nothing\n let comment: Comment | undefined = comments[commentCid];\n if (comment || pkcGetCommentPending[pendingKey]) {\n return;\n }\n pkcGetCommentPending[pendingKey] = true;\n\n try {\n // try to find comment in database\n comment = await getCommentFromDatabase(commentCid, account, commentData);\n\n if (!comment) {\n comment = await ensureLiveComment(commentCid, account, commentData);\n comment = normalizeCommentCommunityAddress(comment);\n log(\"commentsStore.addCommentToStore\", { commentCid, comment, account });\n setState((state: CommentsState) => ({\n comments: { ...state.comments, [commentCid]: utils.clone(comment) },\n }));\n } else {\n comment = normalizeCommentCommunityAddress(comment);\n setState((state: CommentsState) => ({\n comments: { ...state.comments, [commentCid]: utils.clone(comment) },\n }));\n\n // add comment replies pages to repliesPagesStore so they can be used in useComment\n repliesPagesStore.getState().addRepliesPageCommentsToStore(comment);\n\n comment = await ensureLiveComment(\n commentCid,\n account,\n mergeCommentData(commentCid, comment, commentData),\n );\n }\n\n if (comment) {\n requestCommentUpdate(commentCid, comment, { stopAfterNextUpdate: true });\n }\n } catch (e: any) {\n addCommentError(commentCid, e);\n throw e;\n } finally {\n pkcGetCommentPending[pendingKey] = false;\n }\n },\n\n async startCommentAutoUpdate(\n commentCid: string,\n subscriberId: string,\n account: Account,\n commentData?: Comment,\n ) {\n const hadAutoUpdateSubscribers = hasCommentAutoUpdateSubscribers(commentCid);\n commentAutoUpdateSubscribers[commentCid] = {\n ...(commentAutoUpdateSubscribers[commentCid] || {}),\n [subscriberId]: true,\n };\n\n if (hadAutoUpdateSubscribers && liveComments[commentCid]) {\n return;\n }\n\n const storedComment = getState().comments[commentCid];\n const liveComment = await ensureLiveComment(\n commentCid,\n account,\n mergeCommentData(commentCid, storedComment, commentData),\n );\n\n if (!storedComment) {\n setState((state: CommentsState) => ({\n comments: { ...state.comments, [commentCid]: utils.clone(liveComment) },\n }));\n }\n\n if (!hasCommentAutoUpdateSubscribers(commentCid)) {\n await stopLiveComment(commentCid, liveComment);\n maybeReleaseStoppedLiveComment(commentCid, liveComment);\n return;\n }\n\n requestCommentUpdate(commentCid, liveComment);\n },\n\n async stopCommentAutoUpdate(commentCid: string, subscriberId: string) {\n if (commentAutoUpdateSubscribers[commentCid]) {\n delete commentAutoUpdateSubscribers[commentCid][subscriberId];\n if (Object.keys(commentAutoUpdateSubscribers[commentCid]).length === 0) {\n delete commentAutoUpdateSubscribers[commentCid];\n }\n }\n\n if (hasCommentAutoUpdateSubscribers(commentCid)) {\n return;\n }\n\n delete stopCommentAfterNextUpdate[commentCid];\n const liveComment = liveComments[commentCid];\n await stopLiveComment(commentCid, liveComment);\n maybeReleaseStoppedLiveComment(commentCid, liveComment);\n },\n\n async refreshComment(commentCid: string, account: Account, commentData?: Comment) {\n const storedComment = getState().comments[commentCid];\n const liveComment = await ensureLiveComment(\n commentCid,\n account,\n mergeCommentData(commentCid, storedComment, commentData),\n );\n\n if (\n !hasCommentAutoUpdateSubscribers(commentCid) &&\n liveComment?.updatingState !== \"stopped\"\n ) {\n await stopLiveComment(commentCid, liveComment);\n }\n\n const waitForUpdate = waitForCommentUpdateCycle(commentCid, liveComment);\n requestCommentUpdate(commentCid, liveComment, {\n stopAfterNextUpdate: !hasCommentAutoUpdateSubscribers(commentCid),\n });\n return waitForUpdate;\n },\n };\n});\n\nconst getCommentFromDatabase = async (\n commentCid: string,\n account: Account,\n initialCommentData?: Comment,\n) => {\n const commentData: any = await commentsDatabase.getItem(commentCid);\n if (!commentData) {\n return;\n }\n try {\n const comment = normalizeCommentCommunityAddress(\n await account.pkc.createComment(\n mergeCommentData(commentCid, commentData, initialCommentData),\n ),\n );\n return comment;\n } catch (e) {\n // need to log this always or it could silently fail in production and cache never be used\n console.error(\"failed pkc.createComment(cachedComment)\", {\n cachedComment: commentData,\n error: e,\n });\n }\n};\n\n// reset store in between tests\nconst originalState = commentsStore.getState();\n// async function because some stores have async init\nexport const resetCommentsStore = async () => {\n pkcGetCommentPending = {};\n for (const commentCid in commentAutoUpdateSubscribers) {\n delete commentAutoUpdateSubscribers[commentCid];\n }\n for (const commentCid in stopCommentAfterNextUpdate) {\n delete stopCommentAfterNextUpdate[commentCid];\n }\n for (const commentCid in liveCommentPromises) {\n delete liveCommentPromises[commentCid];\n }\n for (const commentCid in liveComments) {\n delete liveComments[commentCid];\n }\n\n // remove all event listeners\n await Promise.all(\n listeners.map(async (listener: any) => {\n try {\n if (typeof listener?.stop === \"function\") {\n await listener.stop();\n }\n } catch {}\n listener?.removeAllListeners?.();\n }),\n );\n listeners.length = 0;\n\n // destroy all component subscriptions to the store\n commentsStore.destroy();\n // restore original state\n commentsStore.setState(originalState);\n};\n\n// reset database and store in between tests\nexport const resetCommentsDatabaseAndStore = async () => {\n await localForageLru.createInstance({ name: \"bitsocialReactHooks-comments\" }).clear();\n await resetCommentsStore();\n};\n\nexport default commentsStore;\n"]}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA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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 onlyIfCached?: boolean;\n autoUpdate?: boolean;\n}\nexport interface UseCommentResult extends Result, Comment {\n refresh(): Promise<void>;\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// 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 interface UseCommunityOptions extends Options {\n community?: CommunityIdentifier;\n onlyIfCached?: boolean;\n}\nexport interface UseCommunityResult extends Result, Community {}\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 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\nexport interface UsePublishCommentOptions 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 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 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// 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// 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 PkcRpcSettings = { [key: string]: any };\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 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 };\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 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 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 onlyIfCached?: boolean;\n autoUpdate?: boolean;\n}\nexport interface UseCommentResult extends Result, Comment {\n refresh(): Promise<void>;\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// 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 interface UseCommunityOptions extends Options {\n community?: CommunityIdentifier;\n onlyIfCached?: boolean;\n}\nexport interface UseCommunityResult extends Result, Community {}\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 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\nexport interface UsePublishCommentOptions 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 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 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// 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// 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 PkcRpcSettings = { [key: string]: any };\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 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 };\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 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 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
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
-
"version": "0.1.
|
|
16
|
+
"version": "0.1.7",
|
|
17
17
|
"packageManager": "yarn@4.13.0",
|
|
18
18
|
"files": [
|
|
19
19
|
"CHANGELOG.md",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"changelog:release-notes": "node scripts/changelog-release-notes.mjs"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@bitsocial/bso-resolver": "0.0.
|
|
50
|
-
"@pkcprotocol/pkc-js": "0.0.
|
|
49
|
+
"@bitsocial/bso-resolver": "0.0.8",
|
|
50
|
+
"@pkcprotocol/pkc-js": "0.0.27",
|
|
51
51
|
"@pkcprotocol/pkc-logger": "0.1.0",
|
|
52
52
|
"assert": "2.0.0",
|
|
53
53
|
"ethers": "5.8.0",
|