@amityco/ts-sdk 0.0.1-beta.43 → 0.0.1-beta.44.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/category/api/queryCategories.d.ts.map +1 -1
- package/dist/comment/api/queryComments.d.ts.map +1 -1
- package/dist/community/api/queryCommunities.d.ts.map +1 -1
- package/dist/community/observers/liveCommunities.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts +21 -0
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/index.cjs.js +116 -62
- package/dist/index.esm.js +115 -63
- package/dist/index.umd.js +4 -4
- package/dist/message/api/queryMessages.d.ts +1 -17
- package/dist/message/api/queryMessages.d.ts.map +1 -1
- package/dist/message/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/post/api/queryPosts.d.ts.map +1 -1
- package/dist/post/observers/livePosts.d.ts.map +1 -1
- package/dist/subChannel/api/querySubChannels.d.ts.map +1 -1
- package/dist/utils/inferIsDeleted.d.ts +2 -0
- package/dist/utils/inferIsDeleted.d.ts.map +1 -0
- package/dist/utils/tests/inferIsDeleted.test.d.ts +2 -0
- package/dist/utils/tests/inferIsDeleted.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/category/api/queryCategories.ts +3 -1
- package/src/category/observers/liveCategories.ts +1 -1
- package/src/category/observers/tests/liveCategories.test.ts +7 -5
- package/src/channel/api/tests/removeChannelMembers.test.ts +3 -4
- package/src/channel/observers/tests/liveChannels.test.ts +6 -6
- package/src/client/api/connectClient.ts +1 -1
- package/src/comment/api/queryComments.ts +3 -1
- package/src/comment/observers/liveComments.ts +1 -1
- package/src/community/api/queryCommunities.ts +2 -1
- package/src/community/api/test/queryCommunity.test.ts +2 -2
- package/src/community/observers/liveCommunities.ts +5 -8
- package/src/community/observers/tests/liveCommunities.test.ts +7 -94
- package/src/community/observers/tests/liveCommunity.test.ts +4 -4
- package/src/core/query/filtering.ts +79 -0
- package/src/core/query/query.ts +4 -4
- package/src/message/api/queryMessages.ts +7 -44
- package/src/message/api/tests/queryMessages.test.ts +2 -37
- package/src/message/observers/liveMessages.ts +2 -2
- package/src/message/tests/observers/liveMessage.test.ts +1 -1
- package/src/message/tests/observers/liveMessages.test.ts +1 -1
- package/src/message/utils/prepareMessagePayload.ts +3 -1
- package/src/post/api/queryPosts.ts +3 -1
- package/src/post/observers/livePosts.ts +7 -2
- package/src/post/observers/tests/livePosts.test.ts +10 -4
- package/src/subChannel/api/querySubChannels.ts +3 -1
- package/src/subChannel/observers/liveSubChannels.ts +1 -1
- package/src/utils/inferIsDeleted.ts +16 -0
- package/src/utils/tests/inferIsDeleted.test.ts +15 -0
package/dist/index.esm.js
CHANGED
|
@@ -81,8 +81,8 @@ const PostContentType = Object.freeze({
|
|
|
81
81
|
|
|
82
82
|
function getVersion() {
|
|
83
83
|
try {
|
|
84
|
-
// the string ''v0.0.1-beta.
|
|
85
|
-
return 'v0.0.1-beta.
|
|
84
|
+
// the string ''v0.0.1-beta.44.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
85
|
+
return 'v0.0.1-beta.44.0-esm';
|
|
86
86
|
}
|
|
87
87
|
catch (error) {
|
|
88
88
|
return '__dev__';
|
|
@@ -437,8 +437,8 @@ const queryOptions = (policy, lifeSpan = CACHE_LIFESPAN) => {
|
|
|
437
437
|
* @category Query
|
|
438
438
|
*/
|
|
439
439
|
const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_server')) => {
|
|
440
|
-
console.
|
|
441
|
-
console.
|
|
440
|
+
console.info('Deprecation Notice: By Q3, CreateQuery/RunQuery will no longer be exported from the SDK. You will be able to use the API without either methods.');
|
|
441
|
+
console.info('Deprecation Notice: From v6.0.0, individual module imports will no longer be supported. All public APIs will need to be imported from their respective repositories. Ex: CommunityRepository, UserRepository, etc.');
|
|
442
442
|
let local;
|
|
443
443
|
const { lifeSpan } = queryOptions('cache_then_server', options.lifeSpan);
|
|
444
444
|
// offline first
|
|
@@ -1127,6 +1127,70 @@ const filterByFeedType = (collection, feedType) => {
|
|
|
1127
1127
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1128
1128
|
return feed && feed.feedType === feedType;
|
|
1129
1129
|
});
|
|
1130
|
+
};
|
|
1131
|
+
/**
|
|
1132
|
+
* Filter a community collection by membership of the userId
|
|
1133
|
+
*
|
|
1134
|
+
* @param collection the community to filter
|
|
1135
|
+
* @param membership the membership to be filtered by
|
|
1136
|
+
* @param userId user id to be filtered by
|
|
1137
|
+
* @returns a filtered collection with items only matching the criteria
|
|
1138
|
+
*
|
|
1139
|
+
* @hidden
|
|
1140
|
+
*/
|
|
1141
|
+
const filterByCommunityMembership = (collection, membership, userId) => {
|
|
1142
|
+
if (membership === 'all') {
|
|
1143
|
+
return collection;
|
|
1144
|
+
}
|
|
1145
|
+
return collection.filter(c => {
|
|
1146
|
+
var _a;
|
|
1147
|
+
// get resolver for the community by user
|
|
1148
|
+
const communityUserCacheKey = getResolver('communityUsers')({
|
|
1149
|
+
communityId: c.communityId,
|
|
1150
|
+
userId,
|
|
1151
|
+
});
|
|
1152
|
+
const communityUser = (_a = pullFromCache([
|
|
1153
|
+
'communityUsers',
|
|
1154
|
+
'get',
|
|
1155
|
+
communityUserCacheKey,
|
|
1156
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1157
|
+
if (membership === 'member') {
|
|
1158
|
+
return communityUser && communityUser.communityMembership === 'member';
|
|
1159
|
+
}
|
|
1160
|
+
// only membership value remainging is 'notMember'
|
|
1161
|
+
return !communityUser || communityUser.communityMembership !== 'none';
|
|
1162
|
+
});
|
|
1163
|
+
};
|
|
1164
|
+
/**
|
|
1165
|
+
* Filter a post collection by dataType
|
|
1166
|
+
*
|
|
1167
|
+
* @param collection the post to filter
|
|
1168
|
+
* @param dataTypes of the post to be filtered by
|
|
1169
|
+
* @returns a filtered collection with items only matching the criteria
|
|
1170
|
+
*
|
|
1171
|
+
* @hidden
|
|
1172
|
+
*/
|
|
1173
|
+
const filterByPostDataTypes = (collection, dataTypes) => {
|
|
1174
|
+
const filteredPosts = [];
|
|
1175
|
+
collection.forEach(c => {
|
|
1176
|
+
var _a;
|
|
1177
|
+
/*
|
|
1178
|
+
* A text post with no children is just a text post
|
|
1179
|
+
*/
|
|
1180
|
+
if (c.dataType === 'text' && !c.children.length)
|
|
1181
|
+
return;
|
|
1182
|
+
if (c.children.length) {
|
|
1183
|
+
const childPost = (_a = pullFromCache(['post', 'get', c.children[0]])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1184
|
+
if (childPost && (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(childPost === null || childPost === void 0 ? void 0 : childPost.dataType))) {
|
|
1185
|
+
// @ts-ignore
|
|
1186
|
+
filteredPosts.push(childPost);
|
|
1187
|
+
}
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
if (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(c.dataType))
|
|
1191
|
+
filteredPosts.push(c);
|
|
1192
|
+
});
|
|
1193
|
+
return filteredPosts;
|
|
1130
1194
|
};
|
|
1131
1195
|
|
|
1132
1196
|
// Note:
|
|
@@ -20837,7 +20901,7 @@ const connectClient = async (params, sessionHandler, config) => {
|
|
|
20837
20901
|
* Cannot push to subscriptions as watcher needs to continue working even if
|
|
20838
20902
|
* token expires
|
|
20839
20903
|
*/
|
|
20840
|
-
unsubWatcher = client.accessTokenExpiryWatcher((_b = client.token) === null || _b === void 0 ? void 0 : _b.
|
|
20904
|
+
unsubWatcher = client.accessTokenExpiryWatcher((_b = client.token) === null || _b === void 0 ? void 0 : _b.expiresAt, (_c = client.token) === null || _c === void 0 ? void 0 : _c.issuedAt, sessionHandler);
|
|
20841
20905
|
setActiveUser(users[0]);
|
|
20842
20906
|
}
|
|
20843
20907
|
catch (error) {
|
|
@@ -21548,6 +21612,22 @@ const prepareMessagePayloadForCache = (payload) => {
|
|
|
21548
21612
|
}
|
|
21549
21613
|
};
|
|
21550
21614
|
|
|
21615
|
+
/*
|
|
21616
|
+
* This is a simple utility that infers the value of isDeleted based on the
|
|
21617
|
+
* value of includeDeleted
|
|
21618
|
+
*
|
|
21619
|
+
* There are two important things to note here:
|
|
21620
|
+
* 1. `includeDeleted` is purely client side query param and not recognized by
|
|
21621
|
+
* the server
|
|
21622
|
+
* 2. The only values we wish to expose with regards to `isDeleted` (the server
|
|
21623
|
+
* param for queries) is false | undefined and want to disallow users to query
|
|
21624
|
+
* for deleted entities
|
|
21625
|
+
*
|
|
21626
|
+
* Although this is a very simple utility, it's only purpose is to keep things
|
|
21627
|
+
* DRY
|
|
21628
|
+
*/
|
|
21629
|
+
const inferIsDeleted = (includeDeleted) => includeDeleted === true ? undefined : false;
|
|
21630
|
+
|
|
21551
21631
|
const getCachedMarker$1 = (message) => {
|
|
21552
21632
|
var _a, _b;
|
|
21553
21633
|
const key = {
|
|
@@ -21626,7 +21706,7 @@ function convertParams(_a) {
|
|
|
21626
21706
|
}
|
|
21627
21707
|
function convertQueryParams$1(_a) {
|
|
21628
21708
|
var { page, sortBy, subChannelId, tags, includeDeleted } = _a, rest = __rest(_a, ["page", "sortBy", "subChannelId", "tags", "includeDeleted"]);
|
|
21629
|
-
const out = Object.assign(Object.assign({}, rest), { messageFeedId: subChannelId, isDeleted: includeDeleted
|
|
21709
|
+
const out = Object.assign(Object.assign({}, rest), { messageFeedId: subChannelId, isDeleted: inferIsDeleted(includeDeleted), options: { token: toToken(page || { limit: 10 }, 'afterbeforeraw') } });
|
|
21630
21710
|
if (sortBy !== undefined) {
|
|
21631
21711
|
out.options.sortBy = sortBy;
|
|
21632
21712
|
}
|
|
@@ -23469,6 +23549,12 @@ const queryMessages = async (query) => {
|
|
|
23469
23549
|
const { messages } = data;
|
|
23470
23550
|
const cachedAt = client.cache && Date.now();
|
|
23471
23551
|
if (client.cache) {
|
|
23552
|
+
/*
|
|
23553
|
+
* queryMessages.locally is unsupported for messages as message list updates
|
|
23554
|
+
* frequently and leads to bugs when user switches between channels, i.e. when
|
|
23555
|
+
* the public function (live messages) calls unmount. The list fetched on
|
|
23556
|
+
* after from the cache is stale.
|
|
23557
|
+
*/
|
|
23472
23558
|
ingestInCache(data, { cachedAt });
|
|
23473
23559
|
const cacheKey = ['message', 'query', params];
|
|
23474
23560
|
pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
|
|
@@ -23478,41 +23564,7 @@ const queryMessages = async (query) => {
|
|
|
23478
23564
|
const prevPage = toPageRaw(paging.previous);
|
|
23479
23565
|
return { data: messages, cachedAt, prevPage, nextPage };
|
|
23480
23566
|
};
|
|
23481
|
-
/* end_public_function */
|
|
23482
|
-
/**
|
|
23483
|
-
* ```js
|
|
23484
|
-
* import { queryMessages } from '@amityco/ts-sdk'
|
|
23485
|
-
* const messages = queryMessages.locally!({ channelId })
|
|
23486
|
-
* ```
|
|
23487
|
-
*
|
|
23488
|
-
* Queries a paginable list of {@link Amity.Message} objects from cache
|
|
23489
|
-
*
|
|
23490
|
-
* @param query The query parameters
|
|
23491
|
-
* @returns A page of {@link Amity.Message} objects
|
|
23492
|
-
*
|
|
23493
|
-
* @category Message API
|
|
23494
|
-
*/
|
|
23495
|
-
queryMessages.locally = (query) => {
|
|
23496
|
-
var _a, _b;
|
|
23497
|
-
const client = getActiveClient();
|
|
23498
|
-
client.log('message/queryMessages.locally', query);
|
|
23499
|
-
if (!client.cache)
|
|
23500
|
-
return;
|
|
23501
|
-
const params = convertQueryParams$1(query);
|
|
23502
|
-
const queryKey = ['message', 'query', params];
|
|
23503
|
-
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
23504
|
-
if (!(data === null || data === void 0 ? void 0 : data.messages.length))
|
|
23505
|
-
return;
|
|
23506
|
-
const messages = data.messages
|
|
23507
|
-
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
23508
|
-
.filter(Boolean)
|
|
23509
|
-
.map(({ data }) => data);
|
|
23510
|
-
const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
23511
|
-
const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
23512
|
-
return messages.length === ((_b = data === null || data === void 0 ? void 0 : data.messages) === null || _b === void 0 ? void 0 : _b.length)
|
|
23513
|
-
? { data: messages, cachedAt, prevPage, nextPage }
|
|
23514
|
-
: undefined;
|
|
23515
|
-
};
|
|
23567
|
+
/* end_public_function */
|
|
23516
23568
|
|
|
23517
23569
|
const uuid = () => nativeIdGenerator.v4().toString();
|
|
23518
23570
|
|
|
@@ -23856,7 +23908,7 @@ const queryPosts = async (query) => {
|
|
|
23856
23908
|
// API-FIX: backend should answer Amity.Response (2)
|
|
23857
23909
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
|
|
23858
23910
|
const { data } = await client.http.get(`/api/v4/posts`, {
|
|
23859
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
23911
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
23860
23912
|
/*
|
|
23861
23913
|
* when creating post like image, file, video BE will create 2 posts
|
|
23862
23914
|
* 1. parent post to store text with dataType=text
|
|
@@ -24201,7 +24253,7 @@ const queryCommunities = async (query) => {
|
|
|
24201
24253
|
// API-FIX: backend doesnt answer Amity.Response
|
|
24202
24254
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
|
|
24203
24255
|
const { data } = await client.http.get(`/api/v3/communities`, {
|
|
24204
|
-
params: Object.assign(Object.assign({}, restParams), { isDeleted: includeDeleted
|
|
24256
|
+
params: Object.assign(Object.assign({}, restParams), { isDeleted: inferIsDeleted(includeDeleted), keyword: displayName, filter: membership, options: {
|
|
24205
24257
|
token: toToken(page, 'skiplimit'),
|
|
24206
24258
|
} }),
|
|
24207
24259
|
});
|
|
@@ -25052,7 +25104,7 @@ const queryComments = async (query) => {
|
|
|
25052
25104
|
// API-FIX: backend should answer Amity.Response (2)
|
|
25053
25105
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.CommentPayload>>>(
|
|
25054
25106
|
const { data } = await client.http.get(`/api/v3/comments`, {
|
|
25055
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
25107
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
25056
25108
|
// filterByParentId, API-FIX: backend does not support this boolean LOL. what the hell seriously.
|
|
25057
25109
|
options }),
|
|
25058
25110
|
});
|
|
@@ -27891,7 +27943,7 @@ const querySubChannels = async (query) => {
|
|
|
27891
27943
|
client.log('channel/querySubChannels', query);
|
|
27892
27944
|
const _a = convertQueryParams(query), { page = { limit: 10 }, channelId, includeDeleted } = _a, params = __rest(_a, ["page", "channelId", "includeDeleted"]);
|
|
27893
27945
|
const response = await client.http.get(`/api/v5/message-feeds/channel/${channelId}`, {
|
|
27894
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
27946
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
27895
27947
|
token: toToken(page, 'skiplimit'),
|
|
27896
27948
|
} }),
|
|
27897
27949
|
});
|
|
@@ -28274,7 +28326,7 @@ const liveSubChannels = (params, callback, config) => {
|
|
|
28274
28326
|
const responder = (data) => {
|
|
28275
28327
|
var _a;
|
|
28276
28328
|
let subChannels = data.data;
|
|
28277
|
-
if (params.includeDeleted
|
|
28329
|
+
if (!params.includeDeleted) {
|
|
28278
28330
|
subChannels = filterByPropEquality(subChannels, 'isDeleted', false);
|
|
28279
28331
|
}
|
|
28280
28332
|
subChannels.sort(sortByLastActivity);
|
|
@@ -28398,7 +28450,7 @@ const liveMessages = (params, callback, config) => {
|
|
|
28398
28450
|
* for cases when message is deleted via RTE, this flag is used to get
|
|
28399
28451
|
* items from cache that are !deleted
|
|
28400
28452
|
*/
|
|
28401
|
-
if (params.includeDeleted
|
|
28453
|
+
if (!params.includeDeleted) {
|
|
28402
28454
|
messages = filterByPropEquality(messages, 'isDeleted', false);
|
|
28403
28455
|
}
|
|
28404
28456
|
callback({
|
|
@@ -28416,6 +28468,7 @@ const liveMessages = (params, callback, config) => {
|
|
|
28416
28468
|
return;
|
|
28417
28469
|
collection.data = [...new Set([message.messageId, ...collection.data])];
|
|
28418
28470
|
pushToCache(cacheKey, collection);
|
|
28471
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
28419
28472
|
responder(collection);
|
|
28420
28473
|
};
|
|
28421
28474
|
const onFetch = () => {
|
|
@@ -28444,7 +28497,6 @@ const liveMessages = (params, callback, config) => {
|
|
|
28444
28497
|
return () => {
|
|
28445
28498
|
log(`liveMessages(tmpid: ${timestamp}) > dispose`);
|
|
28446
28499
|
disposers.forEach(fn => fn());
|
|
28447
|
-
dropFromCache(cacheKey);
|
|
28448
28500
|
};
|
|
28449
28501
|
};
|
|
28450
28502
|
|
|
@@ -28903,7 +28955,7 @@ const observeCommunity = (communityId, callback) => {
|
|
|
28903
28955
|
* @category Community Live Collection
|
|
28904
28956
|
*/
|
|
28905
28957
|
const liveCommunities = (params, callback, config) => {
|
|
28906
|
-
const { log, cache } = getActiveClient();
|
|
28958
|
+
const { log, cache, userId } = getActiveClient();
|
|
28907
28959
|
if (!cache) {
|
|
28908
28960
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
28909
28961
|
}
|
|
@@ -28921,7 +28973,7 @@ const liveCommunities = (params, callback, config) => {
|
|
|
28921
28973
|
.filter(Boolean)
|
|
28922
28974
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
28923
28975
|
communities = filterByPropEquality(communities, 'displayName', params.displayName);
|
|
28924
|
-
if (params.includeDeleted
|
|
28976
|
+
if (!params.includeDeleted) {
|
|
28925
28977
|
communities = filterByPropEquality(communities, 'isDeleted', false);
|
|
28926
28978
|
}
|
|
28927
28979
|
if (params.categoryId) {
|
|
@@ -28930,11 +28982,8 @@ const liveCommunities = (params, callback, config) => {
|
|
|
28930
28982
|
if (params.tags) {
|
|
28931
28983
|
communities = communities.filter(c => { var _a; return (_a = c.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.tags) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
|
|
28932
28984
|
}
|
|
28933
|
-
if (params.membership
|
|
28934
|
-
communities =
|
|
28935
|
-
}
|
|
28936
|
-
if (params.membership === 'notMember') {
|
|
28937
|
-
communities = filterByPropEquality(communities, 'isJoined', false);
|
|
28985
|
+
if (params.membership && userId) {
|
|
28986
|
+
communities = filterByCommunityMembership(communities, params.membership, userId);
|
|
28938
28987
|
}
|
|
28939
28988
|
const sortBy = params.sortBy || 'lastCreated';
|
|
28940
28989
|
if (sortBy === 'lastCreated' || sortBy === 'firstCreated') {
|
|
@@ -29168,7 +29217,7 @@ const queryCategories = async (query) => {
|
|
|
29168
29217
|
client.log('category/queryCategories', query);
|
|
29169
29218
|
const _a = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 }, includeDeleted } = _a, params = __rest(_a, ["page", "includeDeleted"]);
|
|
29170
29219
|
const { data } = await client.http.get(`/api/v3/community-categories`, {
|
|
29171
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
29220
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
29172
29221
|
token: toToken(page, 'skiplimit'),
|
|
29173
29222
|
} }),
|
|
29174
29223
|
});
|
|
@@ -29311,7 +29360,7 @@ const liveCategories = (params, callback, config) => {
|
|
|
29311
29360
|
.map(categoryId => pullFromCache(['category', 'get', categoryId]))
|
|
29312
29361
|
.filter(Boolean)
|
|
29313
29362
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
29314
|
-
if (params.includeDeleted
|
|
29363
|
+
if (!params.includeDeleted) {
|
|
29315
29364
|
categories = filterByPropEquality(categories, 'isDeleted', false);
|
|
29316
29365
|
}
|
|
29317
29366
|
switch (params.sortBy) {
|
|
@@ -30415,14 +30464,14 @@ const livePosts = (params, callback, config) => {
|
|
|
30415
30464
|
{ targetId: params.targetId, targetType: params.targetType },
|
|
30416
30465
|
];
|
|
30417
30466
|
const responder = (data) => {
|
|
30418
|
-
var _a, _b;
|
|
30467
|
+
var _a, _b, _c;
|
|
30419
30468
|
let posts = (_a = data.data
|
|
30420
30469
|
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
30421
30470
|
.filter(Boolean)
|
|
30422
30471
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30423
30472
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
30424
30473
|
posts = posts.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
30425
|
-
if (params.includeDeleted
|
|
30474
|
+
if (!params.includeDeleted) {
|
|
30426
30475
|
posts = filterByPropEquality(posts, 'isDeleted', false);
|
|
30427
30476
|
}
|
|
30428
30477
|
if (params.tags) {
|
|
@@ -30431,10 +30480,13 @@ const livePosts = (params, callback, config) => {
|
|
|
30431
30480
|
if (params.targetType === 'community' && params.feedType) {
|
|
30432
30481
|
posts = filterByFeedType(posts, params.feedType);
|
|
30433
30482
|
}
|
|
30483
|
+
if ((_b = params.dataTypes) === null || _b === void 0 ? void 0 : _b.length) {
|
|
30484
|
+
posts = filterByPostDataTypes(posts, params.dataTypes);
|
|
30485
|
+
}
|
|
30434
30486
|
callback({
|
|
30435
30487
|
onNextPage: onFetch,
|
|
30436
30488
|
data: posts,
|
|
30437
|
-
hasNextPage: !!((
|
|
30489
|
+
hasNextPage: !!((_c = data.params) === null || _c === void 0 ? void 0 : _c.page),
|
|
30438
30490
|
loading: data.loading,
|
|
30439
30491
|
error: data.error,
|
|
30440
30492
|
});
|
|
@@ -30455,6 +30507,7 @@ const livePosts = (params, callback, config) => {
|
|
|
30455
30507
|
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
30456
30508
|
}
|
|
30457
30509
|
pushToCache(cacheKey, collection);
|
|
30510
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
30458
30511
|
responder(collection);
|
|
30459
30512
|
};
|
|
30460
30513
|
const onFetch = () => {
|
|
@@ -30483,7 +30536,6 @@ const livePosts = (params, callback, config) => {
|
|
|
30483
30536
|
return () => {
|
|
30484
30537
|
log(`livePosts(tmpid: ${timestamp}) > dispose`);
|
|
30485
30538
|
disposers.forEach(fn => fn());
|
|
30486
|
-
dropFromCache(cacheKey);
|
|
30487
30539
|
};
|
|
30488
30540
|
};
|
|
30489
30541
|
|
|
@@ -30640,7 +30692,7 @@ const liveComments = (params, callback, config) => {
|
|
|
30640
30692
|
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
30641
30693
|
.filter(Boolean)
|
|
30642
30694
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30643
|
-
if (params.includeDeleted
|
|
30695
|
+
if (!params.includeDeleted) {
|
|
30644
30696
|
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
30645
30697
|
}
|
|
30646
30698
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
@@ -31323,4 +31375,4 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
31323
31375
|
return { accessToken: data.accessToken };
|
|
31324
31376
|
};
|
|
31325
31377
|
|
|
31326
|
-
export { API_REGIONS, CommunityPostSettingMaps, CommunityPostSettings, ContentFeedType, DefaultCommunityPostSetting, FileType, MARKER_INCLUDED_SUB_CHANNEL_TYPE, MessageContentType, PostContentType, SubscriptionLevels, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRoles, addReaction, approvePost, backupCache, banChannelMembers, closePoll, connectClient, convertFromRaw$1 as convertFromRaw, convertQueryParams, createChannel, createClient, createComment, createCommunity, createFile, createImage, createMessage, createPoll, createPost, createQuery, createReport, createStream, createSubChannel, createUserToken, createVideo, declineFollower, declinePost, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePoll, deletePost, deleteReport, deleteStream, deleteSubChannel, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByChannelMembership, filterByFeedType, filterByPropEquality, filterByPropInclusion, follow, getActiveClient, getActiveUser, getCategory, getChannel, getChannelMarkers, getChannelTopic, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFeedSettings, getFile, getFollowInfo, getMarkerSyncEvents, getMessage, getMessageMarkers, getMessageTopic, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPoll, getPost, getPostTopic, getPosts, getRecommendedCommunities, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStream, getSubChannel, getSubChannelMarkers, getSubChannelTopic, getSubChannels, getTopTrendingCommunities, getTotalUnreadCount, getUnreadCount$1 as getUnreadCount, getUser, getUserMarker, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, isUnreadCountSupport$1 as isUnreadCountSupport, joinChannel, joinCommunity, leaveChannel, leaveCommunity, liveCategories, liveChannel, liveChannelMembers, liveChannels, liveComment, liveComments, liveCommunities, liveCommunity, liveCommunityMembers, liveFollowInfo, liveFollowers, liveFollowings, liveMessage, liveMessages, livePost, livePosts, liveReactions, liveSubChannel, liveSubChannels, liveUser, liveUsers, markAsDelivered, markerSync, markerSyncTrigger, mergeInCache, observeChannel, observeChannels, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePoll, observePost, observePosts, observeUser, onChannelCreated, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelMarkerFetched, onChannelMemberAdded, onChannelMemberBanned, onChannelMemberRemoved, onChannelMemberUnbanned, onChannelMuted, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserChanged, onCommunityUserRemoved, onCommunityUserRoleAdded, onCommunityUserRoleRemoved, onCommunityUserUnbanned, onConnectionError, onFeedMarkerFetched, onFollowInfoUpdated, onFollowRequestAccepted, onFollowRequestCanceled, onFollowRequestDeclined, onFollowerDeleted, onFollowerRequested, onMessageCreated, onMessageDeleted, onMessageFetched, onMessageFlagCleared, onMessageFlagged, onMessageMarkerFetched, onMessageReactionAdded, onMessageReactionRemoved, onMessageUnflagged, onMessageUpdated, onPollDeleted, onPollUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionAdded, onReactionRemoved, onReactorAdded, onReactorRemoved, onSessionStateChange, onStreamRecorded, onStreamStarted, onStreamStopped, onSubChannelCreated, onSubChannelDeleted, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onSubChannelUpdated, onUserDeleted, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserMarkerFetched, onUserUnflagged, onUserUnfollowed, onUserUpdated, prepareSubChannelPayload, pullFromCache, pushMarkerSyncEvent, pushToCache, queryCache, queryCategories, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryReactions, queryRoles, queryStreams, querySubChannels, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRoles, removeReaction, renewal, restoreCache, runQuery, setActiveUser, setMarkerSyncEvents, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortByName, sortBySegmentNumber, startReading, startReadingAPI, startUnreadSync, stopReading, stopReadingAPI, stopUnreadSyncing, subscribeTopic, toPage, toPageRaw, toToken, unbanChannelMembers, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateSubChannel, updateSubChannelMarker, updateUser, upsertInCache, votePoll, wipeCache };
|
|
31378
|
+
export { API_REGIONS, CommunityPostSettingMaps, CommunityPostSettings, ContentFeedType, DefaultCommunityPostSetting, FileType, MARKER_INCLUDED_SUB_CHANNEL_TYPE, MessageContentType, PostContentType, SubscriptionLevels, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRoles, addReaction, approvePost, backupCache, banChannelMembers, closePoll, connectClient, convertFromRaw$1 as convertFromRaw, convertQueryParams, createChannel, createClient, createComment, createCommunity, createFile, createImage, createMessage, createPoll, createPost, createQuery, createReport, createStream, createSubChannel, createUserToken, createVideo, declineFollower, declinePost, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePoll, deletePost, deleteReport, deleteStream, deleteSubChannel, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, follow, getActiveClient, getActiveUser, getCategory, getChannel, getChannelMarkers, getChannelTopic, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFeedSettings, getFile, getFollowInfo, getMarkerSyncEvents, getMessage, getMessageMarkers, getMessageTopic, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPoll, getPost, getPostTopic, getPosts, getRecommendedCommunities, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStream, getSubChannel, getSubChannelMarkers, getSubChannelTopic, getSubChannels, getTopTrendingCommunities, getTotalUnreadCount, getUnreadCount$1 as getUnreadCount, getUser, getUserMarker, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, isUnreadCountSupport$1 as isUnreadCountSupport, joinChannel, joinCommunity, leaveChannel, leaveCommunity, liveCategories, liveChannel, liveChannelMembers, liveChannels, liveComment, liveComments, liveCommunities, liveCommunity, liveCommunityMembers, liveFollowInfo, liveFollowers, liveFollowings, liveMessage, liveMessages, livePost, livePosts, liveReactions, liveSubChannel, liveSubChannels, liveUser, liveUsers, markAsDelivered, markerSync, markerSyncTrigger, mergeInCache, observeChannel, observeChannels, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePoll, observePost, observePosts, observeUser, onChannelCreated, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelMarkerFetched, onChannelMemberAdded, onChannelMemberBanned, onChannelMemberRemoved, onChannelMemberUnbanned, onChannelMuted, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserChanged, onCommunityUserRemoved, onCommunityUserRoleAdded, onCommunityUserRoleRemoved, onCommunityUserUnbanned, onConnectionError, onFeedMarkerFetched, onFollowInfoUpdated, onFollowRequestAccepted, onFollowRequestCanceled, onFollowRequestDeclined, onFollowerDeleted, onFollowerRequested, onMessageCreated, onMessageDeleted, onMessageFetched, onMessageFlagCleared, onMessageFlagged, onMessageMarkerFetched, onMessageReactionAdded, onMessageReactionRemoved, onMessageUnflagged, onMessageUpdated, onPollDeleted, onPollUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionAdded, onReactionRemoved, onReactorAdded, onReactorRemoved, onSessionStateChange, onStreamRecorded, onStreamStarted, onStreamStopped, onSubChannelCreated, onSubChannelDeleted, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onSubChannelUpdated, onUserDeleted, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserMarkerFetched, onUserUnflagged, onUserUnfollowed, onUserUpdated, prepareSubChannelPayload, pullFromCache, pushMarkerSyncEvent, pushToCache, queryCache, queryCategories, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryReactions, queryRoles, queryStreams, querySubChannels, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRoles, removeReaction, renewal, restoreCache, runQuery, setActiveUser, setMarkerSyncEvents, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortByName, sortBySegmentNumber, startReading, startReadingAPI, startUnreadSync, stopReading, stopReadingAPI, stopUnreadSyncing, subscribeTopic, toPage, toPageRaw, toToken, unbanChannelMembers, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateSubChannel, updateSubChannelMarker, updateUser, upsertInCache, votePoll, wipeCache };
|