@blocklet/discuss-kit 1.5.56 → 1.5.58

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.
@@ -3,7 +3,6 @@ const react = require("react");
3
3
  const Theme = require("@arcblock/ux/lib/Theme");
4
4
  const joinUrl = require("url-join");
5
5
  const PropTypes = require("prop-types");
6
- const reactUse = require("react-use");
7
6
  const SessionManager = require("@arcblock/did-connect/lib/SessionManager");
8
7
  const Session = require("@arcblock/did-connect/lib/Session");
9
8
  const Button = require("@arcblock/ux/lib/Button");
@@ -13,6 +12,7 @@ const ButtonGroup = require("@mui/material/ButtonGroup");
13
12
  const context = require("@arcblock/ux/lib/Locale/context");
14
13
  const reactErrorBoundary = require("react-error-boundary");
15
14
  const discussKitUx = require("@blocklet/discuss-kit-ux");
15
+ const ahooks = require("ahooks");
16
16
  const ErrorFallback = require("./components/error-fallback");
17
17
  const locales = require("./locales");
18
18
  const getWsClient = require("./ws");
@@ -29,6 +29,16 @@ const ButtonGroup__default = /* @__PURE__ */ _interopDefaultLegacy(ButtonGroup);
29
29
  const ErrorFallback__default = /* @__PURE__ */ _interopDefaultLegacy(ErrorFallback);
30
30
  const getWsClient__default = /* @__PURE__ */ _interopDefaultLegacy(getWsClient);
31
31
  const api__default = /* @__PURE__ */ _interopDefaultLegacy(api);
32
+ const useAsyncRetry = (fn, deps = []) => {
33
+ const state = ahooks.useRequest(fn, {
34
+ refreshDeps: deps
35
+ });
36
+ return {
37
+ ...state,
38
+ value: state == null ? void 0 : state.data,
39
+ retry: state == null ? void 0 : state.run
40
+ };
41
+ };
32
42
  const getPrefix = () => {
33
43
  var _a, _b;
34
44
  const service = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find((x) => x.name === "did-comments");
@@ -156,7 +166,7 @@ function DiscussKitComments({
156
166
  const {
157
167
  t
158
168
  } = context.useLocaleContext();
159
- const objectRatingState = reactUse.useAsyncRetry(() => api.fetchRatingStats(object.id));
169
+ const objectRatingState = useAsyncRetry(() => api.fetchRatingStats(object.id));
160
170
  const handlers = {
161
171
  ADD_COMMENT: (data) => {
162
172
  add(formatComment(data));
@@ -2,7 +2,6 @@ import { useMemo, useEffect, useContext } from "react";
2
2
  import { styled } from "@arcblock/ux/lib/Theme";
3
3
  import joinUrl from "url-join";
4
4
  import PropTypes from "prop-types";
5
- import { useAsyncRetry } from "react-use";
6
5
  import SessionManager from "@arcblock/did-connect/lib/SessionManager";
7
6
  import { SessionContext } from "@arcblock/did-connect/lib/Session";
8
7
  import Button from "@arcblock/ux/lib/Button";
@@ -12,11 +11,22 @@ import ButtonGroup from "@mui/material/ButtonGroup";
12
11
  import { useLocaleContext, LocaleProvider } from "@arcblock/ux/lib/Locale/context";
13
12
  import { ErrorBoundary } from "react-error-boundary";
14
13
  import { InternalThemeProvider, DefaultEditorConfigProvider, CommentsProvider, useCommentsContext, BinaryThumb, CommentInput, CommentList } from "@blocklet/discuss-kit-ux";
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
18
  import api, { fetchRatingStats } from "./api";
19
19
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
20
+ const useAsyncRetry = (fn, deps = []) => {
21
+ const state = useRequest(fn, {
22
+ refreshDeps: deps
23
+ });
24
+ return {
25
+ ...state,
26
+ value: state == null ? void 0 : state.data,
27
+ retry: state == null ? void 0 : state.run
28
+ };
29
+ };
20
30
  const getPrefix = () => {
21
31
  var _a, _b;
22
32
  const service = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find((x) => x.name === "did-comments");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit",
3
- "version": "1.5.56",
3
+ "version": "1.5.58",
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,14 +37,15 @@
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.56",
41
- "@blocklet/editor": "1.5.56",
40
+ "@blocklet/discuss-kit-ux": "1.5.58",
41
+ "@blocklet/editor": "1.5.58",
42
42
  "@emotion/react": "^11.10.5",
43
43
  "@emotion/styled": "^11.10.5",
44
44
  "@mui/icons-material": "^5.14.3",
45
45
  "@mui/lab": "^5.0.0-alpha.139",
46
46
  "@mui/material": "^5.14.4",
47
47
  "@uiw/react-md-editor": "^3.19.7",
48
+ "ahooks": "^3.7.8",
48
49
  "axios": "^0.27.2",
49
50
  "clsx": "^1.2.1",
50
51
  "flat": "^5.0.2",
@@ -52,7 +53,6 @@
52
53
  "lodash": "^4.17.21",
53
54
  "prop-types": "^15.8.1",
54
55
  "react-error-boundary": "^3.1.4",
55
- "react-use": "^17.4.0",
56
56
  "rehype-sanitize": "^5.0.1",
57
57
  "timeago.js": "^4.0.2",
58
58
  "uppload": "^3.2.1",
@@ -77,5 +77,5 @@
77
77
  "vite-plugin-build": "^0.7.1",
78
78
  "vite-plugin-svgr": "^2.2.2"
79
79
  },
80
- "gitHead": "f0421c3bc64908662a3473dca07931971aca5228"
80
+ "gitHead": "dafd7ca06e1dc8fb39f221bb2977899d20c1ae8b"
81
81
  }