elseware-ui 2.31.4 → 2.31.5
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.js +30 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18041,28 +18041,48 @@ function CommentThread({
|
|
|
18041
18041
|
setComments((prev) => insertReply(prev, parentComment.id, reply));
|
|
18042
18042
|
}
|
|
18043
18043
|
async function handleLike(comment) {
|
|
18044
|
-
const
|
|
18044
|
+
const optimistic = {
|
|
18045
|
+
liked: !comment.liked,
|
|
18046
|
+
disliked: false,
|
|
18047
|
+
likes: comment.liked ? comment.likes - 1 : comment.likes + 1,
|
|
18048
|
+
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes
|
|
18049
|
+
};
|
|
18045
18050
|
setComments(
|
|
18046
18051
|
(prev) => updateComment(prev, comment.id, (item) => ({
|
|
18047
18052
|
...item,
|
|
18048
|
-
likes:
|
|
18049
|
-
dislikes:
|
|
18050
|
-
liked:
|
|
18051
|
-
disliked:
|
|
18053
|
+
likes: optimistic.likes,
|
|
18054
|
+
dislikes: optimistic.dislikes,
|
|
18055
|
+
liked: optimistic.liked,
|
|
18056
|
+
disliked: optimistic.disliked
|
|
18052
18057
|
}))
|
|
18053
18058
|
);
|
|
18059
|
+
try {
|
|
18060
|
+
await dataSource.toggleLike(comment.id);
|
|
18061
|
+
} catch {
|
|
18062
|
+
setComments((prev) => updateComment(prev, comment.id, () => comment));
|
|
18063
|
+
}
|
|
18054
18064
|
}
|
|
18055
18065
|
async function handleDislike(comment) {
|
|
18056
|
-
const
|
|
18066
|
+
const optimistic = {
|
|
18067
|
+
liked: false,
|
|
18068
|
+
disliked: !comment.disliked,
|
|
18069
|
+
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes,
|
|
18070
|
+
dislikes: comment.disliked ? comment.dislikes - 1 : comment.dislikes + 1
|
|
18071
|
+
};
|
|
18057
18072
|
setComments(
|
|
18058
18073
|
(prev) => updateComment(prev, comment.id, (item) => ({
|
|
18059
18074
|
...item,
|
|
18060
|
-
likes:
|
|
18061
|
-
dislikes:
|
|
18062
|
-
liked:
|
|
18063
|
-
disliked:
|
|
18075
|
+
likes: optimistic.likes,
|
|
18076
|
+
dislikes: optimistic.dislikes,
|
|
18077
|
+
liked: optimistic.liked,
|
|
18078
|
+
disliked: optimistic.disliked
|
|
18064
18079
|
}))
|
|
18065
18080
|
);
|
|
18081
|
+
try {
|
|
18082
|
+
await dataSource.toggleDislike(comment.id);
|
|
18083
|
+
} catch {
|
|
18084
|
+
setComments((prev) => updateComment(prev, comment.id, () => comment));
|
|
18085
|
+
}
|
|
18066
18086
|
}
|
|
18067
18087
|
if (loading || isLoadingComments) {
|
|
18068
18088
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|