elseware-ui 2.31.14 → 2.31.15
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/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +45 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -17966,6 +17966,7 @@ function CommentThread({
|
|
|
17966
17966
|
const [replyCache, setReplyCache] = useState(
|
|
17967
17967
|
{}
|
|
17968
17968
|
);
|
|
17969
|
+
const replyCacheRef = useRef(replyCache);
|
|
17969
17970
|
const ComposerComponent = components?.Composer ?? CommentComposer_default;
|
|
17970
17971
|
const resolvedConfig = {
|
|
17971
17972
|
...DEFAULT_COMMENT_THREAD_CONFIG,
|
|
@@ -17985,6 +17986,45 @@ function CommentThread({
|
|
|
17985
17986
|
}
|
|
17986
17987
|
loadComments();
|
|
17987
17988
|
}, [dataSource, resolvedConfig.commentsPerPage]);
|
|
17989
|
+
useEffect(() => {
|
|
17990
|
+
replyCacheRef.current = replyCache;
|
|
17991
|
+
}, [replyCache]);
|
|
17992
|
+
useEffect(() => {
|
|
17993
|
+
let cancelled = false;
|
|
17994
|
+
async function refreshLoadedReplies() {
|
|
17995
|
+
const parentIds = Object.keys(replyCacheRef.current);
|
|
17996
|
+
if (!parentIds.length) {
|
|
17997
|
+
return;
|
|
17998
|
+
}
|
|
17999
|
+
try {
|
|
18000
|
+
const entries = await Promise.all(
|
|
18001
|
+
parentIds.map(async (parentId) => {
|
|
18002
|
+
const result = await dataSource.getReplies(parentId, {
|
|
18003
|
+
limit: resolvedConfig.repliesPerPage
|
|
18004
|
+
});
|
|
18005
|
+
return [parentId, result.items];
|
|
18006
|
+
})
|
|
18007
|
+
);
|
|
18008
|
+
if (cancelled) {
|
|
18009
|
+
return;
|
|
18010
|
+
}
|
|
18011
|
+
setReplyCache((prev) => {
|
|
18012
|
+
const next = { ...prev };
|
|
18013
|
+
for (const [parentId, replies] of entries) {
|
|
18014
|
+
if (parentId in next) {
|
|
18015
|
+
next[parentId] = replies;
|
|
18016
|
+
}
|
|
18017
|
+
}
|
|
18018
|
+
return next;
|
|
18019
|
+
});
|
|
18020
|
+
} catch {
|
|
18021
|
+
}
|
|
18022
|
+
}
|
|
18023
|
+
void refreshLoadedReplies();
|
|
18024
|
+
return () => {
|
|
18025
|
+
cancelled = true;
|
|
18026
|
+
};
|
|
18027
|
+
}, [dataSource, resolvedConfig.repliesPerPage]);
|
|
17988
18028
|
function updateReplyCacheComment(cache, commentId, updater) {
|
|
17989
18029
|
const next = {};
|
|
17990
18030
|
for (const [parentId, replies] of Object.entries(cache)) {
|
|
@@ -18123,9 +18163,11 @@ function CommentThread({
|
|
|
18123
18163
|
);
|
|
18124
18164
|
}
|
|
18125
18165
|
}
|
|
18126
|
-
function handleEditComment(
|
|
18127
|
-
|
|
18128
|
-
|
|
18166
|
+
async function handleEditComment(comment) {
|
|
18167
|
+
const updatedComment = await onEdit?.(comment);
|
|
18168
|
+
if (updatedComment) {
|
|
18169
|
+
updateCommentEverywhere(updatedComment.id, () => updatedComment);
|
|
18170
|
+
}
|
|
18129
18171
|
}
|
|
18130
18172
|
if (loading || isLoadingComments) {
|
|
18131
18173
|
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|