@blocklet/discuss-kit 1.5.176 → 1.5.177

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.
@@ -102,7 +102,7 @@ function DiscussKitComments({
102
102
  }) {
103
103
  discussKitUx.useDefaultApiErrorHandler({ request: api });
104
104
  const { session } = react.useContext(Session.SessionContext) || {};
105
- const { state, sort, add, updateCommentState, interactive } = discussKitUx.useCommentsContext();
105
+ const { state, sort, add, updateCommentState, interactive, findById } = discussKitUx.useCommentsContext();
106
106
  const { total, order, initialized } = state;
107
107
  const { t } = context.useLocaleContext();
108
108
  const objectRatingState = useAsyncRetry(() => api.fetchRatings(object.id));
@@ -112,11 +112,15 @@ function DiscussKitComments({
112
112
  onChange == null ? void 0 : onChange();
113
113
  },
114
114
  UPDATE_COMMENT: (data) => {
115
- updateCommentState(data.id, (current) => {
116
- current.content = data.content;
117
- current.updatedAt = data.updatedAt;
118
- return current;
119
- });
115
+ const comment = findById(data.id);
116
+ if (comment && comment.content !== data.content) {
117
+ updateCommentState(data.id, (current) => {
118
+ current.content = data.content;
119
+ current.updatedAt = data.updatedAt;
120
+ current.synced = Date.now();
121
+ return current;
122
+ });
123
+ }
120
124
  },
121
125
  RATING: () => objectRatingState.retry(),
122
126
  RATING_COMMENT: async ({ commentId }) => {
@@ -101,7 +101,7 @@ function DiscussKitComments({
101
101
  }) {
102
102
  useDefaultApiErrorHandler({ request: api });
103
103
  const { session } = useContext(SessionContext) || {};
104
- const { state, sort, add, updateCommentState, interactive } = useCommentsContext();
104
+ const { state, sort, add, updateCommentState, interactive, findById } = useCommentsContext();
105
105
  const { total, order, initialized } = state;
106
106
  const { t } = useLocaleContext();
107
107
  const objectRatingState = useAsyncRetry(() => fetchRatings(object.id));
@@ -111,11 +111,15 @@ function DiscussKitComments({
111
111
  onChange == null ? void 0 : onChange();
112
112
  },
113
113
  UPDATE_COMMENT: (data) => {
114
- updateCommentState(data.id, (current) => {
115
- current.content = data.content;
116
- current.updatedAt = data.updatedAt;
117
- return current;
118
- });
114
+ const comment = findById(data.id);
115
+ if (comment && comment.content !== data.content) {
116
+ updateCommentState(data.id, (current) => {
117
+ current.content = data.content;
118
+ current.updatedAt = data.updatedAt;
119
+ current.synced = Date.now();
120
+ return current;
121
+ });
122
+ }
119
123
  },
120
124
  RATING: () => objectRatingState.retry(),
121
125
  RATING_COMMENT: async ({ commentId }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit",
3
- "version": "1.5.176",
3
+ "version": "1.5.177",
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.8.14",
38
38
  "@arcblock/ux": "^2.8.14",
39
39
  "@arcblock/ws": "^1.18.95",
40
- "@blocklet/discuss-kit-ux": "1.5.176",
41
- "@blocklet/editor": "1.5.176",
40
+ "@blocklet/discuss-kit-ux": "1.5.177",
41
+ "@blocklet/editor": "1.5.177",
42
42
  "@emotion/react": "^11.10.5",
43
43
  "@emotion/styled": "^11.10.5",
44
44
  "@mui/icons-material": "^5.14.9",
@@ -77,5 +77,5 @@
77
77
  "vite-plugin-build": "^0.10.0",
78
78
  "vite-plugin-svgr": "^4.1.0"
79
79
  },
80
- "gitHead": "ecc40537d773844660ed1cb039a4cb9b1d2e1066"
80
+ "gitHead": "c453501ad7daa9e9ff2083ce14f0b0f1d71a12a2"
81
81
  }