Last active
October 28, 2021 20:18
-
-
Save matinzd/eec72b3cf30a58239e90a3f742374f37 to your computer and use it in GitHub Desktop.
Delete comment patch beta 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/@amityco/ts-sdk/dist/index.cjs.js b/node_modules/@amityco/ts-sdk/dist/index.cjs.js | |
index 592dbad..4cee65c 100644 | |
--- a/node_modules/@amityco/ts-sdk/dist/index.cjs.js | |
+++ b/node_modules/@amityco/ts-sdk/dist/index.cjs.js | |
@@ -2993,9 +2993,9 @@ const removeCommunityMembersRole = async (communityId, roleId, userIds) => { | |
* @async | |
*/ | |
const deletePost = async (postId, permanent = false) => { | |
- var _a; | |
const client = getActiveClient(); | |
client.log('post/deletePost', postId); | |
+ const deleted = await getPost(postId); | |
// API-FIX: This endpoint has not been implemented yet. | |
await client.http.delete(`/api/v4/posts/${postId}`, { | |
params: { | |
@@ -3003,21 +3003,7 @@ const deletePost = async (postId, permanent = false) => { | |
permanent, | |
}, | |
}); | |
- let deleted; | |
- try { | |
- // API-FIX: as for now we have no choice but to refetch | |
- deleted = await getPost(postId); | |
- } | |
- catch (error) { | |
- if (((_a = error) === null || _a === void 0 ? void 0 : _a.code) === 400400 /* ITEM_NOT_FOUND */) { | |
- // there is currently a limitation which doesnt allow us to fire event to tell that community | |
- // has been updated. reason is that, when the object is deleted, we don't have its `communityId` | |
- // and so we cannot refetch the community or advertise on events. hopefully this should be solved | |
- // later when realtime events covers that for us. | |
- return { success: true }; | |
- } | |
- throw (error); | |
- } | |
+ | |
if (deleted.targetType === 'community') { | |
const community = await getCommunity(deleted.targetId); | |
fireEvent('v3.community.didUpdate', { communities: [community] }); | |
@@ -3309,9 +3295,10 @@ const updateComment = async (commentId, patch) => { | |
* @async | |
*/ | |
const deleteComment = async (commentId, permanent = false) => { | |
- var _a; | |
const client = getActiveClient(); | |
client.log('comment/deleteComment', commentId); | |
+ // API-FIX: as for now we have no choice but to refetch | |
+ const deleted = await getComment(commentId); | |
// API-FIX: This endpoint has not been implemented yet. | |
await client.http.delete(`/api/v4/comments/${commentId}`, { | |
params: { | |
@@ -3319,21 +3306,7 @@ const deleteComment = async (commentId, permanent = false) => { | |
permanent, | |
}, | |
}); | |
- let deleted; | |
- try { | |
- // API-FIX: as for now we have no choice but to refetch | |
- deleted = await getComment(commentId); | |
- } | |
- catch (error) { | |
- if (((_a = error) === null || _a === void 0 ? void 0 : _a.code) === 400400 /* ITEM_NOT_FOUND */) { | |
- // there is currently a limitation which doesnt allow us to fire event to tell that post | |
- // has been updated. reason is that, when the object is deleted, we don't have its `postId` | |
- // and so we cannot refetch the post or advertise on events. hopefully this should be solved | |
- // later when realtime events covers that for us. | |
- return { success: true }; | |
- } | |
- throw (error); | |
- } | |
+ | |
const post = await getPost(deleted.referenceId); | |
fireEvent('v3.post.didUpdate', { posts: [post] }); | |
fireEvent('v3.comment.didDelete', { comments: [deleted] }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment