@blocklet/discuss-kit 2.0.36 → 2.0.37
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/comments.js +25 -10
- package/lib/cjs/locales/en.js +4 -0
- package/lib/cjs/locales/zh.js +4 -0
- package/lib/es/comments.js +19 -4
- package/lib/es/locales/en.js +4 -0
- package/lib/es/locales/zh.js +4 -0
- package/package.json +4 -4
package/lib/cjs/comments.js
CHANGED
|
@@ -7,8 +7,7 @@ const PropTypes = require("prop-types");
|
|
|
7
7
|
const SessionManager = require("@arcblock/did-connect/lib/SessionManager");
|
|
8
8
|
const Session = require("@arcblock/did-connect/lib/Session");
|
|
9
9
|
const Button = require("@arcblock/ux/lib/Button");
|
|
10
|
-
const
|
|
11
|
-
const CircularProgress = require("@mui/material/CircularProgress");
|
|
10
|
+
const material = require("@mui/material");
|
|
12
11
|
const context = require("@arcblock/ux/lib/Locale/context");
|
|
13
12
|
const reactErrorBoundary = require("react-error-boundary");
|
|
14
13
|
const discussKitUx = require("@blocklet/discuss-kit-ux");
|
|
@@ -105,7 +104,17 @@ const DiscussKitComments = react.forwardRef(
|
|
|
105
104
|
sendIcon,
|
|
106
105
|
showTopbar
|
|
107
106
|
}, ref) => {
|
|
108
|
-
|
|
107
|
+
const [apiAvailable, setApiAvailable] = react.useState(true);
|
|
108
|
+
discussKitUx.useDefaultApiErrorHandler({
|
|
109
|
+
request: api,
|
|
110
|
+
onError: (e) => {
|
|
111
|
+
var _a;
|
|
112
|
+
if (((_a = e.response) == null ? void 0 : _a.status) === 404) {
|
|
113
|
+
setApiAvailable(false);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
109
118
|
const { session } = react.useContext(Session.SessionContext) || {};
|
|
110
119
|
const { state, sort, add, updateCommentState, interactive, findById } = discussKitUx.useCommentsContext();
|
|
111
120
|
const { total, order, initialized } = state;
|
|
@@ -145,7 +154,7 @@ const DiscussKitComments = react.forwardRef(
|
|
|
145
154
|
[object.id, state]
|
|
146
155
|
);
|
|
147
156
|
if (!initialized) {
|
|
148
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Box, { width: "100%", display: "flex", justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(CircularProgress, {}) });
|
|
157
|
+
return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { width: "100%", display: "flex", justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, {}) });
|
|
149
158
|
}
|
|
150
159
|
const sendComment = async (content) => {
|
|
151
160
|
const { data } = await api.post("/comments", { content, object });
|
|
@@ -180,10 +189,16 @@ const DiscussKitComments = react.forwardRef(
|
|
|
180
189
|
}
|
|
181
190
|
);
|
|
182
191
|
};
|
|
192
|
+
if (!apiAvailable) {
|
|
193
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(material.Alert, { severity: "info", children: [
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.AlertTitle, { children: t("apiUnavailable.title") }),
|
|
195
|
+
t("apiUnavailable.desc")
|
|
196
|
+
] });
|
|
197
|
+
}
|
|
183
198
|
return /* @__PURE__ */ jsxRuntime.jsxs(Container, { ref, children: [
|
|
184
199
|
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
185
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "end", children: [
|
|
186
|
-
displayReaction && objectRatingState.value && /* @__PURE__ */ jsxRuntime.jsx(Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
200
|
+
/* @__PURE__ */ jsxRuntime.jsxs(material.Box, { display: "flex", justifyContent: "space-between", alignItems: "end", children: [
|
|
201
|
+
displayReaction && objectRatingState.value && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
187
202
|
discussKitUx.GithubReaction,
|
|
188
203
|
{
|
|
189
204
|
data: objectRatingState.value,
|
|
@@ -199,10 +214,10 @@ const DiscussKitComments = react.forwardRef(
|
|
|
199
214
|
" ",
|
|
200
215
|
/* @__PURE__ */ jsxRuntime.jsx("a", { className: "down-load-wallet", href: "https://www.didwallet.io/", target: "_blank", rel: "noreferrer", children: t("installDIDWallet") })
|
|
201
216
|
] }) }),
|
|
202
|
-
session.user && interactive && commentInputPosition === "top" && /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 2, className: "comment-editor", children: renderCommentInput() })
|
|
217
|
+
session.user && interactive && commentInputPosition === "top" && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { mt: 2, className: "comment-editor", children: renderCommentInput() })
|
|
203
218
|
] }),
|
|
204
|
-
!!total && showTopbar && /* @__PURE__ */ jsxRuntime.jsxs(Box, { display: "flex", justifyContent: "space-between", mt: 3, children: [
|
|
205
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { fontWeight: "medium" }, children: [
|
|
219
|
+
!!total && showTopbar && /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { display: "flex", justifyContent: "space-between", mt: 3, children: [
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { fontWeight: "medium" }, children: [
|
|
206
221
|
total > 0 ? `${total} ${t("comments")}` : t("comment"),
|
|
207
222
|
" "
|
|
208
223
|
] }),
|
|
@@ -219,7 +234,7 @@ const DiscussKitComments = react.forwardRef(
|
|
|
219
234
|
)
|
|
220
235
|
] }),
|
|
221
236
|
/* @__PURE__ */ jsxRuntime.jsx(discussKitUx.CommentList, { className: "comment-list" }),
|
|
222
|
-
session.user && interactive && commentInputPosition === "bottom" && /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 6, children: renderCommentInput() })
|
|
237
|
+
session.user && interactive && commentInputPosition === "bottom" && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { mt: 6, children: renderCommentInput() })
|
|
223
238
|
] });
|
|
224
239
|
}
|
|
225
240
|
);
|
package/lib/cjs/locales/en.js
CHANGED
|
@@ -41,6 +41,10 @@ const en = flat({
|
|
|
41
41
|
unpin: "unpinned this",
|
|
42
42
|
markAsFeatured: "marked this as featured",
|
|
43
43
|
unmarkAsFeatured: "unmarked this as featured"
|
|
44
|
+
},
|
|
45
|
+
apiUnavailable: {
|
|
46
|
+
title: "Comment service is not available",
|
|
47
|
+
desc: "Unable to access the comment service, please verify if Discuss Kit Blocklet is running and check for any access restrictions."
|
|
44
48
|
}
|
|
45
49
|
});
|
|
46
50
|
module.exports = en;
|
package/lib/cjs/locales/zh.js
CHANGED
package/lib/es/comments.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useContext, useRef, useMemo, useEffect } from "react";
|
|
2
|
+
import { forwardRef, useState, useContext, useRef, useMemo, useEffect } from "react";
|
|
3
3
|
import { styled } from "@arcblock/ux/lib/Theme";
|
|
4
4
|
import joinUrl from "url-join";
|
|
5
5
|
import PropTypes from "prop-types";
|
|
6
6
|
import SessionManager from "@arcblock/did-connect/lib/SessionManager";
|
|
7
7
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
8
8
|
import Button from "@arcblock/ux/lib/Button";
|
|
9
|
-
import Box from "@mui/material
|
|
10
|
-
import CircularProgress from "@mui/material/CircularProgress";
|
|
9
|
+
import { Box, CircularProgress, Alert, AlertTitle } from "@mui/material";
|
|
11
10
|
import { useLocaleContext, LocaleProvider } from "@arcblock/ux/lib/Locale/context";
|
|
12
11
|
import { ErrorBoundary } from "react-error-boundary";
|
|
13
12
|
import { useDefaultApiErrorHandler, useCommentsContext, useSubscription, GithubReaction, SegmentedControl, CommentList, getWsClient, UploaderProvider, InternalThemeProvider, ConfirmProvider, DefaultEditorConfigProvider, CommentsProvider, CommentInput } from "@blocklet/discuss-kit-ux";
|
|
@@ -104,7 +103,17 @@ const DiscussKitComments = forwardRef(
|
|
|
104
103
|
sendIcon,
|
|
105
104
|
showTopbar
|
|
106
105
|
}, ref) => {
|
|
107
|
-
|
|
106
|
+
const [apiAvailable, setApiAvailable] = useState(true);
|
|
107
|
+
useDefaultApiErrorHandler({
|
|
108
|
+
request: api,
|
|
109
|
+
onError: (e) => {
|
|
110
|
+
var _a;
|
|
111
|
+
if (((_a = e.response) == null ? void 0 : _a.status) === 404) {
|
|
112
|
+
setApiAvailable(false);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
108
117
|
const { session } = useContext(SessionContext) || {};
|
|
109
118
|
const { state, sort, add, updateCommentState, interactive, findById } = useCommentsContext();
|
|
110
119
|
const { total, order, initialized } = state;
|
|
@@ -179,6 +188,12 @@ const DiscussKitComments = forwardRef(
|
|
|
179
188
|
}
|
|
180
189
|
);
|
|
181
190
|
};
|
|
191
|
+
if (!apiAvailable) {
|
|
192
|
+
return /* @__PURE__ */ jsxs(Alert, { severity: "info", children: [
|
|
193
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: t("apiUnavailable.title") }),
|
|
194
|
+
t("apiUnavailable.desc")
|
|
195
|
+
] });
|
|
196
|
+
}
|
|
182
197
|
return /* @__PURE__ */ jsxs(Container, { ref, children: [
|
|
183
198
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
184
199
|
/* @__PURE__ */ jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "end", children: [
|
package/lib/es/locales/en.js
CHANGED
|
@@ -40,6 +40,10 @@ const en = flat({
|
|
|
40
40
|
unpin: "unpinned this",
|
|
41
41
|
markAsFeatured: "marked this as featured",
|
|
42
42
|
unmarkAsFeatured: "unmarked this as featured"
|
|
43
|
+
},
|
|
44
|
+
apiUnavailable: {
|
|
45
|
+
title: "Comment service is not available",
|
|
46
|
+
desc: "Unable to access the comment service, please verify if Discuss Kit Blocklet is running and check for any access restrictions."
|
|
43
47
|
}
|
|
44
48
|
});
|
|
45
49
|
export {
|
package/lib/es/locales/zh.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.37",
|
|
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.10.1",
|
|
38
38
|
"@arcblock/ux": "^2.10.1",
|
|
39
39
|
"@arcblock/ws": "^1.18.123",
|
|
40
|
-
"@blocklet/discuss-kit-ux": "2.0.
|
|
41
|
-
"@blocklet/editor": "2.0.
|
|
40
|
+
"@blocklet/discuss-kit-ux": "2.0.37",
|
|
41
|
+
"@blocklet/editor": "2.0.37",
|
|
42
42
|
"@blocklet/js-sdk": "^1.16.28",
|
|
43
43
|
"@blocklet/ui-react": "^2.10.1",
|
|
44
44
|
"@emotion/react": "^11.10.5",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"vite-plugin-build": "^0.10.0",
|
|
79
79
|
"vite-plugin-svgr": "^4.2.0"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "7739c4309ff2a2997bd1f5f5d3510ec0c291dabd"
|
|
82
82
|
}
|