@blocklet/discuss-kit 2.1.105 → 2.1.107
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 +12 -0
- package/lib/es/comments.js +12 -0
- package/package.json +3 -3
package/lib/cjs/comments.js
CHANGED
|
@@ -38,6 +38,7 @@ const formatComment = (comment) => {
|
|
|
38
38
|
createdAt: comment.createdAt ? new Date(comment.createdAt) : null,
|
|
39
39
|
updatedAt: comment.updatedAt ? new Date(comment.updatedAt) : null,
|
|
40
40
|
deletedAt: comment.deletedAt ? new Date(comment.deletedAt) : null,
|
|
41
|
+
pinnedAt: comment.pinnedAt ? new Date(comment.pinnedAt) : null,
|
|
41
42
|
replies: (_a = comment.replies) == null ? void 0 : _a.map(formatComment)
|
|
42
43
|
};
|
|
43
44
|
};
|
|
@@ -53,6 +54,10 @@ const commentAPI = {
|
|
|
53
54
|
} = await api.get("/comments", { params: copy });
|
|
54
55
|
return { data: data == null ? void 0 : data.map(formatComment), nextCursor, total };
|
|
55
56
|
},
|
|
57
|
+
fetchPinnedComments: async (objectId) => {
|
|
58
|
+
const { data } = await api.get("/comments/pinned", { params: { objectId } });
|
|
59
|
+
return ((data == null ? void 0 : data.data) || []).map(formatComment);
|
|
60
|
+
},
|
|
56
61
|
fetchCommentPosition: async ({ id, ...params }) => {
|
|
57
62
|
const { data } = await api.get(`/comments/${id}/position`, { params });
|
|
58
63
|
return data;
|
|
@@ -82,6 +87,13 @@ const commentAPI = {
|
|
|
82
87
|
fetchRatings: async (id) => {
|
|
83
88
|
const { data } = await api.get(`/ratings/${id}`);
|
|
84
89
|
return data;
|
|
90
|
+
},
|
|
91
|
+
togglePin: async ({ post, value }) => {
|
|
92
|
+
if (value) {
|
|
93
|
+
await api.put(`/posts/${post.id}/pinned`);
|
|
94
|
+
} else {
|
|
95
|
+
await api.delete(`/posts/${post.id}/pinned`);
|
|
96
|
+
}
|
|
85
97
|
}
|
|
86
98
|
};
|
|
87
99
|
const useDiscussKitStatus = () => {
|
package/lib/es/comments.js
CHANGED
|
@@ -37,6 +37,7 @@ const formatComment = (comment) => {
|
|
|
37
37
|
createdAt: comment.createdAt ? new Date(comment.createdAt) : null,
|
|
38
38
|
updatedAt: comment.updatedAt ? new Date(comment.updatedAt) : null,
|
|
39
39
|
deletedAt: comment.deletedAt ? new Date(comment.deletedAt) : null,
|
|
40
|
+
pinnedAt: comment.pinnedAt ? new Date(comment.pinnedAt) : null,
|
|
40
41
|
replies: (_a = comment.replies) == null ? void 0 : _a.map(formatComment)
|
|
41
42
|
};
|
|
42
43
|
};
|
|
@@ -52,6 +53,10 @@ const commentAPI = {
|
|
|
52
53
|
} = await api.get("/comments", { params: copy });
|
|
53
54
|
return { data: data == null ? void 0 : data.map(formatComment), nextCursor, total };
|
|
54
55
|
},
|
|
56
|
+
fetchPinnedComments: async (objectId) => {
|
|
57
|
+
const { data } = await api.get("/comments/pinned", { params: { objectId } });
|
|
58
|
+
return ((data == null ? void 0 : data.data) || []).map(formatComment);
|
|
59
|
+
},
|
|
55
60
|
fetchCommentPosition: async ({ id, ...params }) => {
|
|
56
61
|
const { data } = await api.get(`/comments/${id}/position`, { params });
|
|
57
62
|
return data;
|
|
@@ -81,6 +86,13 @@ const commentAPI = {
|
|
|
81
86
|
fetchRatings: async (id) => {
|
|
82
87
|
const { data } = await api.get(`/ratings/${id}`);
|
|
83
88
|
return data;
|
|
89
|
+
},
|
|
90
|
+
togglePin: async ({ post, value }) => {
|
|
91
|
+
if (value) {
|
|
92
|
+
await api.put(`/posts/${post.id}/pinned`);
|
|
93
|
+
} else {
|
|
94
|
+
await api.delete(`/posts/${post.id}/pinned`);
|
|
95
|
+
}
|
|
84
96
|
}
|
|
85
97
|
};
|
|
86
98
|
const useDiscussKitStatus = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.107",
|
|
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.
|
|
53
|
-
"@blocklet/editor": "^2.1.
|
|
52
|
+
"@blocklet/discuss-kit-ux": "^2.1.107",
|
|
53
|
+
"@blocklet/editor": "^2.1.107"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@arcblock/did-connect": "^2.10.36",
|