@amityco/ts-sdk-react-native 7.34.0 → 7.34.1-2c138b60.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/index.cjs.js +49 -9
- package/dist/index.esm.js +49 -9
- package/dist/index.umd.js +1 -1
- package/dist/postRepository/api/editPost.d.ts.map +1 -1
- package/dist/postRepository/api/getPostByIds.d.ts.map +1 -1
- package/dist/postRepository/events/onPostReactionAdded.d.ts.map +1 -1
- package/dist/postRepository/events/onPostReactionRemoved.d.ts.map +1 -1
- package/dist/postRepository/events/tests/reactionCommentCountInterplay.test.d.ts +2 -0
- package/dist/postRepository/events/tests/reactionCommentCountInterplay.test.d.ts.map +1 -0
- package/dist/postRepository/events/tests/reactionKeepsLocalCommentCount.test.d.ts +2 -0
- package/dist/postRepository/events/tests/reactionKeepsLocalCommentCount.test.d.ts.map +1 -0
- package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/observers/tests/getPost.reactionCommentCount.test.d.ts +2 -0
- package/dist/postRepository/observers/tests/getPost.reactionCommentCount.test.d.ts.map +1 -0
- package/dist/postRepository/observers/tests/pinnedPostsCommentCount.test.d.ts +2 -0
- package/dist/postRepository/observers/tests/pinnedPostsCommentCount.test.d.ts.map +1 -0
- package/dist/postRepository/utils/withLocalCommentCount.d.ts +21 -0
- package/dist/postRepository/utils/withLocalCommentCount.d.ts.map +1 -0
- package/dist/reactionRepository/events/onReactorAdded.d.ts.map +1 -1
- package/dist/reactionRepository/events/onReactorRemoved.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -14550,7 +14550,7 @@ const getWatchSessionStorage = () => {
|
|
|
14550
14550
|
return storageInstance;
|
|
14551
14551
|
};
|
|
14552
14552
|
|
|
14553
|
-
const privateKey = "-----BE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ahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
14554
14554
|
/*
|
|
14555
14555
|
* The crypto algorithm used for importing key and signing string
|
|
14556
14556
|
*/
|
|
@@ -19139,6 +19139,42 @@ const onPostFlagged = (callback) => createPostEventSubscriber('post.flagged', ca
|
|
|
19139
19139
|
*/
|
|
19140
19140
|
const onPostUnflagged = (callback) => createPostEventSubscriber('post.unflagged', callback);
|
|
19141
19141
|
|
|
19142
|
+
/**
|
|
19143
|
+
* Carries the session's comment count onto the posts of a raw server payload.
|
|
19144
|
+
*
|
|
19145
|
+
* Reaction events, pinned post queries and a few post APIs deliver the post as the server sees
|
|
19146
|
+
* it, with no `localCommentCount`, and are ingested by replacing the cached post. Without this
|
|
19147
|
+
* the count is dropped from the cache and the post reads as having no comments until it is
|
|
19148
|
+
* fetched again.
|
|
19149
|
+
*
|
|
19150
|
+
* A post the engine already tracks keeps its figure: it is read rather than recomputed, since a
|
|
19151
|
+
* ResetTask would throw away the local delta. A post the engine has not seen yet is seeded from
|
|
19152
|
+
* the payload, the way `preparePostPayload` seeds it; otherwise a post that only ever arrived
|
|
19153
|
+
* here (a pinned post, say) would have no tracker and comments created or deleted in this
|
|
19154
|
+
* session would never move its count.
|
|
19155
|
+
*
|
|
19156
|
+
* @hidden
|
|
19157
|
+
*/
|
|
19158
|
+
const withLocalCommentCount = (payload) => {
|
|
19159
|
+
if (!payload.posts)
|
|
19160
|
+
return payload;
|
|
19161
|
+
const engine = PostCommentCountEngine$1.getInstance();
|
|
19162
|
+
const posts = payload.posts.map(post => {
|
|
19163
|
+
var _a, _b, _c;
|
|
19164
|
+
if (!engine.hasTracker(post.postId)) {
|
|
19165
|
+
const latestCreatedAt = (_b = ((_a = payload.comments) !== null && _a !== void 0 ? _a : [])
|
|
19166
|
+
.filter(comment => comment.referenceType === 'post' && comment.referenceId === post.postId)
|
|
19167
|
+
.map(comment => comment.createdAt)
|
|
19168
|
+
.sort()
|
|
19169
|
+
.at(-1)) !== null && _b !== void 0 ? _b : new Date().toISOString();
|
|
19170
|
+
engine.queueCommentChangeTask(new ResetTask(post.postId, latestCreatedAt, (_c = post.commentsCount) !== null && _c !== void 0 ? _c : 0));
|
|
19171
|
+
}
|
|
19172
|
+
// Same figure preparePostPayload writes: the author's view, own pending comments included.
|
|
19173
|
+
return Object.assign(Object.assign({}, post), { localCommentCount: engine.getLocalCommentCount(post.postId, true) });
|
|
19174
|
+
});
|
|
19175
|
+
return Object.assign(Object.assign({}, payload), { posts });
|
|
19176
|
+
};
|
|
19177
|
+
|
|
19142
19178
|
/**
|
|
19143
19179
|
* ```js
|
|
19144
19180
|
* import { onPostReactionAdded } from '@amityco/ts-sdk-react-native'
|
|
@@ -19163,7 +19199,7 @@ const onPostReactionAdded = (callback) => {
|
|
|
19163
19199
|
else {
|
|
19164
19200
|
const processed = prepareReactionPayloadFromEvent('post.addReaction', payload);
|
|
19165
19201
|
const postPayload = __rest(processed, ["reactor"]);
|
|
19166
|
-
ingestInCache(postPayload);
|
|
19202
|
+
ingestInCache(withLocalCommentCount(postPayload));
|
|
19167
19203
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
19168
19204
|
callback(post.data);
|
|
19169
19205
|
}
|
|
@@ -19195,7 +19231,7 @@ const onPostReactionRemoved = (callback) => {
|
|
|
19195
19231
|
else {
|
|
19196
19232
|
const processed = prepareReactionPayloadFromEvent('post.removeReaction', payload);
|
|
19197
19233
|
const postPayload = __rest(processed, ["reactor"]);
|
|
19198
|
-
ingestInCache(postPayload);
|
|
19234
|
+
ingestInCache(withLocalCommentCount(postPayload));
|
|
19199
19235
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
19200
19236
|
callback(post.data);
|
|
19201
19237
|
}
|
|
@@ -19685,7 +19721,7 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
|
|
|
19685
19721
|
if (referenceType === 'post') {
|
|
19686
19722
|
const filter = (payload) => {
|
|
19687
19723
|
const { reactor } = payload, rest = __rest(payload, ["reactor"]);
|
|
19688
|
-
ingestInCache(rest);
|
|
19724
|
+
ingestInCache(withLocalCommentCount(rest));
|
|
19689
19725
|
ingestInCache({ reactions: [reactor] });
|
|
19690
19726
|
callbackWrapper('post', payload.posts[0].postId, reactor);
|
|
19691
19727
|
};
|
|
@@ -19748,7 +19784,7 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
|
|
|
19748
19784
|
if (referenceType === 'post') {
|
|
19749
19785
|
const filter = (payload) => {
|
|
19750
19786
|
const { reactor } = payload, rest = __rest(payload, ["reactor"]);
|
|
19751
|
-
ingestInCache(rest);
|
|
19787
|
+
ingestInCache(withLocalCommentCount(rest));
|
|
19752
19788
|
// FIXME: correct reactions type in model
|
|
19753
19789
|
// @ts-ignore
|
|
19754
19790
|
ingestInCache({ reactions: [reactor] });
|
|
@@ -31122,7 +31158,9 @@ const getPostByIds = async (postIds) => {
|
|
|
31122
31158
|
});
|
|
31123
31159
|
throw error;
|
|
31124
31160
|
}
|
|
31125
|
-
|
|
31161
|
+
// The response is a raw server post; carry the session's comment count onto it before it
|
|
31162
|
+
// replaces the cached post
|
|
31163
|
+
const data = withLocalCommentCount(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31126
31164
|
const cachedAt = client.cache && Date.now();
|
|
31127
31165
|
if (client.cache)
|
|
31128
31166
|
ingestInCache(data, { cachedAt });
|
|
@@ -31251,7 +31289,9 @@ const editPost = async (postId, patch) => {
|
|
|
31251
31289
|
const { attachments } = patch;
|
|
31252
31290
|
const processedAttachments = preparePostAttachments(attachments, patch.attachmentProductTags);
|
|
31253
31291
|
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, Object.assign(Object.assign({}, patch), { attachments: processedAttachments }));
|
|
31254
|
-
|
|
31292
|
+
// The response is a raw server post; carry the session's comment count onto it before it
|
|
31293
|
+
// replaces the cached post
|
|
31294
|
+
const data = withLocalCommentCount(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31255
31295
|
const cachedAt = client.cache && Date.now();
|
|
31256
31296
|
if (client.cache)
|
|
31257
31297
|
ingestInCache(data, { cachedAt });
|
|
@@ -32326,7 +32366,7 @@ class PinnedPostQueryStreamController extends QueryStreamController {
|
|
|
32326
32366
|
const client = getActiveClient();
|
|
32327
32367
|
const cachedAt = client.cache && Date.now();
|
|
32328
32368
|
if (client.cache) {
|
|
32329
|
-
const processedPayload = Object.assign(Object.assign({}, response), { users: response.users ? response.users.map(convertRawUserToInternalUser) : [] });
|
|
32369
|
+
const processedPayload = Object.assign(Object.assign({}, withLocalCommentCount(response)), { users: response.users ? response.users.map(convertRawUserToInternalUser) : [] });
|
|
32330
32370
|
ingestInCache(processedPayload, { cachedAt });
|
|
32331
32371
|
}
|
|
32332
32372
|
}
|
|
@@ -32477,7 +32517,7 @@ class GlobalPinnedPostQueryStreamController extends QueryStreamController {
|
|
|
32477
32517
|
const client = getActiveClient();
|
|
32478
32518
|
const cachedAt = client.cache && Date.now();
|
|
32479
32519
|
if (client.cache) {
|
|
32480
|
-
const processedPayload = Object.assign(Object.assign({}, response), { users: response.users.map(convertRawUserToInternalUser) });
|
|
32520
|
+
const processedPayload = Object.assign(Object.assign({}, withLocalCommentCount(response)), { users: response.users.map(convertRawUserToInternalUser) });
|
|
32481
32521
|
ingestInCache(processedPayload, { cachedAt });
|
|
32482
32522
|
}
|
|
32483
32523
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -14531,7 +14531,7 @@ const getWatchSessionStorage = () => {
|
|
|
14531
14531
|
return storageInstance;
|
|
14532
14532
|
};
|
|
14533
14533
|
|
|
14534
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
14534
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT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KEY-----";
|
|
14535
14535
|
/*
|
|
14536
14536
|
* The crypto algorithm used for importing key and signing string
|
|
14537
14537
|
*/
|
|
@@ -19120,6 +19120,42 @@ const onPostFlagged = (callback) => createPostEventSubscriber('post.flagged', ca
|
|
|
19120
19120
|
*/
|
|
19121
19121
|
const onPostUnflagged = (callback) => createPostEventSubscriber('post.unflagged', callback);
|
|
19122
19122
|
|
|
19123
|
+
/**
|
|
19124
|
+
* Carries the session's comment count onto the posts of a raw server payload.
|
|
19125
|
+
*
|
|
19126
|
+
* Reaction events, pinned post queries and a few post APIs deliver the post as the server sees
|
|
19127
|
+
* it, with no `localCommentCount`, and are ingested by replacing the cached post. Without this
|
|
19128
|
+
* the count is dropped from the cache and the post reads as having no comments until it is
|
|
19129
|
+
* fetched again.
|
|
19130
|
+
*
|
|
19131
|
+
* A post the engine already tracks keeps its figure: it is read rather than recomputed, since a
|
|
19132
|
+
* ResetTask would throw away the local delta. A post the engine has not seen yet is seeded from
|
|
19133
|
+
* the payload, the way `preparePostPayload` seeds it; otherwise a post that only ever arrived
|
|
19134
|
+
* here (a pinned post, say) would have no tracker and comments created or deleted in this
|
|
19135
|
+
* session would never move its count.
|
|
19136
|
+
*
|
|
19137
|
+
* @hidden
|
|
19138
|
+
*/
|
|
19139
|
+
const withLocalCommentCount = (payload) => {
|
|
19140
|
+
if (!payload.posts)
|
|
19141
|
+
return payload;
|
|
19142
|
+
const engine = PostCommentCountEngine$1.getInstance();
|
|
19143
|
+
const posts = payload.posts.map(post => {
|
|
19144
|
+
var _a, _b, _c;
|
|
19145
|
+
if (!engine.hasTracker(post.postId)) {
|
|
19146
|
+
const latestCreatedAt = (_b = ((_a = payload.comments) !== null && _a !== void 0 ? _a : [])
|
|
19147
|
+
.filter(comment => comment.referenceType === 'post' && comment.referenceId === post.postId)
|
|
19148
|
+
.map(comment => comment.createdAt)
|
|
19149
|
+
.sort()
|
|
19150
|
+
.at(-1)) !== null && _b !== void 0 ? _b : new Date().toISOString();
|
|
19151
|
+
engine.queueCommentChangeTask(new ResetTask(post.postId, latestCreatedAt, (_c = post.commentsCount) !== null && _c !== void 0 ? _c : 0));
|
|
19152
|
+
}
|
|
19153
|
+
// Same figure preparePostPayload writes: the author's view, own pending comments included.
|
|
19154
|
+
return Object.assign(Object.assign({}, post), { localCommentCount: engine.getLocalCommentCount(post.postId, true) });
|
|
19155
|
+
});
|
|
19156
|
+
return Object.assign(Object.assign({}, payload), { posts });
|
|
19157
|
+
};
|
|
19158
|
+
|
|
19123
19159
|
/**
|
|
19124
19160
|
* ```js
|
|
19125
19161
|
* import { onPostReactionAdded } from '@amityco/ts-sdk-react-native'
|
|
@@ -19144,7 +19180,7 @@ const onPostReactionAdded = (callback) => {
|
|
|
19144
19180
|
else {
|
|
19145
19181
|
const processed = prepareReactionPayloadFromEvent('post.addReaction', payload);
|
|
19146
19182
|
const postPayload = __rest(processed, ["reactor"]);
|
|
19147
|
-
ingestInCache(postPayload);
|
|
19183
|
+
ingestInCache(withLocalCommentCount(postPayload));
|
|
19148
19184
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
19149
19185
|
callback(post.data);
|
|
19150
19186
|
}
|
|
@@ -19176,7 +19212,7 @@ const onPostReactionRemoved = (callback) => {
|
|
|
19176
19212
|
else {
|
|
19177
19213
|
const processed = prepareReactionPayloadFromEvent('post.removeReaction', payload);
|
|
19178
19214
|
const postPayload = __rest(processed, ["reactor"]);
|
|
19179
|
-
ingestInCache(postPayload);
|
|
19215
|
+
ingestInCache(withLocalCommentCount(postPayload));
|
|
19180
19216
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
19181
19217
|
callback(post.data);
|
|
19182
19218
|
}
|
|
@@ -19666,7 +19702,7 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
|
|
|
19666
19702
|
if (referenceType === 'post') {
|
|
19667
19703
|
const filter = (payload) => {
|
|
19668
19704
|
const { reactor } = payload, rest = __rest(payload, ["reactor"]);
|
|
19669
|
-
ingestInCache(rest);
|
|
19705
|
+
ingestInCache(withLocalCommentCount(rest));
|
|
19670
19706
|
ingestInCache({ reactions: [reactor] });
|
|
19671
19707
|
callbackWrapper('post', payload.posts[0].postId, reactor);
|
|
19672
19708
|
};
|
|
@@ -19729,7 +19765,7 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
|
|
|
19729
19765
|
if (referenceType === 'post') {
|
|
19730
19766
|
const filter = (payload) => {
|
|
19731
19767
|
const { reactor } = payload, rest = __rest(payload, ["reactor"]);
|
|
19732
|
-
ingestInCache(rest);
|
|
19768
|
+
ingestInCache(withLocalCommentCount(rest));
|
|
19733
19769
|
// FIXME: correct reactions type in model
|
|
19734
19770
|
// @ts-ignore
|
|
19735
19771
|
ingestInCache({ reactions: [reactor] });
|
|
@@ -31103,7 +31139,9 @@ const getPostByIds = async (postIds) => {
|
|
|
31103
31139
|
});
|
|
31104
31140
|
throw error;
|
|
31105
31141
|
}
|
|
31106
|
-
|
|
31142
|
+
// The response is a raw server post; carry the session's comment count onto it before it
|
|
31143
|
+
// replaces the cached post
|
|
31144
|
+
const data = withLocalCommentCount(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31107
31145
|
const cachedAt = client.cache && Date.now();
|
|
31108
31146
|
if (client.cache)
|
|
31109
31147
|
ingestInCache(data, { cachedAt });
|
|
@@ -31232,7 +31270,9 @@ const editPost = async (postId, patch) => {
|
|
|
31232
31270
|
const { attachments } = patch;
|
|
31233
31271
|
const processedAttachments = preparePostAttachments(attachments, patch.attachmentProductTags);
|
|
31234
31272
|
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, Object.assign(Object.assign({}, patch), { attachments: processedAttachments }));
|
|
31235
|
-
|
|
31273
|
+
// The response is a raw server post; carry the session's comment count onto it before it
|
|
31274
|
+
// replaces the cached post
|
|
31275
|
+
const data = withLocalCommentCount(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31236
31276
|
const cachedAt = client.cache && Date.now();
|
|
31237
31277
|
if (client.cache)
|
|
31238
31278
|
ingestInCache(data, { cachedAt });
|
|
@@ -32307,7 +32347,7 @@ class PinnedPostQueryStreamController extends QueryStreamController {
|
|
|
32307
32347
|
const client = getActiveClient();
|
|
32308
32348
|
const cachedAt = client.cache && Date.now();
|
|
32309
32349
|
if (client.cache) {
|
|
32310
|
-
const processedPayload = Object.assign(Object.assign({}, response), { users: response.users ? response.users.map(convertRawUserToInternalUser) : [] });
|
|
32350
|
+
const processedPayload = Object.assign(Object.assign({}, withLocalCommentCount(response)), { users: response.users ? response.users.map(convertRawUserToInternalUser) : [] });
|
|
32311
32351
|
ingestInCache(processedPayload, { cachedAt });
|
|
32312
32352
|
}
|
|
32313
32353
|
}
|
|
@@ -32458,7 +32498,7 @@ class GlobalPinnedPostQueryStreamController extends QueryStreamController {
|
|
|
32458
32498
|
const client = getActiveClient();
|
|
32459
32499
|
const cachedAt = client.cache && Date.now();
|
|
32460
32500
|
if (client.cache) {
|
|
32461
|
-
const processedPayload = Object.assign(Object.assign({}, response), { users: response.users.map(convertRawUserToInternalUser) });
|
|
32501
|
+
const processedPayload = Object.assign(Object.assign({}, withLocalCommentCount(response)), { users: response.users.map(convertRawUserToInternalUser) });
|
|
32462
32502
|
ingestInCache(processedPayload, { cachedAt });
|
|
32463
32503
|
}
|
|
32464
32504
|
}
|