@amityco/ts-sdk 0.0.1-73c3ccf.0 → 0.0.1-79eb069.0
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/dist/comment/api/deleteComment.d.ts +35 -2
- package/dist/comment/api/deleteComment.d.ts.map +1 -1
- package/dist/index.cjs.js +29 -35
- package/dist/index.esm.js +29 -35
- package/dist/index.umd.js +29 -35
- package/dist/post/api/deletePost.d.ts +38 -2
- package/dist/post/api/deletePost.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/comment/api/deleteComment.ts +15 -18
- package/src/post/api/deletePost.ts +20 -20
|
@@ -12,7 +12,40 @@
|
|
|
12
12
|
* @category Comment API
|
|
13
13
|
* @async
|
|
14
14
|
*/
|
|
15
|
-
export declare const deleteComment: (commentId: Amity.Comment['commentId'], permanent?: boolean) => Promise<
|
|
16
|
-
|
|
15
|
+
export declare const deleteComment: (commentId: Amity.Comment['commentId'], permanent?: boolean) => Promise<{
|
|
16
|
+
isDeleted: boolean;
|
|
17
|
+
commentId: string;
|
|
18
|
+
userId: string;
|
|
19
|
+
parentId?: string | undefined;
|
|
20
|
+
rootId: string;
|
|
21
|
+
childrenNumber: number;
|
|
22
|
+
children: string[];
|
|
23
|
+
segmentNumber: number;
|
|
24
|
+
referenceId: string;
|
|
25
|
+
referenceType: Amity.CommentReferenceType;
|
|
26
|
+
dataType?: any;
|
|
27
|
+
data: any;
|
|
28
|
+
metadata?: Record<string, any> | undefined;
|
|
29
|
+
flagCount: number;
|
|
30
|
+
hashFlag: {
|
|
31
|
+
bits: number;
|
|
32
|
+
hashes: number;
|
|
33
|
+
hash: string;
|
|
34
|
+
} | null;
|
|
35
|
+
reactionsCount: number;
|
|
36
|
+
reactions: Record<string, number>;
|
|
37
|
+
myReactions?: string[] | undefined;
|
|
38
|
+
latestReaction?: ({
|
|
39
|
+
reactionId: string;
|
|
40
|
+
userId: string;
|
|
41
|
+
reactionName: string;
|
|
42
|
+
} & Amity.CreatedAt & Amity.Relationship<Amity.ReactableType> & {
|
|
43
|
+
eventName: "added" | "removed";
|
|
44
|
+
}) | undefined;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt?: string | undefined;
|
|
47
|
+
deletedAt?: string | undefined;
|
|
48
|
+
localId: string;
|
|
49
|
+
syncedAt: number;
|
|
17
50
|
}>;
|
|
18
51
|
//# sourceMappingURL=deleteComment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteComment.d.ts","sourceRoot":"","sources":["../../../src/comment/api/deleteComment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deleteComment.d.ts","sourceRoot":"","sources":["../../../src/comment/api/deleteComment.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,cACb,aAAa,CAAC,WAAW,CAAC,cAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCnB,CAAA"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -2993,9 +2993,9 @@ const removeCommunityMembersRole = async (communityId, roleId, userIds) => {
|
|
|
2993
2993
|
* @async
|
|
2994
2994
|
*/
|
|
2995
2995
|
const deletePost = async (postId, permanent = false) => {
|
|
2996
|
-
var _a;
|
|
2997
2996
|
const client = getActiveClient();
|
|
2998
2997
|
client.log('post/deletePost', postId);
|
|
2998
|
+
let post = await getPost(postId);
|
|
2999
2999
|
// API-FIX: This endpoint has not been implemented yet.
|
|
3000
3000
|
await client.http.delete(`/api/v4/posts/${postId}`, {
|
|
3001
3001
|
params: {
|
|
@@ -3003,26 +3003,25 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
3003
3003
|
permanent,
|
|
3004
3004
|
},
|
|
3005
3005
|
});
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
if (((_a = error) === null || _a === void 0 ? void 0 : _a.code) === 400400 /* ITEM_NOT_FOUND */) {
|
|
3013
|
-
// there is currently a limitation which doesnt allow us to fire event to tell that community
|
|
3014
|
-
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
3015
|
-
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
3016
|
-
// later when realtime events covers that for us.
|
|
3017
|
-
return { success: true };
|
|
3018
|
-
}
|
|
3019
|
-
throw (error);
|
|
3020
|
-
}
|
|
3021
|
-
if (deleted.targetType === 'community') {
|
|
3022
|
-
const community = await getCommunity(deleted.targetId);
|
|
3006
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
3007
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
3008
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
3009
|
+
// later when realtime events covers that for us.
|
|
3010
|
+
if (post.targetType === 'community') {
|
|
3011
|
+
const community = await getCommunity(post.targetId);
|
|
3023
3012
|
fireEvent('v3.community.didUpdate', { communities: [community] });
|
|
3024
3013
|
}
|
|
3014
|
+
// to support hard deletion
|
|
3015
|
+
const deleted = Object.assign(Object.assign({}, post), { isDeleted: true });
|
|
3025
3016
|
fireEvent('v3.post.didDelete', { posts: [deleted] });
|
|
3017
|
+
if (permanent) {
|
|
3018
|
+
setTimeout(() => {
|
|
3019
|
+
dropFromCache('post', { postId });
|
|
3020
|
+
}, 0);
|
|
3021
|
+
}
|
|
3022
|
+
else {
|
|
3023
|
+
mergeInCache('post', { postId, isDeleted: true });
|
|
3024
|
+
}
|
|
3026
3025
|
return deleted;
|
|
3027
3026
|
};
|
|
3028
3027
|
|
|
@@ -3309,9 +3308,9 @@ const updateComment = async (commentId, patch) => {
|
|
|
3309
3308
|
* @async
|
|
3310
3309
|
*/
|
|
3311
3310
|
const deleteComment = async (commentId, permanent = false) => {
|
|
3312
|
-
var _a;
|
|
3313
3311
|
const client = getActiveClient();
|
|
3314
3312
|
client.log('comment/deleteComment', commentId);
|
|
3313
|
+
const comment = await getComment(commentId);
|
|
3315
3314
|
// API-FIX: This endpoint has not been implemented yet.
|
|
3316
3315
|
await client.http.delete(`/api/v4/comments/${commentId}`, {
|
|
3317
3316
|
params: {
|
|
@@ -3319,24 +3318,19 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
3319
3318
|
permanent,
|
|
3320
3319
|
},
|
|
3321
3320
|
});
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
deleted = await getComment(commentId);
|
|
3326
|
-
}
|
|
3327
|
-
catch (error) {
|
|
3328
|
-
if (((_a = error) === null || _a === void 0 ? void 0 : _a.code) === 400400 /* ITEM_NOT_FOUND */) {
|
|
3329
|
-
// there is currently a limitation which doesnt allow us to fire event to tell that post
|
|
3330
|
-
// has been updated. reason is that, when the object is deleted, we don't have its `postId`
|
|
3331
|
-
// and so we cannot refetch the post or advertise on events. hopefully this should be solved
|
|
3332
|
-
// later when realtime events covers that for us.
|
|
3333
|
-
return { success: true };
|
|
3334
|
-
}
|
|
3335
|
-
throw (error);
|
|
3336
|
-
}
|
|
3337
|
-
const post = await getPost(deleted.referenceId);
|
|
3321
|
+
// to support hard deletion
|
|
3322
|
+
const deleted = Object.assign(Object.assign({}, comment), { isDeleted: true });
|
|
3323
|
+
const post = await getPost(comment.referenceId);
|
|
3338
3324
|
fireEvent('v3.post.didUpdate', { posts: [post] });
|
|
3339
3325
|
fireEvent('v3.comment.didDelete', { comments: [deleted] });
|
|
3326
|
+
if (permanent) {
|
|
3327
|
+
setTimeout(() => {
|
|
3328
|
+
dropFromCache('comment', { commentId });
|
|
3329
|
+
}, 0);
|
|
3330
|
+
}
|
|
3331
|
+
else {
|
|
3332
|
+
mergeInCache('comment', { commentId, isDeleted: true });
|
|
3333
|
+
}
|
|
3340
3334
|
return deleted;
|
|
3341
3335
|
};
|
|
3342
3336
|
|
package/dist/index.esm.js
CHANGED
|
@@ -2979,9 +2979,9 @@ const removeCommunityMembersRole = async (communityId, roleId, userIds) => {
|
|
|
2979
2979
|
* @async
|
|
2980
2980
|
*/
|
|
2981
2981
|
const deletePost = async (postId, permanent = false) => {
|
|
2982
|
-
var _a;
|
|
2983
2982
|
const client = getActiveClient();
|
|
2984
2983
|
client.log('post/deletePost', postId);
|
|
2984
|
+
let post = await getPost(postId);
|
|
2985
2985
|
// API-FIX: This endpoint has not been implemented yet.
|
|
2986
2986
|
await client.http.delete(`/api/v4/posts/${postId}`, {
|
|
2987
2987
|
params: {
|
|
@@ -2989,26 +2989,25 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
2989
2989
|
permanent,
|
|
2990
2990
|
},
|
|
2991
2991
|
});
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
if (((_a = error) === null || _a === void 0 ? void 0 : _a.code) === 400400 /* ITEM_NOT_FOUND */) {
|
|
2999
|
-
// there is currently a limitation which doesnt allow us to fire event to tell that community
|
|
3000
|
-
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
3001
|
-
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
3002
|
-
// later when realtime events covers that for us.
|
|
3003
|
-
return { success: true };
|
|
3004
|
-
}
|
|
3005
|
-
throw (error);
|
|
3006
|
-
}
|
|
3007
|
-
if (deleted.targetType === 'community') {
|
|
3008
|
-
const community = await getCommunity(deleted.targetId);
|
|
2992
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
2993
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
2994
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
2995
|
+
// later when realtime events covers that for us.
|
|
2996
|
+
if (post.targetType === 'community') {
|
|
2997
|
+
const community = await getCommunity(post.targetId);
|
|
3009
2998
|
fireEvent('v3.community.didUpdate', { communities: [community] });
|
|
3010
2999
|
}
|
|
3000
|
+
// to support hard deletion
|
|
3001
|
+
const deleted = Object.assign(Object.assign({}, post), { isDeleted: true });
|
|
3011
3002
|
fireEvent('v3.post.didDelete', { posts: [deleted] });
|
|
3003
|
+
if (permanent) {
|
|
3004
|
+
setTimeout(() => {
|
|
3005
|
+
dropFromCache('post', { postId });
|
|
3006
|
+
}, 0);
|
|
3007
|
+
}
|
|
3008
|
+
else {
|
|
3009
|
+
mergeInCache('post', { postId, isDeleted: true });
|
|
3010
|
+
}
|
|
3012
3011
|
return deleted;
|
|
3013
3012
|
};
|
|
3014
3013
|
|
|
@@ -3295,9 +3294,9 @@ const updateComment = async (commentId, patch) => {
|
|
|
3295
3294
|
* @async
|
|
3296
3295
|
*/
|
|
3297
3296
|
const deleteComment = async (commentId, permanent = false) => {
|
|
3298
|
-
var _a;
|
|
3299
3297
|
const client = getActiveClient();
|
|
3300
3298
|
client.log('comment/deleteComment', commentId);
|
|
3299
|
+
const comment = await getComment(commentId);
|
|
3301
3300
|
// API-FIX: This endpoint has not been implemented yet.
|
|
3302
3301
|
await client.http.delete(`/api/v4/comments/${commentId}`, {
|
|
3303
3302
|
params: {
|
|
@@ -3305,24 +3304,19 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
3305
3304
|
permanent,
|
|
3306
3305
|
},
|
|
3307
3306
|
});
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
deleted = await getComment(commentId);
|
|
3312
|
-
}
|
|
3313
|
-
catch (error) {
|
|
3314
|
-
if (((_a = error) === null || _a === void 0 ? void 0 : _a.code) === 400400 /* ITEM_NOT_FOUND */) {
|
|
3315
|
-
// there is currently a limitation which doesnt allow us to fire event to tell that post
|
|
3316
|
-
// has been updated. reason is that, when the object is deleted, we don't have its `postId`
|
|
3317
|
-
// and so we cannot refetch the post or advertise on events. hopefully this should be solved
|
|
3318
|
-
// later when realtime events covers that for us.
|
|
3319
|
-
return { success: true };
|
|
3320
|
-
}
|
|
3321
|
-
throw (error);
|
|
3322
|
-
}
|
|
3323
|
-
const post = await getPost(deleted.referenceId);
|
|
3307
|
+
// to support hard deletion
|
|
3308
|
+
const deleted = Object.assign(Object.assign({}, comment), { isDeleted: true });
|
|
3309
|
+
const post = await getPost(comment.referenceId);
|
|
3324
3310
|
fireEvent('v3.post.didUpdate', { posts: [post] });
|
|
3325
3311
|
fireEvent('v3.comment.didDelete', { comments: [deleted] });
|
|
3312
|
+
if (permanent) {
|
|
3313
|
+
setTimeout(() => {
|
|
3314
|
+
dropFromCache('comment', { commentId });
|
|
3315
|
+
}, 0);
|
|
3316
|
+
}
|
|
3317
|
+
else {
|
|
3318
|
+
mergeInCache('comment', { commentId, isDeleted: true });
|
|
3319
|
+
}
|
|
3326
3320
|
return deleted;
|
|
3327
3321
|
};
|
|
3328
3322
|
|
package/dist/index.umd.js
CHANGED
|
@@ -2983,9 +2983,9 @@ var Amity = (function (exports, jsBase64, nativeIdGenerator, debug, axios, HttpA
|
|
|
2983
2983
|
* @async
|
|
2984
2984
|
*/
|
|
2985
2985
|
const deletePost = async (postId, permanent = false) => {
|
|
2986
|
-
var _a;
|
|
2987
2986
|
const client = getActiveClient();
|
|
2988
2987
|
client.log('post/deletePost', postId);
|
|
2988
|
+
let post = await getPost(postId);
|
|
2989
2989
|
// API-FIX: This endpoint has not been implemented yet.
|
|
2990
2990
|
await client.http.delete(`/api/v4/posts/${postId}`, {
|
|
2991
2991
|
params: {
|
|
@@ -2993,26 +2993,25 @@ var Amity = (function (exports, jsBase64, nativeIdGenerator, debug, axios, HttpA
|
|
|
2993
2993
|
permanent,
|
|
2994
2994
|
},
|
|
2995
2995
|
});
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
if (((_a = error) === null || _a === void 0 ? void 0 : _a.code) === 400400 /* ITEM_NOT_FOUND */) {
|
|
3003
|
-
// there is currently a limitation which doesnt allow us to fire event to tell that community
|
|
3004
|
-
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
3005
|
-
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
3006
|
-
// later when realtime events covers that for us.
|
|
3007
|
-
return { success: true };
|
|
3008
|
-
}
|
|
3009
|
-
throw (error);
|
|
3010
|
-
}
|
|
3011
|
-
if (deleted.targetType === 'community') {
|
|
3012
|
-
const community = await getCommunity(deleted.targetId);
|
|
2996
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
2997
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
2998
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
2999
|
+
// later when realtime events covers that for us.
|
|
3000
|
+
if (post.targetType === 'community') {
|
|
3001
|
+
const community = await getCommunity(post.targetId);
|
|
3013
3002
|
fireEvent('v3.community.didUpdate', { communities: [community] });
|
|
3014
3003
|
}
|
|
3004
|
+
// to support hard deletion
|
|
3005
|
+
const deleted = Object.assign(Object.assign({}, post), { isDeleted: true });
|
|
3015
3006
|
fireEvent('v3.post.didDelete', { posts: [deleted] });
|
|
3007
|
+
if (permanent) {
|
|
3008
|
+
setTimeout(() => {
|
|
3009
|
+
dropFromCache('post', { postId });
|
|
3010
|
+
}, 0);
|
|
3011
|
+
}
|
|
3012
|
+
else {
|
|
3013
|
+
mergeInCache('post', { postId, isDeleted: true });
|
|
3014
|
+
}
|
|
3016
3015
|
return deleted;
|
|
3017
3016
|
};
|
|
3018
3017
|
|
|
@@ -3299,9 +3298,9 @@ var Amity = (function (exports, jsBase64, nativeIdGenerator, debug, axios, HttpA
|
|
|
3299
3298
|
* @async
|
|
3300
3299
|
*/
|
|
3301
3300
|
const deleteComment = async (commentId, permanent = false) => {
|
|
3302
|
-
var _a;
|
|
3303
3301
|
const client = getActiveClient();
|
|
3304
3302
|
client.log('comment/deleteComment', commentId);
|
|
3303
|
+
const comment = await getComment(commentId);
|
|
3305
3304
|
// API-FIX: This endpoint has not been implemented yet.
|
|
3306
3305
|
await client.http.delete(`/api/v4/comments/${commentId}`, {
|
|
3307
3306
|
params: {
|
|
@@ -3309,24 +3308,19 @@ var Amity = (function (exports, jsBase64, nativeIdGenerator, debug, axios, HttpA
|
|
|
3309
3308
|
permanent,
|
|
3310
3309
|
},
|
|
3311
3310
|
});
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
deleted = await getComment(commentId);
|
|
3316
|
-
}
|
|
3317
|
-
catch (error) {
|
|
3318
|
-
if (((_a = error) === null || _a === void 0 ? void 0 : _a.code) === 400400 /* ITEM_NOT_FOUND */) {
|
|
3319
|
-
// there is currently a limitation which doesnt allow us to fire event to tell that post
|
|
3320
|
-
// has been updated. reason is that, when the object is deleted, we don't have its `postId`
|
|
3321
|
-
// and so we cannot refetch the post or advertise on events. hopefully this should be solved
|
|
3322
|
-
// later when realtime events covers that for us.
|
|
3323
|
-
return { success: true };
|
|
3324
|
-
}
|
|
3325
|
-
throw (error);
|
|
3326
|
-
}
|
|
3327
|
-
const post = await getPost(deleted.referenceId);
|
|
3311
|
+
// to support hard deletion
|
|
3312
|
+
const deleted = Object.assign(Object.assign({}, comment), { isDeleted: true });
|
|
3313
|
+
const post = await getPost(comment.referenceId);
|
|
3328
3314
|
fireEvent('v3.post.didUpdate', { posts: [post] });
|
|
3329
3315
|
fireEvent('v3.comment.didDelete', { comments: [deleted] });
|
|
3316
|
+
if (permanent) {
|
|
3317
|
+
setTimeout(() => {
|
|
3318
|
+
dropFromCache('comment', { commentId });
|
|
3319
|
+
}, 0);
|
|
3320
|
+
}
|
|
3321
|
+
else {
|
|
3322
|
+
mergeInCache('comment', { commentId, isDeleted: true });
|
|
3323
|
+
}
|
|
3330
3324
|
return deleted;
|
|
3331
3325
|
};
|
|
3332
3326
|
|
|
@@ -12,7 +12,43 @@
|
|
|
12
12
|
* @category Post API
|
|
13
13
|
* @async
|
|
14
14
|
*/
|
|
15
|
-
export declare const deletePost: (postId: Amity.Post['postId'], permanent?: boolean) => Promise<
|
|
16
|
-
|
|
15
|
+
export declare const deletePost: (postId: Amity.Post['postId'], permanent?: boolean) => Promise<{
|
|
16
|
+
isDeleted: boolean;
|
|
17
|
+
postId: string;
|
|
18
|
+
postedUserId: string;
|
|
19
|
+
parentId: string;
|
|
20
|
+
targetType: Amity.PostTargetType;
|
|
21
|
+
targetId: string;
|
|
22
|
+
feedId: string;
|
|
23
|
+
children: string[];
|
|
24
|
+
comments: string[];
|
|
25
|
+
commentsCount: number;
|
|
26
|
+
hasFlaggedChildren: false;
|
|
27
|
+
hasFlaggedComment: false;
|
|
28
|
+
editedAt: string;
|
|
29
|
+
dataType?: any;
|
|
30
|
+
data: any;
|
|
31
|
+
metadata?: Record<string, any> | undefined;
|
|
32
|
+
flagCount: number;
|
|
33
|
+
hashFlag: {
|
|
34
|
+
bits: number;
|
|
35
|
+
hashes: number;
|
|
36
|
+
hash: string;
|
|
37
|
+
} | null;
|
|
38
|
+
reactionsCount: number;
|
|
39
|
+
reactions: Record<string, number>;
|
|
40
|
+
myReactions?: string[] | undefined;
|
|
41
|
+
latestReaction?: ({
|
|
42
|
+
reactionId: string;
|
|
43
|
+
userId: string;
|
|
44
|
+
reactionName: string;
|
|
45
|
+
} & Amity.CreatedAt & Amity.Relationship<Amity.ReactableType> & {
|
|
46
|
+
eventName: "added" | "removed";
|
|
47
|
+
}) | undefined;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
updatedAt?: string | undefined;
|
|
50
|
+
deletedAt?: string | undefined;
|
|
51
|
+
localId: string;
|
|
52
|
+
syncedAt: number;
|
|
17
53
|
}>;
|
|
18
54
|
//# sourceMappingURL=deletePost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deletePost.d.ts","sourceRoot":"","sources":["../../../src/post/api/deletePost.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deletePost.d.ts","sourceRoot":"","sources":["../../../src/post/api/deletePost.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,WACb,MAAM,IAAI,CAAC,QAAQ,CAAC,cACjB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCnB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api'
|
|
2
2
|
import { fireEvent } from '~/core/events'
|
|
3
|
+
import { dropFromCache, mergeInCache } from '~/core/cache'
|
|
3
4
|
|
|
4
5
|
import { getComment } from './getComment'
|
|
5
6
|
|
|
@@ -26,6 +27,8 @@ export const deleteComment = async (
|
|
|
26
27
|
const client = getActiveClient()
|
|
27
28
|
client.log('comment/deleteComment', commentId)
|
|
28
29
|
|
|
30
|
+
const comment = await getComment(commentId)
|
|
31
|
+
|
|
29
32
|
// API-FIX: This endpoint has not been implemented yet.
|
|
30
33
|
await client.http.delete<{ success: boolean }>(
|
|
31
34
|
`/api/v4/comments/${commentId}`, {
|
|
@@ -36,28 +39,22 @@ export const deleteComment = async (
|
|
|
36
39
|
},
|
|
37
40
|
)
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
// API-FIX: as for now we have no choice but to refetch
|
|
43
|
-
deleted = await getComment(commentId)
|
|
44
|
-
} catch (error) {
|
|
45
|
-
if ((error as Amity.ErrorResponse)?.code === Amity.ServerError.ITEM_NOT_FOUND) {
|
|
46
|
-
// there is currently a limitation which doesnt allow us to fire event to tell that post
|
|
47
|
-
// has been updated. reason is that, when the object is deleted, we don't have its `postId`
|
|
48
|
-
// and so we cannot refetch the post or advertise on events. hopefully this should be solved
|
|
49
|
-
// later when realtime events covers that for us.
|
|
50
|
-
|
|
51
|
-
return { success: true }
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
throw(error);
|
|
55
|
-
}
|
|
42
|
+
// to support hard deletion
|
|
43
|
+
const deleted = { ...comment, isDeleted: true }
|
|
56
44
|
|
|
57
|
-
const post = await getPost(
|
|
45
|
+
const post = await getPost(comment.referenceId)
|
|
58
46
|
|
|
59
47
|
fireEvent('v3.post.didUpdate', { posts: [post] })
|
|
60
48
|
fireEvent('v3.comment.didDelete', { comments: [deleted] })
|
|
61
49
|
|
|
50
|
+
|
|
51
|
+
if (permanent) {
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
dropFromCache('comment', {commentId})
|
|
54
|
+
}, 0)
|
|
55
|
+
} else {
|
|
56
|
+
mergeInCache('comment', {commentId, isDeleted: true})
|
|
57
|
+
}
|
|
58
|
+
|
|
62
59
|
return deleted
|
|
63
60
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api'
|
|
2
2
|
import { getCommunity } from '~/community/api'
|
|
3
3
|
import { fireEvent } from '~/core/events'
|
|
4
|
+
import { dropFromCache, mergeInCache } from '~/core/cache'
|
|
4
5
|
|
|
5
6
|
import { getPost } from './getPost'
|
|
6
7
|
|
|
@@ -25,6 +26,8 @@ export const deletePost = async (
|
|
|
25
26
|
const client = getActiveClient()
|
|
26
27
|
client.log('post/deletePost', postId)
|
|
27
28
|
|
|
29
|
+
let post = await getPost(postId)
|
|
30
|
+
|
|
28
31
|
// API-FIX: This endpoint has not been implemented yet.
|
|
29
32
|
await client.http.delete<{ success: boolean }>(
|
|
30
33
|
`/api/v4/posts/${postId}`, {
|
|
@@ -35,30 +38,27 @@ export const deletePost = async (
|
|
|
35
38
|
},
|
|
36
39
|
)
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if ((error as Amity.ErrorResponse)?.code === Amity.ServerError.ITEM_NOT_FOUND) {
|
|
45
|
-
// there is currently a limitation which doesnt allow us to fire event to tell that community
|
|
46
|
-
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
47
|
-
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
48
|
-
// later when realtime events covers that for us.
|
|
49
|
-
|
|
50
|
-
return { success: true }
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
throw(error);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (deleted.targetType === 'community') {
|
|
57
|
-
const community = await getCommunity(deleted.targetId);
|
|
41
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
42
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
43
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
44
|
+
// later when realtime events covers that for us.
|
|
45
|
+
if (post.targetType === 'community') {
|
|
46
|
+
const community = await getCommunity(post.targetId);
|
|
58
47
|
fireEvent('v3.community.didUpdate', { communities: [community] })
|
|
59
48
|
}
|
|
60
49
|
|
|
50
|
+
// to support hard deletion
|
|
51
|
+
const deleted = { ...post, isDeleted: true }
|
|
52
|
+
|
|
61
53
|
fireEvent('v3.post.didDelete', { posts: [deleted] })
|
|
62
54
|
|
|
55
|
+
if (permanent) {
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
dropFromCache('post', {postId})
|
|
58
|
+
}, 0)
|
|
59
|
+
} else {
|
|
60
|
+
mergeInCache('post', {postId, isDeleted: true})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
63
|
return deleted
|
|
64
64
|
}
|