@blocklet/discuss-kit 1.5.63 → 1.5.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api.js +3 -3
- package/lib/cjs/comments.js +7 -12
- package/lib/es/api.js +3 -3
- package/lib/es/comments.js +9 -14
- package/package.json +4 -4
package/lib/cjs/api.js
CHANGED
|
@@ -10,8 +10,8 @@ request.interceptors.request.use(
|
|
|
10
10
|
},
|
|
11
11
|
(error) => Promise.reject(error)
|
|
12
12
|
);
|
|
13
|
-
const
|
|
14
|
-
const { data } = await request.get(`/ratings/${id}
|
|
13
|
+
const fetchRatings = async (id) => {
|
|
14
|
+
const { data } = await request.get(`/ratings/${id}`);
|
|
15
15
|
return data;
|
|
16
16
|
};
|
|
17
17
|
const fetchComments = async (params) => {
|
|
@@ -41,5 +41,5 @@ const fetchMoreReplies = async ({ commentId, cursor, limit = 10 }) => {
|
|
|
41
41
|
exports.default = request;
|
|
42
42
|
exports.fetchComments = fetchComments;
|
|
43
43
|
exports.fetchMoreReplies = fetchMoreReplies;
|
|
44
|
-
exports.
|
|
44
|
+
exports.fetchRatings = fetchRatings;
|
|
45
45
|
exports.reply = reply;
|
package/lib/cjs/comments.js
CHANGED
|
@@ -166,7 +166,7 @@ function DiscussKitComments({
|
|
|
166
166
|
const {
|
|
167
167
|
t
|
|
168
168
|
} = context.useLocaleContext();
|
|
169
|
-
const objectRatingState = useAsyncRetry(() => api.
|
|
169
|
+
const objectRatingState = useAsyncRetry(() => api.fetchRatings(object.id));
|
|
170
170
|
const handlers = {
|
|
171
171
|
ADD_COMMENT: (data) => {
|
|
172
172
|
add(formatComment(data));
|
|
@@ -176,7 +176,7 @@ function DiscussKitComments({
|
|
|
176
176
|
RATING_COMMENT: async ({
|
|
177
177
|
commentId
|
|
178
178
|
}) => {
|
|
179
|
-
const rating = await api.
|
|
179
|
+
const rating = await api.fetchRatings(commentId);
|
|
180
180
|
updateCommentState(commentId, (current) => ({
|
|
181
181
|
...current,
|
|
182
182
|
rating
|
|
@@ -233,17 +233,12 @@ function DiscussKitComments({
|
|
|
233
233
|
children: [/* @__PURE__ */ jsxRuntime.jsxs(Box__default.default, {
|
|
234
234
|
display: "flex",
|
|
235
235
|
justifyContent: "space-between",
|
|
236
|
-
alignItems: "
|
|
237
|
-
children: [displayReaction && /* @__PURE__ */ jsxRuntime.jsx(Box__default.default, {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
selectedValue: objectRatingState.value.myRating,
|
|
241
|
-
countPerValue: objectRatingState.value.counts,
|
|
236
|
+
alignItems: "end",
|
|
237
|
+
children: [displayReaction && objectRatingState.value && /* @__PURE__ */ jsxRuntime.jsx(Box__default.default, {
|
|
238
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.GithubReaction, {
|
|
239
|
+
data: objectRatingState.value,
|
|
242
240
|
onRate: handleOnRate,
|
|
243
|
-
onUnrate: handleOnUnrate
|
|
244
|
-
variant: "inverse",
|
|
245
|
-
size: "lg",
|
|
246
|
-
fetchRatings: () => commentAPI.fetchRatings(object.id)
|
|
241
|
+
onUnrate: handleOnUnrate
|
|
247
242
|
})
|
|
248
243
|
}), displayConnectButton && (session.user ? /* @__PURE__ */ jsxRuntime.jsx(SessionManager__default.default, {
|
|
249
244
|
style: {
|
package/lib/es/api.js
CHANGED
|
@@ -6,8 +6,8 @@ request.interceptors.request.use(
|
|
|
6
6
|
},
|
|
7
7
|
(error) => Promise.reject(error)
|
|
8
8
|
);
|
|
9
|
-
const
|
|
10
|
-
const { data } = await request.get(`/ratings/${id}
|
|
9
|
+
const fetchRatings = async (id) => {
|
|
10
|
+
const { data } = await request.get(`/ratings/${id}`);
|
|
11
11
|
return data;
|
|
12
12
|
};
|
|
13
13
|
const fetchComments = async (params) => {
|
|
@@ -38,6 +38,6 @@ export {
|
|
|
38
38
|
request as default,
|
|
39
39
|
fetchComments,
|
|
40
40
|
fetchMoreReplies,
|
|
41
|
-
|
|
41
|
+
fetchRatings,
|
|
42
42
|
reply
|
|
43
43
|
};
|
package/lib/es/comments.js
CHANGED
|
@@ -10,12 +10,12 @@ import CircularProgress from "@mui/material/CircularProgress";
|
|
|
10
10
|
import ButtonGroup from "@mui/material/ButtonGroup";
|
|
11
11
|
import { useLocaleContext, LocaleProvider } from "@arcblock/ux/lib/Locale/context";
|
|
12
12
|
import { ErrorBoundary } from "react-error-boundary";
|
|
13
|
-
import { InternalThemeProvider, DefaultEditorConfigProvider, CommentsProvider, useCommentsContext,
|
|
13
|
+
import { InternalThemeProvider, DefaultEditorConfigProvider, CommentsProvider, useCommentsContext, GithubReaction, CommentInput, CommentList } from "@blocklet/discuss-kit-ux";
|
|
14
14
|
import { useRequest } from "ahooks";
|
|
15
15
|
import ErrorFallback from "./components/error-fallback";
|
|
16
16
|
import { translations } from "./locales";
|
|
17
17
|
import getWsClient, { useSubscription } from "./ws";
|
|
18
|
-
import api, {
|
|
18
|
+
import api, { fetchRatings } from "./api";
|
|
19
19
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
20
20
|
const useAsyncRetry = (fn, deps = []) => {
|
|
21
21
|
const state = useRequest(fn, {
|
|
@@ -154,7 +154,7 @@ function DiscussKitComments({
|
|
|
154
154
|
const {
|
|
155
155
|
t
|
|
156
156
|
} = useLocaleContext();
|
|
157
|
-
const objectRatingState = useAsyncRetry(() =>
|
|
157
|
+
const objectRatingState = useAsyncRetry(() => fetchRatings(object.id));
|
|
158
158
|
const handlers = {
|
|
159
159
|
ADD_COMMENT: (data) => {
|
|
160
160
|
add(formatComment(data));
|
|
@@ -164,7 +164,7 @@ function DiscussKitComments({
|
|
|
164
164
|
RATING_COMMENT: async ({
|
|
165
165
|
commentId
|
|
166
166
|
}) => {
|
|
167
|
-
const rating = await
|
|
167
|
+
const rating = await fetchRatings(commentId);
|
|
168
168
|
updateCommentState(commentId, (current) => ({
|
|
169
169
|
...current,
|
|
170
170
|
rating
|
|
@@ -221,17 +221,12 @@ function DiscussKitComments({
|
|
|
221
221
|
children: [/* @__PURE__ */ jsxs(Box, {
|
|
222
222
|
display: "flex",
|
|
223
223
|
justifyContent: "space-between",
|
|
224
|
-
alignItems: "
|
|
225
|
-
children: [displayReaction && /* @__PURE__ */ jsx(Box, {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
selectedValue: objectRatingState.value.myRating,
|
|
229
|
-
countPerValue: objectRatingState.value.counts,
|
|
224
|
+
alignItems: "end",
|
|
225
|
+
children: [displayReaction && objectRatingState.value && /* @__PURE__ */ jsx(Box, {
|
|
226
|
+
children: /* @__PURE__ */ jsx(GithubReaction, {
|
|
227
|
+
data: objectRatingState.value,
|
|
230
228
|
onRate: handleOnRate,
|
|
231
|
-
onUnrate: handleOnUnrate
|
|
232
|
-
variant: "inverse",
|
|
233
|
-
size: "lg",
|
|
234
|
-
fetchRatings: () => commentAPI.fetchRatings(object.id)
|
|
229
|
+
onUnrate: handleOnUnrate
|
|
235
230
|
})
|
|
236
231
|
}), displayConnectButton && (session.user ? /* @__PURE__ */ jsx(SessionManager, {
|
|
237
232
|
style: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.65",
|
|
4
4
|
"description": "A react component for Discuss Kit blocklet.",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/es/index.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@arcblock/did-connect": "^2.7.8",
|
|
38
38
|
"@arcblock/ux": "^2.7.8",
|
|
39
39
|
"@arcblock/ws": "^1.18.89",
|
|
40
|
-
"@blocklet/discuss-kit-ux": "1.5.
|
|
41
|
-
"@blocklet/editor": "1.5.
|
|
40
|
+
"@blocklet/discuss-kit-ux": "1.5.65",
|
|
41
|
+
"@blocklet/editor": "1.5.65",
|
|
42
42
|
"@emotion/react": "^11.10.5",
|
|
43
43
|
"@emotion/styled": "^11.10.5",
|
|
44
44
|
"@mui/icons-material": "^5.14.3",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"vite-plugin-build": "^0.7.1",
|
|
78
78
|
"vite-plugin-svgr": "^2.2.2"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "6212cd205e1de8873c163f80ec59dd3f31ecb628"
|
|
81
81
|
}
|