@amityco/ts-sdk 0.0.1-beta.43.1 → 0.0.1-beta.45.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/core/query/filtering.d.ts +10 -0
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/index.cjs.js +136 -114
- package/dist/index.esm.js +136 -115
- 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 +5 -5
- package/src/category/observers/tests/liveCategories.test.ts +7 -5
- package/src/channel/api/tests/removeChannelMembers.test.ts +3 -4
- package/src/channel/observers/liveChannelMembers.ts +4 -4
- package/src/channel/observers/liveChannels.ts +4 -4
- package/src/channel/observers/tests/liveChannels.test.ts +9 -15
- package/src/client/api/connectClient.ts +1 -1
- package/src/comment/api/queryComments.ts +3 -1
- package/src/comment/observers/liveComments.ts +5 -5
- 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 -5
- package/src/community/observers/liveCommunityMembers.ts +4 -4
- package/src/community/observers/tests/liveCommunities.test.ts +7 -7
- package/src/core/query/filtering.ts +38 -0
- package/src/follow/observers/liveFollowers.ts +4 -4
- package/src/follow/observers/liveFollowings.ts +4 -4
- package/src/message/api/queryMessages.ts +15 -50
- package/src/message/api/tests/queryMessages.test.ts +2 -37
- package/src/message/observers/liveMessages.ts +7 -7
- 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 +11 -6
- package/src/post/observers/tests/livePosts.test.ts +10 -4
- package/src/reaction/observers/liveReactions.ts +4 -4
- package/src/subChannel/api/querySubChannels.ts +3 -1
- package/src/subChannel/observers/liveSubChannels.ts +1 -1
- package/src/user/observers/liveUsers.ts +4 -4
- package/src/user/observers/tests/liveUsers.test.ts +3 -9
- 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.45.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
85
|
+
return 'v0.0.1-beta.45.0-esm';
|
|
86
86
|
}
|
|
87
87
|
catch (error) {
|
|
88
88
|
return '__dev__';
|
|
@@ -1160,6 +1160,37 @@ const filterByCommunityMembership = (collection, membership, userId) => {
|
|
|
1160
1160
|
// only membership value remainging is 'notMember'
|
|
1161
1161
|
return !communityUser || communityUser.communityMembership !== 'none';
|
|
1162
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;
|
|
1163
1194
|
};
|
|
1164
1195
|
|
|
1165
1196
|
// Note:
|
|
@@ -20870,7 +20901,7 @@ const connectClient = async (params, sessionHandler, config) => {
|
|
|
20870
20901
|
* Cannot push to subscriptions as watcher needs to continue working even if
|
|
20871
20902
|
* token expires
|
|
20872
20903
|
*/
|
|
20873
|
-
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);
|
|
20874
20905
|
setActiveUser(users[0]);
|
|
20875
20906
|
}
|
|
20876
20907
|
catch (error) {
|
|
@@ -21581,6 +21612,22 @@ const prepareMessagePayloadForCache = (payload) => {
|
|
|
21581
21612
|
}
|
|
21582
21613
|
};
|
|
21583
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
|
+
|
|
21584
21631
|
const getCachedMarker$1 = (message) => {
|
|
21585
21632
|
var _a, _b;
|
|
21586
21633
|
const key = {
|
|
@@ -21659,7 +21706,7 @@ function convertParams(_a) {
|
|
|
21659
21706
|
}
|
|
21660
21707
|
function convertQueryParams$1(_a) {
|
|
21661
21708
|
var { page, sortBy, subChannelId, tags, includeDeleted } = _a, rest = __rest(_a, ["page", "sortBy", "subChannelId", "tags", "includeDeleted"]);
|
|
21662
|
-
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') } });
|
|
21663
21710
|
if (sortBy !== undefined) {
|
|
21664
21711
|
out.options.sortBy = sortBy;
|
|
21665
21712
|
}
|
|
@@ -22868,13 +22915,13 @@ const liveUsers = (params, callback, config) => {
|
|
|
22868
22915
|
pushToCache(cacheKey, collection);
|
|
22869
22916
|
responder(collection);
|
|
22870
22917
|
};
|
|
22871
|
-
const onFetch = () => {
|
|
22918
|
+
const onFetch = (initial = false) => {
|
|
22872
22919
|
var _a, _b, _c;
|
|
22873
22920
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22874
22921
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
22875
|
-
if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
22922
|
+
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
22876
22923
|
return;
|
|
22877
|
-
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
22924
|
+
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
22878
22925
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
22879
22926
|
const data = {
|
|
22880
22927
|
loading,
|
|
@@ -22890,7 +22937,7 @@ const liveUsers = (params, callback, config) => {
|
|
|
22890
22937
|
}, queryOptions(policy));
|
|
22891
22938
|
};
|
|
22892
22939
|
disposers.push(onUserUpdated(realtimeRouter()), onUserDeleted(realtimeRouter()), onUserFlagged(realtimeRouter()), onUserUnflagged(realtimeRouter()), onUserFlagCleared(realtimeRouter()));
|
|
22893
|
-
onFetch();
|
|
22940
|
+
onFetch(true);
|
|
22894
22941
|
return () => {
|
|
22895
22942
|
log(`liveUsers(tmpid: ${timestamp}) > dispose`);
|
|
22896
22943
|
disposers.forEach(fn => fn());
|
|
@@ -23501,52 +23548,23 @@ const queryMessages = async (query) => {
|
|
|
23501
23548
|
const data = await prepareMessagePayload(payload);
|
|
23502
23549
|
const { messages } = data;
|
|
23503
23550
|
const cachedAt = client.cache && Date.now();
|
|
23504
|
-
|
|
23505
|
-
|
|
23506
|
-
|
|
23507
|
-
|
|
23508
|
-
|
|
23509
|
-
|
|
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
|
+
*/
|
|
23558
|
+
ingestInCache(data, { cachedAt });
|
|
23559
|
+
const cacheKey = ['message', 'query', params];
|
|
23560
|
+
pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
|
|
23561
|
+
}
|
|
23510
23562
|
fireEvent('local.message.fetched', { messages });
|
|
23511
23563
|
const nextPage = toPageRaw(paging.next);
|
|
23512
23564
|
const prevPage = toPageRaw(paging.previous);
|
|
23513
23565
|
return { data: messages, cachedAt, prevPage, nextPage };
|
|
23514
23566
|
};
|
|
23515
|
-
/* end_public_function */
|
|
23516
|
-
/**
|
|
23517
|
-
* ```js
|
|
23518
|
-
* import { queryMessages } from '@amityco/ts-sdk'
|
|
23519
|
-
* const messages = queryMessages.locally!({ channelId })
|
|
23520
|
-
* ```
|
|
23521
|
-
*
|
|
23522
|
-
* Queries a paginable list of {@link Amity.Message} objects from cache
|
|
23523
|
-
*
|
|
23524
|
-
* @param query The query parameters
|
|
23525
|
-
* @returns A page of {@link Amity.Message} objects
|
|
23526
|
-
*
|
|
23527
|
-
* @category Message API
|
|
23528
|
-
*/
|
|
23529
|
-
queryMessages.locally = (query) => {
|
|
23530
|
-
var _a, _b;
|
|
23531
|
-
const client = getActiveClient();
|
|
23532
|
-
client.log('message/queryMessages.locally', query);
|
|
23533
|
-
if (!client.cache)
|
|
23534
|
-
return;
|
|
23535
|
-
const params = convertQueryParams$1(query);
|
|
23536
|
-
const queryKey = ['message', 'query', params];
|
|
23537
|
-
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
23538
|
-
if (!(data === null || data === void 0 ? void 0 : data.messages.length))
|
|
23539
|
-
return;
|
|
23540
|
-
const messages = data.messages
|
|
23541
|
-
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
23542
|
-
.filter(Boolean)
|
|
23543
|
-
.map(({ data }) => data);
|
|
23544
|
-
const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
23545
|
-
const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
23546
|
-
return messages.length === ((_b = data === null || data === void 0 ? void 0 : data.messages) === null || _b === void 0 ? void 0 : _b.length)
|
|
23547
|
-
? { data: messages, cachedAt, prevPage, nextPage }
|
|
23548
|
-
: undefined;
|
|
23549
|
-
};
|
|
23567
|
+
/* end_public_function */
|
|
23550
23568
|
|
|
23551
23569
|
const uuid = () => nativeIdGenerator.v4().toString();
|
|
23552
23570
|
|
|
@@ -23890,7 +23908,7 @@ const queryPosts = async (query) => {
|
|
|
23890
23908
|
// API-FIX: backend should answer Amity.Response (2)
|
|
23891
23909
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
|
|
23892
23910
|
const { data } = await client.http.get(`/api/v4/posts`, {
|
|
23893
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
23911
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
23894
23912
|
/*
|
|
23895
23913
|
* when creating post like image, file, video BE will create 2 posts
|
|
23896
23914
|
* 1. parent post to store text with dataType=text
|
|
@@ -24235,7 +24253,7 @@ const queryCommunities = async (query) => {
|
|
|
24235
24253
|
// API-FIX: backend doesnt answer Amity.Response
|
|
24236
24254
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
|
|
24237
24255
|
const { data } = await client.http.get(`/api/v3/communities`, {
|
|
24238
|
-
params: Object.assign(Object.assign({}, restParams), { isDeleted: includeDeleted
|
|
24256
|
+
params: Object.assign(Object.assign({}, restParams), { isDeleted: inferIsDeleted(includeDeleted), keyword: displayName, filter: membership, options: {
|
|
24239
24257
|
token: toToken(page, 'skiplimit'),
|
|
24240
24258
|
} }),
|
|
24241
24259
|
});
|
|
@@ -25086,7 +25104,7 @@ const queryComments = async (query) => {
|
|
|
25086
25104
|
// API-FIX: backend should answer Amity.Response (2)
|
|
25087
25105
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.CommentPayload>>>(
|
|
25088
25106
|
const { data } = await client.http.get(`/api/v3/comments`, {
|
|
25089
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
25107
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
25090
25108
|
// filterByParentId, API-FIX: backend does not support this boolean LOL. what the hell seriously.
|
|
25091
25109
|
options }),
|
|
25092
25110
|
});
|
|
@@ -26370,13 +26388,13 @@ const liveReactions = (params, callback, config) => {
|
|
|
26370
26388
|
pushToCache(cacheKey, collection);
|
|
26371
26389
|
responder(collection);
|
|
26372
26390
|
};
|
|
26373
|
-
const onFetch = () => {
|
|
26374
|
-
var _a, _b, _c, _d
|
|
26391
|
+
const onFetch = (initial = false) => {
|
|
26392
|
+
var _a, _b, _c, _d;
|
|
26375
26393
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26376
26394
|
const reactions = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
26377
|
-
if (reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26395
|
+
if (!initial && reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26378
26396
|
return;
|
|
26379
|
-
const query = createQuery(queryReactions, Object.assign(Object.assign({}, queryParams), { page: (
|
|
26397
|
+
const query = createQuery(queryReactions, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
26380
26398
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
26381
26399
|
const data = {
|
|
26382
26400
|
loading,
|
|
@@ -26394,7 +26412,7 @@ const liveReactions = (params, callback, config) => {
|
|
|
26394
26412
|
}, queryOptions(policy));
|
|
26395
26413
|
};
|
|
26396
26414
|
disposers.push(onReactorAdded(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onAdded')), onReactorRemoved(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onRemoved')));
|
|
26397
|
-
onFetch();
|
|
26415
|
+
onFetch(true);
|
|
26398
26416
|
return () => {
|
|
26399
26417
|
log(`liveReactions(tmpid: ${timestamp}) > dispose`);
|
|
26400
26418
|
disposers.forEach(fn => fn());
|
|
@@ -27755,13 +27773,13 @@ const liveChannels = (params, callback, config) => {
|
|
|
27755
27773
|
pushToCache(cacheKey, collection);
|
|
27756
27774
|
responder(collection);
|
|
27757
27775
|
};
|
|
27758
|
-
const onFetch = () => {
|
|
27776
|
+
const onFetch = (initial = false) => {
|
|
27759
27777
|
var _a, _b, _c;
|
|
27760
27778
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27761
27779
|
const channels = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27762
|
-
if (channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27780
|
+
if (!initial && channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27763
27781
|
return;
|
|
27764
|
-
const query = createQuery(queryChannels, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27782
|
+
const query = createQuery(queryChannels, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27765
27783
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27766
27784
|
const data = {
|
|
27767
27785
|
loading,
|
|
@@ -27777,7 +27795,7 @@ const liveChannels = (params, callback, config) => {
|
|
|
27777
27795
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
27778
27796
|
};
|
|
27779
27797
|
disposers.push(onChannelCreated(realtimeRouter()), onChannelDeleted(realtimeRouter()), onChannelUpdated(realtimeRouter()), onChannelMuted(realtimeRouter()), onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onMessageCreated(() => null));
|
|
27780
|
-
onFetch();
|
|
27798
|
+
onFetch(true);
|
|
27781
27799
|
return () => {
|
|
27782
27800
|
log(`liveChannels(tmpid: ${timestamp}) > dispose`);
|
|
27783
27801
|
disposers.forEach(fn => fn());
|
|
@@ -27874,13 +27892,13 @@ const liveChannelMembers = (params, callback, config) => {
|
|
|
27874
27892
|
pushToCache(cacheKey, collection);
|
|
27875
27893
|
responder(collection);
|
|
27876
27894
|
};
|
|
27877
|
-
const onFetch = () => {
|
|
27895
|
+
const onFetch = (initial = false) => {
|
|
27878
27896
|
var _a, _b, _c;
|
|
27879
27897
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27880
27898
|
const channelMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27881
|
-
if (channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27899
|
+
if (!initial && channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27882
27900
|
return;
|
|
27883
|
-
const query = createQuery(queryChannelMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27901
|
+
const query = createQuery(queryChannelMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27884
27902
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27885
27903
|
const data = {
|
|
27886
27904
|
loading,
|
|
@@ -27896,7 +27914,7 @@ const liveChannelMembers = (params, callback, config) => {
|
|
|
27896
27914
|
}, queryOptions(policy));
|
|
27897
27915
|
};
|
|
27898
27916
|
disposers.push(onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onChannelMemberBanned(realtimeRouter()), onChannelMemberUnbanned(realtimeRouter()));
|
|
27899
|
-
onFetch();
|
|
27917
|
+
onFetch(true);
|
|
27900
27918
|
return () => {
|
|
27901
27919
|
log(`liveChannelMembers(tmpid: ${timestamp}) > dispose`);
|
|
27902
27920
|
disposers.forEach(fn => fn());
|
|
@@ -27925,7 +27943,7 @@ const querySubChannels = async (query) => {
|
|
|
27925
27943
|
client.log('channel/querySubChannels', query);
|
|
27926
27944
|
const _a = convertQueryParams(query), { page = { limit: 10 }, channelId, includeDeleted } = _a, params = __rest(_a, ["page", "channelId", "includeDeleted"]);
|
|
27927
27945
|
const response = await client.http.get(`/api/v5/message-feeds/channel/${channelId}`, {
|
|
27928
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
27946
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
27929
27947
|
token: toToken(page, 'skiplimit'),
|
|
27930
27948
|
} }),
|
|
27931
27949
|
});
|
|
@@ -28308,7 +28326,7 @@ const liveSubChannels = (params, callback, config) => {
|
|
|
28308
28326
|
const responder = (data) => {
|
|
28309
28327
|
var _a;
|
|
28310
28328
|
let subChannels = data.data;
|
|
28311
|
-
if (params.includeDeleted
|
|
28329
|
+
if (!params.includeDeleted) {
|
|
28312
28330
|
subChannels = filterByPropEquality(subChannels, 'isDeleted', false);
|
|
28313
28331
|
}
|
|
28314
28332
|
subChannels.sort(sortByLastActivity);
|
|
@@ -28432,7 +28450,7 @@ const liveMessages = (params, callback, config) => {
|
|
|
28432
28450
|
* for cases when message is deleted via RTE, this flag is used to get
|
|
28433
28451
|
* items from cache that are !deleted
|
|
28434
28452
|
*/
|
|
28435
|
-
if (params.includeDeleted
|
|
28453
|
+
if (!params.includeDeleted) {
|
|
28436
28454
|
messages = filterByPropEquality(messages, 'isDeleted', false);
|
|
28437
28455
|
}
|
|
28438
28456
|
callback({
|
|
@@ -28452,13 +28470,13 @@ const liveMessages = (params, callback, config) => {
|
|
|
28452
28470
|
pushToCache(cacheKey, collection);
|
|
28453
28471
|
responder(collection);
|
|
28454
28472
|
};
|
|
28455
|
-
const onFetch = () => {
|
|
28456
|
-
var _a, _b, _c, _d
|
|
28473
|
+
const onFetch = (initial = false) => {
|
|
28474
|
+
var _a, _b, _c, _d;
|
|
28457
28475
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28458
28476
|
const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28459
|
-
if (messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28477
|
+
if (!initial && messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28460
28478
|
return;
|
|
28461
|
-
const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (
|
|
28479
|
+
const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
28462
28480
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
28463
28481
|
const data = {
|
|
28464
28482
|
loading,
|
|
@@ -28474,11 +28492,11 @@ const liveMessages = (params, callback, config) => {
|
|
|
28474
28492
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
28475
28493
|
};
|
|
28476
28494
|
disposers.push(onMessageFetched(realtimeRouter()), onMessageCreated(realtimeRouter()), onMessageUpdated(realtimeRouter()), onMessageDeleted(realtimeRouter()), onMessageFlagged(realtimeRouter()), onMessageUnflagged(realtimeRouter()), onMessageFlagCleared(realtimeRouter()), onMessageReactionAdded(realtimeRouter()), onMessageReactionRemoved(realtimeRouter()));
|
|
28477
|
-
onFetch();
|
|
28495
|
+
onFetch(true);
|
|
28496
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
28478
28497
|
return () => {
|
|
28479
28498
|
log(`liveMessages(tmpid: ${timestamp}) > dispose`);
|
|
28480
28499
|
disposers.forEach(fn => fn());
|
|
28481
|
-
dropFromCache(cacheKey);
|
|
28482
28500
|
};
|
|
28483
28501
|
};
|
|
28484
28502
|
|
|
@@ -28955,7 +28973,7 @@ const liveCommunities = (params, callback, config) => {
|
|
|
28955
28973
|
.filter(Boolean)
|
|
28956
28974
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
28957
28975
|
communities = filterByPropEquality(communities, 'displayName', params.displayName);
|
|
28958
|
-
if (params.includeDeleted
|
|
28976
|
+
if (!params.includeDeleted) {
|
|
28959
28977
|
communities = filterByPropEquality(communities, 'isDeleted', false);
|
|
28960
28978
|
}
|
|
28961
28979
|
if (params.categoryId) {
|
|
@@ -29004,13 +29022,13 @@ const liveCommunities = (params, callback, config) => {
|
|
|
29004
29022
|
pushToCache(cacheKey, collection);
|
|
29005
29023
|
responder(collection);
|
|
29006
29024
|
};
|
|
29007
|
-
const onFetch = () => {
|
|
29025
|
+
const onFetch = (initial = false) => {
|
|
29008
29026
|
var _a, _b, _c;
|
|
29009
29027
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29010
29028
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29011
|
-
if (communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29029
|
+
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29012
29030
|
return;
|
|
29013
|
-
const query = createQuery(queryCommunities, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
29031
|
+
const query = createQuery(queryCommunities, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
29014
29032
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
29015
29033
|
const data = {
|
|
29016
29034
|
loading,
|
|
@@ -29026,7 +29044,7 @@ const liveCommunities = (params, callback, config) => {
|
|
|
29026
29044
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
29027
29045
|
};
|
|
29028
29046
|
disposers.push(onCommunityCreated(realtimeRouter()), onCommunityDeleted(realtimeRouter()), onCommunityUpdated(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityLeft(realtimeRouter()), onCommunityUserChanged(realtimeRouter()));
|
|
29029
|
-
onFetch();
|
|
29047
|
+
onFetch(true);
|
|
29030
29048
|
return () => {
|
|
29031
29049
|
log(`liveCommunities(tmpid: ${timestamp}) > dispose`);
|
|
29032
29050
|
disposers.forEach(fn => fn());
|
|
@@ -29146,13 +29164,13 @@ const liveCommunityMembers = (params, callback, config) => {
|
|
|
29146
29164
|
pushToCache(cacheKey, collection);
|
|
29147
29165
|
responder(collection);
|
|
29148
29166
|
};
|
|
29149
|
-
const onFetch = () => {
|
|
29167
|
+
const onFetch = (initial = false) => {
|
|
29150
29168
|
var _a, _b, _c;
|
|
29151
29169
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29152
29170
|
const communityMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29153
|
-
if (communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29171
|
+
if (!initial && communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29154
29172
|
return;
|
|
29155
|
-
const query = createQuery(queryCommunityMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
29173
|
+
const query = createQuery(queryCommunityMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
29156
29174
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
29157
29175
|
const data = {
|
|
29158
29176
|
loading,
|
|
@@ -29170,7 +29188,7 @@ const liveCommunityMembers = (params, callback, config) => {
|
|
|
29170
29188
|
}, queryOptions(policy));
|
|
29171
29189
|
};
|
|
29172
29190
|
disposers.push(onCommunityLeft(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityUserBanned(realtimeRouter()), onCommunityUserUnbanned(realtimeRouter()), onCommunityUserChanged(realtimeRouter()), onCommunityUserRoleAdded(realtimeRouter()), onCommunityUserRoleRemoved(realtimeRouter()));
|
|
29173
|
-
onFetch();
|
|
29191
|
+
onFetch(true);
|
|
29174
29192
|
return () => {
|
|
29175
29193
|
log(`liveCommunityMembers(tmpid: ${timestamp}) > dispose`);
|
|
29176
29194
|
disposers.forEach(fn => fn());
|
|
@@ -29199,7 +29217,7 @@ const queryCategories = async (query) => {
|
|
|
29199
29217
|
client.log('category/queryCategories', query);
|
|
29200
29218
|
const _a = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 }, includeDeleted } = _a, params = __rest(_a, ["page", "includeDeleted"]);
|
|
29201
29219
|
const { data } = await client.http.get(`/api/v3/community-categories`, {
|
|
29202
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
29220
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
29203
29221
|
token: toToken(page, 'skiplimit'),
|
|
29204
29222
|
} }),
|
|
29205
29223
|
});
|
|
@@ -29342,7 +29360,7 @@ const liveCategories = (params, callback, config) => {
|
|
|
29342
29360
|
.map(categoryId => pullFromCache(['category', 'get', categoryId]))
|
|
29343
29361
|
.filter(Boolean)
|
|
29344
29362
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
29345
|
-
if (params.includeDeleted
|
|
29363
|
+
if (!params.includeDeleted) {
|
|
29346
29364
|
categories = filterByPropEquality(categories, 'isDeleted', false);
|
|
29347
29365
|
}
|
|
29348
29366
|
switch (params.sortBy) {
|
|
@@ -29369,13 +29387,13 @@ const liveCategories = (params, callback, config) => {
|
|
|
29369
29387
|
* observers
|
|
29370
29388
|
*};
|
|
29371
29389
|
*/
|
|
29372
|
-
const onFetch = () => {
|
|
29390
|
+
const onFetch = (initial = false) => {
|
|
29373
29391
|
var _a, _b, _c;
|
|
29374
29392
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29375
29393
|
const categories = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29376
|
-
if (categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29394
|
+
if (!initial && categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29377
29395
|
return;
|
|
29378
|
-
const query = createQuery(queryCategories, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
29396
|
+
const query = createQuery(queryCategories, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
29379
29397
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
29380
29398
|
const data = {
|
|
29381
29399
|
loading,
|
|
@@ -29393,7 +29411,7 @@ const liveCategories = (params, callback, config) => {
|
|
|
29393
29411
|
disposers.push(() => {
|
|
29394
29412
|
// @TODO -> update once observers added
|
|
29395
29413
|
});
|
|
29396
|
-
onFetch();
|
|
29414
|
+
onFetch(true);
|
|
29397
29415
|
return () => {
|
|
29398
29416
|
log(`liveCategories(tmpid: ${timestamp}) > dispose`);
|
|
29399
29417
|
disposers.forEach(fn => fn());
|
|
@@ -30150,13 +30168,13 @@ const liveFollowers = (params, callback, config) => {
|
|
|
30150
30168
|
pushToCache(cacheKey, collection);
|
|
30151
30169
|
responder(collection);
|
|
30152
30170
|
};
|
|
30153
|
-
const onFetch = () => {
|
|
30154
|
-
var _a, _b, _c, _d
|
|
30171
|
+
const onFetch = (initial = false) => {
|
|
30172
|
+
var _a, _b, _c, _d;
|
|
30155
30173
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30156
30174
|
const followers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30157
|
-
if (followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30175
|
+
if (!initial && followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30158
30176
|
return;
|
|
30159
|
-
const query = createQuery(queryFollowers, Object.assign(Object.assign({}, queryParams), { page: (
|
|
30177
|
+
const query = createQuery(queryFollowers, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
30160
30178
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30161
30179
|
const data = {
|
|
30162
30180
|
loading,
|
|
@@ -30172,7 +30190,7 @@ const liveFollowers = (params, callback, config) => {
|
|
|
30172
30190
|
}, queryOptions(policy));
|
|
30173
30191
|
};
|
|
30174
30192
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
30175
|
-
onFetch();
|
|
30193
|
+
onFetch(true);
|
|
30176
30194
|
return () => {
|
|
30177
30195
|
log(`liveFollowers(tmpid: ${timestamp}) > dispose`);
|
|
30178
30196
|
disposers.forEach(fn => fn());
|
|
@@ -30240,13 +30258,13 @@ const liveFollowings = (params, callback, config) => {
|
|
|
30240
30258
|
pushToCache(cacheKey, collection);
|
|
30241
30259
|
responder(collection);
|
|
30242
30260
|
};
|
|
30243
|
-
const onFetch = () => {
|
|
30244
|
-
var _a, _b, _c, _d
|
|
30261
|
+
const onFetch = (initial = false) => {
|
|
30262
|
+
var _a, _b, _c, _d;
|
|
30245
30263
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30246
30264
|
const followings = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30247
|
-
if (followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30265
|
+
if (!initial && followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30248
30266
|
return;
|
|
30249
|
-
const query = createQuery(queryFollowings, Object.assign(Object.assign({}, queryParams), { page: (
|
|
30267
|
+
const query = createQuery(queryFollowings, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
30250
30268
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30251
30269
|
const data = {
|
|
30252
30270
|
loading,
|
|
@@ -30262,7 +30280,7 @@ const liveFollowings = (params, callback, config) => {
|
|
|
30262
30280
|
}, queryOptions(policy));
|
|
30263
30281
|
};
|
|
30264
30282
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
30265
|
-
onFetch();
|
|
30283
|
+
onFetch(true);
|
|
30266
30284
|
return () => {
|
|
30267
30285
|
log(`liveFollowings(tmpid: ${timestamp}) > dispose`);
|
|
30268
30286
|
disposers.forEach(fn => fn());
|
|
@@ -30446,14 +30464,14 @@ const livePosts = (params, callback, config) => {
|
|
|
30446
30464
|
{ targetId: params.targetId, targetType: params.targetType },
|
|
30447
30465
|
];
|
|
30448
30466
|
const responder = (data) => {
|
|
30449
|
-
var _a, _b;
|
|
30467
|
+
var _a, _b, _c;
|
|
30450
30468
|
let posts = (_a = data.data
|
|
30451
30469
|
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
30452
30470
|
.filter(Boolean)
|
|
30453
30471
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30454
30472
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
30455
30473
|
posts = posts.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
30456
|
-
if (params.includeDeleted
|
|
30474
|
+
if (!params.includeDeleted) {
|
|
30457
30475
|
posts = filterByPropEquality(posts, 'isDeleted', false);
|
|
30458
30476
|
}
|
|
30459
30477
|
if (params.tags) {
|
|
@@ -30462,10 +30480,13 @@ const livePosts = (params, callback, config) => {
|
|
|
30462
30480
|
if (params.targetType === 'community' && params.feedType) {
|
|
30463
30481
|
posts = filterByFeedType(posts, params.feedType);
|
|
30464
30482
|
}
|
|
30483
|
+
if ((_b = params.dataTypes) === null || _b === void 0 ? void 0 : _b.length) {
|
|
30484
|
+
posts = filterByPostDataTypes(posts, params.dataTypes);
|
|
30485
|
+
}
|
|
30465
30486
|
callback({
|
|
30466
30487
|
onNextPage: onFetch,
|
|
30467
30488
|
data: posts,
|
|
30468
|
-
hasNextPage: !!((
|
|
30489
|
+
hasNextPage: !!((_c = data.params) === null || _c === void 0 ? void 0 : _c.page),
|
|
30469
30490
|
loading: data.loading,
|
|
30470
30491
|
error: data.error,
|
|
30471
30492
|
});
|
|
@@ -30486,15 +30507,16 @@ const livePosts = (params, callback, config) => {
|
|
|
30486
30507
|
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
30487
30508
|
}
|
|
30488
30509
|
pushToCache(cacheKey, collection);
|
|
30510
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
30489
30511
|
responder(collection);
|
|
30490
30512
|
};
|
|
30491
|
-
const onFetch = () => {
|
|
30492
|
-
var _a, _b, _c, _d
|
|
30513
|
+
const onFetch = (initial = false) => {
|
|
30514
|
+
var _a, _b, _c, _d;
|
|
30493
30515
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30494
30516
|
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30495
|
-
if (posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30517
|
+
if (!initial && posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30496
30518
|
return;
|
|
30497
|
-
const query = createQuery(queryPosts, Object.assign(Object.assign({}, queryParams), { page: (
|
|
30519
|
+
const query = createQuery(queryPosts, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
30498
30520
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30499
30521
|
const data = {
|
|
30500
30522
|
loading,
|
|
@@ -30510,11 +30532,10 @@ const livePosts = (params, callback, config) => {
|
|
|
30510
30532
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
30511
30533
|
};
|
|
30512
30534
|
disposers.push(onPostCreated(realtimeRouter('onCreate')), onPostApproved(realtimeRouter('onApproved')), onPostDeclined(realtimeRouter('onDeclined')), onPostDeleted(realtimeRouter('onDelete')), onPostUpdated(realtimeRouter('onUpdate')), onPostFlagged(realtimeRouter('onFlagged')), onPostUnflagged(realtimeRouter('onUnflagged')), onPostReactionAdded(realtimeRouter('onReactionAdded')), onPostReactionRemoved(realtimeRouter('onReactionRemoved')));
|
|
30513
|
-
onFetch();
|
|
30535
|
+
onFetch(true);
|
|
30514
30536
|
return () => {
|
|
30515
30537
|
log(`livePosts(tmpid: ${timestamp}) > dispose`);
|
|
30516
30538
|
disposers.forEach(fn => fn());
|
|
30517
|
-
dropFromCache(cacheKey);
|
|
30518
30539
|
};
|
|
30519
30540
|
};
|
|
30520
30541
|
|
|
@@ -30671,7 +30692,7 @@ const liveComments = (params, callback, config) => {
|
|
|
30671
30692
|
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
30672
30693
|
.filter(Boolean)
|
|
30673
30694
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30674
|
-
if (params.includeDeleted
|
|
30695
|
+
if (!params.includeDeleted) {
|
|
30675
30696
|
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
30676
30697
|
}
|
|
30677
30698
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
@@ -30700,13 +30721,13 @@ const liveComments = (params, callback, config) => {
|
|
|
30700
30721
|
pushToCache(cacheKey, collection);
|
|
30701
30722
|
responder(collection);
|
|
30702
30723
|
};
|
|
30703
|
-
const onFetch = () => {
|
|
30704
|
-
var _a, _b, _c, _d
|
|
30724
|
+
const onFetch = (initial = false) => {
|
|
30725
|
+
var _a, _b, _c, _d;
|
|
30705
30726
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30706
30727
|
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30707
|
-
if (comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30728
|
+
if (!initial && comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30708
30729
|
return;
|
|
30709
|
-
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { page: (
|
|
30730
|
+
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
30710
30731
|
runQuery(query, ({ data: result, error, loading, prevPage, nextPage }) => {
|
|
30711
30732
|
// depend on sortBy value we have two different pagination type
|
|
30712
30733
|
const page = queryParams.sortBy ? nextPage : prevPage;
|
|
@@ -30724,7 +30745,7 @@ const liveComments = (params, callback, config) => {
|
|
|
30724
30745
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
30725
30746
|
};
|
|
30726
30747
|
disposers.push(onCommentCreated(realtimeRouter('onCreate')), onCommentUpdated(realtimeRouter('onUpdate')), onCommentDeleted(realtimeRouter('onDelete')), onCommentFlagged(realtimeRouter('onFlagged')), onCommentUnflagged(realtimeRouter('onUnflagged')), onCommentReactionAdded(realtimeRouter('onReactionAdded')), onCommentReactionRemoved(realtimeRouter('onReactionRemoved')));
|
|
30727
|
-
onFetch();
|
|
30748
|
+
onFetch(true);
|
|
30728
30749
|
return () => {
|
|
30729
30750
|
log(`liveComments(tmpid: ${timestamp}) > dispose`);
|
|
30730
30751
|
disposers.forEach(fn => fn());
|
|
@@ -31354,4 +31375,4 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
31354
31375
|
return { accessToken: data.accessToken };
|
|
31355
31376
|
};
|
|
31356
31377
|
|
|
31357
|
-
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, 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 };
|