@blocklet/discuss-kit 2.1.143 → 2.1.144

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.
@@ -15,6 +15,7 @@ const ErrorFallback = require("./components/error-fallback");
15
15
  const locales = require("./locales");
16
16
  const utils = require("./lib/utils");
17
17
  const api = require("./api");
18
+ const topicInfoSync = require("./hooks/topic-info-sync");
18
19
  const useAsyncRetry = (fn, deps = []) => {
19
20
  const state = ahooks.useRequest(fn, { refreshDeps: deps });
20
21
  return { ...state, value: state == null ? void 0 : state.data, retry: state == null ? void 0 : state.run };
@@ -129,6 +130,7 @@ const DiscussKitComments = react.forwardRef(
129
130
  const { total, order, initialized } = state;
130
131
  const { t } = context.useLocaleContext();
131
132
  const objectRatingState = useAsyncRetry(() => api.fetchRatings(object.id));
133
+ topicInfoSync.useTopicInfoSync(object);
132
134
  const handlers = {
133
135
  ADD_COMMENT: (data) => {
134
136
  add(formatComment(data));
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const request = require("../api");
5
+ const useTopicInfoSync = (options) => {
6
+ react.useEffect(() => {
7
+ const sync = () => {
8
+ request.put(`/comments/topics/${options.id}`, {
9
+ title: options.title,
10
+ link: options.link
11
+ }).catch((err) => {
12
+ console.error(err);
13
+ });
14
+ };
15
+ sync();
16
+ }, []);
17
+ };
18
+ exports.useTopicInfoSync = useTopicInfoSync;
@@ -14,6 +14,7 @@ import ErrorFallback from "./components/error-fallback";
14
14
  import { translations } from "./locales";
15
15
  import { discussKitPrefix } from "./lib/utils";
16
16
  import api, { fetchRatings } from "./api";
17
+ import { useTopicInfoSync } from "./hooks/topic-info-sync";
17
18
  const useAsyncRetry = (fn, deps = []) => {
18
19
  const state = useRequest(fn, { refreshDeps: deps });
19
20
  return { ...state, value: state == null ? void 0 : state.data, retry: state == null ? void 0 : state.run };
@@ -128,6 +129,7 @@ const DiscussKitComments = forwardRef(
128
129
  const { total, order, initialized } = state;
129
130
  const { t } = useLocaleContext();
130
131
  const objectRatingState = useAsyncRetry(() => fetchRatings(object.id));
132
+ useTopicInfoSync(object);
131
133
  const handlers = {
132
134
  ADD_COMMENT: (data) => {
133
135
  add(formatComment(data));
@@ -0,0 +1,18 @@
1
+ import { useEffect } from "react";
2
+ import request from "../api";
3
+ const useTopicInfoSync = (options) => {
4
+ useEffect(() => {
5
+ const sync = () => {
6
+ request.put(`/comments/topics/${options.id}`, {
7
+ title: options.title,
8
+ link: options.link
9
+ }).catch((err) => {
10
+ console.error(err);
11
+ });
12
+ };
13
+ sync();
14
+ }, []);
15
+ };
16
+ export {
17
+ useTopicInfoSync
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit",
3
- "version": "2.1.143",
3
+ "version": "2.1.144",
4
4
  "description": "A react component for Discuss Kit blocklet.",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/es/index.js",
@@ -49,8 +49,8 @@
49
49
  "rehype-sanitize": "^5.0.1",
50
50
  "timeago.js": "^4.0.2",
51
51
  "url-join": "^4.0.1",
52
- "@blocklet/discuss-kit-ux": "^2.1.143",
53
- "@blocklet/editor": "^2.1.143"
52
+ "@blocklet/discuss-kit-ux": "^2.1.144",
53
+ "@blocklet/editor": "^2.1.144"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@arcblock/did-connect": "^2.10.36",