@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.cjs.js
CHANGED
|
@@ -95,8 +95,8 @@ const PostContentType = Object.freeze({
|
|
|
95
95
|
|
|
96
96
|
function getVersion() {
|
|
97
97
|
try {
|
|
98
|
-
// the string ''v0.0.1-beta.
|
|
99
|
-
return 'v0.0.1-beta.
|
|
98
|
+
// the string ''v0.0.1-beta.45.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
99
|
+
return 'v0.0.1-beta.45.0-cjs';
|
|
100
100
|
}
|
|
101
101
|
catch (error) {
|
|
102
102
|
return '__dev__';
|
|
@@ -1174,6 +1174,37 @@ const filterByCommunityMembership = (collection, membership, userId) => {
|
|
|
1174
1174
|
// only membership value remainging is 'notMember'
|
|
1175
1175
|
return !communityUser || communityUser.communityMembership !== 'none';
|
|
1176
1176
|
});
|
|
1177
|
+
};
|
|
1178
|
+
/**
|
|
1179
|
+
* Filter a post collection by dataType
|
|
1180
|
+
*
|
|
1181
|
+
* @param collection the post to filter
|
|
1182
|
+
* @param dataTypes of the post to be filtered by
|
|
1183
|
+
* @returns a filtered collection with items only matching the criteria
|
|
1184
|
+
*
|
|
1185
|
+
* @hidden
|
|
1186
|
+
*/
|
|
1187
|
+
const filterByPostDataTypes = (collection, dataTypes) => {
|
|
1188
|
+
const filteredPosts = [];
|
|
1189
|
+
collection.forEach(c => {
|
|
1190
|
+
var _a;
|
|
1191
|
+
/*
|
|
1192
|
+
* A text post with no children is just a text post
|
|
1193
|
+
*/
|
|
1194
|
+
if (c.dataType === 'text' && !c.children.length)
|
|
1195
|
+
return;
|
|
1196
|
+
if (c.children.length) {
|
|
1197
|
+
const childPost = (_a = pullFromCache(['post', 'get', c.children[0]])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1198
|
+
if (childPost && (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(childPost === null || childPost === void 0 ? void 0 : childPost.dataType))) {
|
|
1199
|
+
// @ts-ignore
|
|
1200
|
+
filteredPosts.push(childPost);
|
|
1201
|
+
}
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
if (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(c.dataType))
|
|
1205
|
+
filteredPosts.push(c);
|
|
1206
|
+
});
|
|
1207
|
+
return filteredPosts;
|
|
1177
1208
|
};
|
|
1178
1209
|
|
|
1179
1210
|
// Note:
|
|
@@ -20884,7 +20915,7 @@ const connectClient = async (params, sessionHandler, config) => {
|
|
|
20884
20915
|
* Cannot push to subscriptions as watcher needs to continue working even if
|
|
20885
20916
|
* token expires
|
|
20886
20917
|
*/
|
|
20887
|
-
unsubWatcher = client.accessTokenExpiryWatcher((_b = client.token) === null || _b === void 0 ? void 0 : _b.
|
|
20918
|
+
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);
|
|
20888
20919
|
setActiveUser(users[0]);
|
|
20889
20920
|
}
|
|
20890
20921
|
catch (error) {
|
|
@@ -21595,6 +21626,22 @@ const prepareMessagePayloadForCache = (payload) => {
|
|
|
21595
21626
|
}
|
|
21596
21627
|
};
|
|
21597
21628
|
|
|
21629
|
+
/*
|
|
21630
|
+
* This is a simple utility that infers the value of isDeleted based on the
|
|
21631
|
+
* value of includeDeleted
|
|
21632
|
+
*
|
|
21633
|
+
* There are two important things to note here:
|
|
21634
|
+
* 1. `includeDeleted` is purely client side query param and not recognized by
|
|
21635
|
+
* the server
|
|
21636
|
+
* 2. The only values we wish to expose with regards to `isDeleted` (the server
|
|
21637
|
+
* param for queries) is false | undefined and want to disallow users to query
|
|
21638
|
+
* for deleted entities
|
|
21639
|
+
*
|
|
21640
|
+
* Although this is a very simple utility, it's only purpose is to keep things
|
|
21641
|
+
* DRY
|
|
21642
|
+
*/
|
|
21643
|
+
const inferIsDeleted = (includeDeleted) => includeDeleted === true ? undefined : false;
|
|
21644
|
+
|
|
21598
21645
|
const getCachedMarker$1 = (message) => {
|
|
21599
21646
|
var _a, _b;
|
|
21600
21647
|
const key = {
|
|
@@ -21673,7 +21720,7 @@ function convertParams(_a) {
|
|
|
21673
21720
|
}
|
|
21674
21721
|
function convertQueryParams$1(_a) {
|
|
21675
21722
|
var { page, sortBy, subChannelId, tags, includeDeleted } = _a, rest = __rest(_a, ["page", "sortBy", "subChannelId", "tags", "includeDeleted"]);
|
|
21676
|
-
const out = Object.assign(Object.assign({}, rest), { messageFeedId: subChannelId, isDeleted: includeDeleted
|
|
21723
|
+
const out = Object.assign(Object.assign({}, rest), { messageFeedId: subChannelId, isDeleted: inferIsDeleted(includeDeleted), options: { token: toToken(page || { limit: 10 }, 'afterbeforeraw') } });
|
|
21677
21724
|
if (sortBy !== undefined) {
|
|
21678
21725
|
out.options.sortBy = sortBy;
|
|
21679
21726
|
}
|
|
@@ -22882,13 +22929,13 @@ const liveUsers = (params, callback, config) => {
|
|
|
22882
22929
|
pushToCache(cacheKey, collection);
|
|
22883
22930
|
responder(collection);
|
|
22884
22931
|
};
|
|
22885
|
-
const onFetch = () => {
|
|
22932
|
+
const onFetch = (initial = false) => {
|
|
22886
22933
|
var _a, _b, _c;
|
|
22887
22934
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22888
22935
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
22889
|
-
if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
22936
|
+
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
22890
22937
|
return;
|
|
22891
|
-
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 } }));
|
|
22938
|
+
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 } }));
|
|
22892
22939
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
22893
22940
|
const data = {
|
|
22894
22941
|
loading,
|
|
@@ -22904,7 +22951,7 @@ const liveUsers = (params, callback, config) => {
|
|
|
22904
22951
|
}, queryOptions(policy));
|
|
22905
22952
|
};
|
|
22906
22953
|
disposers.push(onUserUpdated(realtimeRouter()), onUserDeleted(realtimeRouter()), onUserFlagged(realtimeRouter()), onUserUnflagged(realtimeRouter()), onUserFlagCleared(realtimeRouter()));
|
|
22907
|
-
onFetch();
|
|
22954
|
+
onFetch(true);
|
|
22908
22955
|
return () => {
|
|
22909
22956
|
log(`liveUsers(tmpid: ${timestamp}) > dispose`);
|
|
22910
22957
|
disposers.forEach(fn => fn());
|
|
@@ -23515,52 +23562,23 @@ const queryMessages = async (query) => {
|
|
|
23515
23562
|
const data = await prepareMessagePayload(payload);
|
|
23516
23563
|
const { messages } = data;
|
|
23517
23564
|
const cachedAt = client.cache && Date.now();
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23565
|
+
if (client.cache) {
|
|
23566
|
+
/*
|
|
23567
|
+
* queryMessages.locally is unsupported for messages as message list updates
|
|
23568
|
+
* frequently and leads to bugs when user switches between channels, i.e. when
|
|
23569
|
+
* the public function (live messages) calls unmount. The list fetched on
|
|
23570
|
+
* after from the cache is stale.
|
|
23571
|
+
*/
|
|
23572
|
+
ingestInCache(data, { cachedAt });
|
|
23573
|
+
const cacheKey = ['message', 'query', params];
|
|
23574
|
+
pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
|
|
23575
|
+
}
|
|
23524
23576
|
fireEvent('local.message.fetched', { messages });
|
|
23525
23577
|
const nextPage = toPageRaw(paging.next);
|
|
23526
23578
|
const prevPage = toPageRaw(paging.previous);
|
|
23527
23579
|
return { data: messages, cachedAt, prevPage, nextPage };
|
|
23528
23580
|
};
|
|
23529
|
-
/* end_public_function */
|
|
23530
|
-
/**
|
|
23531
|
-
* ```js
|
|
23532
|
-
* import { queryMessages } from '@amityco/ts-sdk'
|
|
23533
|
-
* const messages = queryMessages.locally!({ channelId })
|
|
23534
|
-
* ```
|
|
23535
|
-
*
|
|
23536
|
-
* Queries a paginable list of {@link Amity.Message} objects from cache
|
|
23537
|
-
*
|
|
23538
|
-
* @param query The query parameters
|
|
23539
|
-
* @returns A page of {@link Amity.Message} objects
|
|
23540
|
-
*
|
|
23541
|
-
* @category Message API
|
|
23542
|
-
*/
|
|
23543
|
-
queryMessages.locally = (query) => {
|
|
23544
|
-
var _a, _b;
|
|
23545
|
-
const client = getActiveClient();
|
|
23546
|
-
client.log('message/queryMessages.locally', query);
|
|
23547
|
-
if (!client.cache)
|
|
23548
|
-
return;
|
|
23549
|
-
const params = convertQueryParams$1(query);
|
|
23550
|
-
const queryKey = ['message', 'query', params];
|
|
23551
|
-
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
23552
|
-
if (!(data === null || data === void 0 ? void 0 : data.messages.length))
|
|
23553
|
-
return;
|
|
23554
|
-
const messages = data.messages
|
|
23555
|
-
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
23556
|
-
.filter(Boolean)
|
|
23557
|
-
.map(({ data }) => data);
|
|
23558
|
-
const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
23559
|
-
const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
23560
|
-
return messages.length === ((_b = data === null || data === void 0 ? void 0 : data.messages) === null || _b === void 0 ? void 0 : _b.length)
|
|
23561
|
-
? { data: messages, cachedAt, prevPage, nextPage }
|
|
23562
|
-
: undefined;
|
|
23563
|
-
};
|
|
23581
|
+
/* end_public_function */
|
|
23564
23582
|
|
|
23565
23583
|
const uuid = () => nativeIdGenerator__default["default"].v4().toString();
|
|
23566
23584
|
|
|
@@ -23904,7 +23922,7 @@ const queryPosts = async (query) => {
|
|
|
23904
23922
|
// API-FIX: backend should answer Amity.Response (2)
|
|
23905
23923
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
|
|
23906
23924
|
const { data } = await client.http.get(`/api/v4/posts`, {
|
|
23907
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
23925
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
23908
23926
|
/*
|
|
23909
23927
|
* when creating post like image, file, video BE will create 2 posts
|
|
23910
23928
|
* 1. parent post to store text with dataType=text
|
|
@@ -24249,7 +24267,7 @@ const queryCommunities = async (query) => {
|
|
|
24249
24267
|
// API-FIX: backend doesnt answer Amity.Response
|
|
24250
24268
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
|
|
24251
24269
|
const { data } = await client.http.get(`/api/v3/communities`, {
|
|
24252
|
-
params: Object.assign(Object.assign({}, restParams), { isDeleted: includeDeleted
|
|
24270
|
+
params: Object.assign(Object.assign({}, restParams), { isDeleted: inferIsDeleted(includeDeleted), keyword: displayName, filter: membership, options: {
|
|
24253
24271
|
token: toToken(page, 'skiplimit'),
|
|
24254
24272
|
} }),
|
|
24255
24273
|
});
|
|
@@ -25100,7 +25118,7 @@ const queryComments = async (query) => {
|
|
|
25100
25118
|
// API-FIX: backend should answer Amity.Response (2)
|
|
25101
25119
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.CommentPayload>>>(
|
|
25102
25120
|
const { data } = await client.http.get(`/api/v3/comments`, {
|
|
25103
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
25121
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
25104
25122
|
// filterByParentId, API-FIX: backend does not support this boolean LOL. what the hell seriously.
|
|
25105
25123
|
options }),
|
|
25106
25124
|
});
|
|
@@ -26384,13 +26402,13 @@ const liveReactions = (params, callback, config) => {
|
|
|
26384
26402
|
pushToCache(cacheKey, collection);
|
|
26385
26403
|
responder(collection);
|
|
26386
26404
|
};
|
|
26387
|
-
const onFetch = () => {
|
|
26388
|
-
var _a, _b, _c, _d
|
|
26405
|
+
const onFetch = (initial = false) => {
|
|
26406
|
+
var _a, _b, _c, _d;
|
|
26389
26407
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26390
26408
|
const reactions = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
26391
|
-
if (reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26409
|
+
if (!initial && reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26392
26410
|
return;
|
|
26393
|
-
const query = createQuery(queryReactions, Object.assign(Object.assign({}, queryParams), { page: (
|
|
26411
|
+
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 } }));
|
|
26394
26412
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
26395
26413
|
const data = {
|
|
26396
26414
|
loading,
|
|
@@ -26408,7 +26426,7 @@ const liveReactions = (params, callback, config) => {
|
|
|
26408
26426
|
}, queryOptions(policy));
|
|
26409
26427
|
};
|
|
26410
26428
|
disposers.push(onReactorAdded(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onAdded')), onReactorRemoved(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onRemoved')));
|
|
26411
|
-
onFetch();
|
|
26429
|
+
onFetch(true);
|
|
26412
26430
|
return () => {
|
|
26413
26431
|
log(`liveReactions(tmpid: ${timestamp}) > dispose`);
|
|
26414
26432
|
disposers.forEach(fn => fn());
|
|
@@ -27769,13 +27787,13 @@ const liveChannels = (params, callback, config) => {
|
|
|
27769
27787
|
pushToCache(cacheKey, collection);
|
|
27770
27788
|
responder(collection);
|
|
27771
27789
|
};
|
|
27772
|
-
const onFetch = () => {
|
|
27790
|
+
const onFetch = (initial = false) => {
|
|
27773
27791
|
var _a, _b, _c;
|
|
27774
27792
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27775
27793
|
const channels = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27776
|
-
if (channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27794
|
+
if (!initial && channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27777
27795
|
return;
|
|
27778
|
-
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 } }));
|
|
27796
|
+
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 } }));
|
|
27779
27797
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27780
27798
|
const data = {
|
|
27781
27799
|
loading,
|
|
@@ -27791,7 +27809,7 @@ const liveChannels = (params, callback, config) => {
|
|
|
27791
27809
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
27792
27810
|
};
|
|
27793
27811
|
disposers.push(onChannelCreated(realtimeRouter()), onChannelDeleted(realtimeRouter()), onChannelUpdated(realtimeRouter()), onChannelMuted(realtimeRouter()), onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onMessageCreated(() => null));
|
|
27794
|
-
onFetch();
|
|
27812
|
+
onFetch(true);
|
|
27795
27813
|
return () => {
|
|
27796
27814
|
log(`liveChannels(tmpid: ${timestamp}) > dispose`);
|
|
27797
27815
|
disposers.forEach(fn => fn());
|
|
@@ -27888,13 +27906,13 @@ const liveChannelMembers = (params, callback, config) => {
|
|
|
27888
27906
|
pushToCache(cacheKey, collection);
|
|
27889
27907
|
responder(collection);
|
|
27890
27908
|
};
|
|
27891
|
-
const onFetch = () => {
|
|
27909
|
+
const onFetch = (initial = false) => {
|
|
27892
27910
|
var _a, _b, _c;
|
|
27893
27911
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27894
27912
|
const channelMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27895
|
-
if (channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27913
|
+
if (!initial && channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27896
27914
|
return;
|
|
27897
|
-
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 } }));
|
|
27915
|
+
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 } }));
|
|
27898
27916
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27899
27917
|
const data = {
|
|
27900
27918
|
loading,
|
|
@@ -27910,7 +27928,7 @@ const liveChannelMembers = (params, callback, config) => {
|
|
|
27910
27928
|
}, queryOptions(policy));
|
|
27911
27929
|
};
|
|
27912
27930
|
disposers.push(onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onChannelMemberBanned(realtimeRouter()), onChannelMemberUnbanned(realtimeRouter()));
|
|
27913
|
-
onFetch();
|
|
27931
|
+
onFetch(true);
|
|
27914
27932
|
return () => {
|
|
27915
27933
|
log(`liveChannelMembers(tmpid: ${timestamp}) > dispose`);
|
|
27916
27934
|
disposers.forEach(fn => fn());
|
|
@@ -27939,7 +27957,7 @@ const querySubChannels = async (query) => {
|
|
|
27939
27957
|
client.log('channel/querySubChannels', query);
|
|
27940
27958
|
const _a = convertQueryParams(query), { page = { limit: 10 }, channelId, includeDeleted } = _a, params = __rest(_a, ["page", "channelId", "includeDeleted"]);
|
|
27941
27959
|
const response = await client.http.get(`/api/v5/message-feeds/channel/${channelId}`, {
|
|
27942
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
27960
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
27943
27961
|
token: toToken(page, 'skiplimit'),
|
|
27944
27962
|
} }),
|
|
27945
27963
|
});
|
|
@@ -28322,7 +28340,7 @@ const liveSubChannels = (params, callback, config) => {
|
|
|
28322
28340
|
const responder = (data) => {
|
|
28323
28341
|
var _a;
|
|
28324
28342
|
let subChannels = data.data;
|
|
28325
|
-
if (params.includeDeleted
|
|
28343
|
+
if (!params.includeDeleted) {
|
|
28326
28344
|
subChannels = filterByPropEquality(subChannels, 'isDeleted', false);
|
|
28327
28345
|
}
|
|
28328
28346
|
subChannels.sort(sortByLastActivity);
|
|
@@ -28446,7 +28464,7 @@ const liveMessages = (params, callback, config) => {
|
|
|
28446
28464
|
* for cases when message is deleted via RTE, this flag is used to get
|
|
28447
28465
|
* items from cache that are !deleted
|
|
28448
28466
|
*/
|
|
28449
|
-
if (params.includeDeleted
|
|
28467
|
+
if (!params.includeDeleted) {
|
|
28450
28468
|
messages = filterByPropEquality(messages, 'isDeleted', false);
|
|
28451
28469
|
}
|
|
28452
28470
|
callback({
|
|
@@ -28466,13 +28484,13 @@ const liveMessages = (params, callback, config) => {
|
|
|
28466
28484
|
pushToCache(cacheKey, collection);
|
|
28467
28485
|
responder(collection);
|
|
28468
28486
|
};
|
|
28469
|
-
const onFetch = () => {
|
|
28470
|
-
var _a, _b, _c, _d
|
|
28487
|
+
const onFetch = (initial = false) => {
|
|
28488
|
+
var _a, _b, _c, _d;
|
|
28471
28489
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28472
28490
|
const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28473
|
-
if (messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28491
|
+
if (!initial && messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28474
28492
|
return;
|
|
28475
|
-
const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (
|
|
28493
|
+
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 } }));
|
|
28476
28494
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
28477
28495
|
const data = {
|
|
28478
28496
|
loading,
|
|
@@ -28488,11 +28506,11 @@ const liveMessages = (params, callback, config) => {
|
|
|
28488
28506
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
28489
28507
|
};
|
|
28490
28508
|
disposers.push(onMessageFetched(realtimeRouter()), onMessageCreated(realtimeRouter()), onMessageUpdated(realtimeRouter()), onMessageDeleted(realtimeRouter()), onMessageFlagged(realtimeRouter()), onMessageUnflagged(realtimeRouter()), onMessageFlagCleared(realtimeRouter()), onMessageReactionAdded(realtimeRouter()), onMessageReactionRemoved(realtimeRouter()));
|
|
28491
|
-
onFetch();
|
|
28509
|
+
onFetch(true);
|
|
28510
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
28492
28511
|
return () => {
|
|
28493
28512
|
log(`liveMessages(tmpid: ${timestamp}) > dispose`);
|
|
28494
28513
|
disposers.forEach(fn => fn());
|
|
28495
|
-
dropFromCache(cacheKey);
|
|
28496
28514
|
};
|
|
28497
28515
|
};
|
|
28498
28516
|
|
|
@@ -28969,7 +28987,7 @@ const liveCommunities = (params, callback, config) => {
|
|
|
28969
28987
|
.filter(Boolean)
|
|
28970
28988
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
28971
28989
|
communities = filterByPropEquality(communities, 'displayName', params.displayName);
|
|
28972
|
-
if (params.includeDeleted
|
|
28990
|
+
if (!params.includeDeleted) {
|
|
28973
28991
|
communities = filterByPropEquality(communities, 'isDeleted', false);
|
|
28974
28992
|
}
|
|
28975
28993
|
if (params.categoryId) {
|
|
@@ -29018,13 +29036,13 @@ const liveCommunities = (params, callback, config) => {
|
|
|
29018
29036
|
pushToCache(cacheKey, collection);
|
|
29019
29037
|
responder(collection);
|
|
29020
29038
|
};
|
|
29021
|
-
const onFetch = () => {
|
|
29039
|
+
const onFetch = (initial = false) => {
|
|
29022
29040
|
var _a, _b, _c;
|
|
29023
29041
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29024
29042
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29025
|
-
if (communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29043
|
+
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29026
29044
|
return;
|
|
29027
|
-
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 } }));
|
|
29045
|
+
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 } }));
|
|
29028
29046
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
29029
29047
|
const data = {
|
|
29030
29048
|
loading,
|
|
@@ -29040,7 +29058,7 @@ const liveCommunities = (params, callback, config) => {
|
|
|
29040
29058
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
29041
29059
|
};
|
|
29042
29060
|
disposers.push(onCommunityCreated(realtimeRouter()), onCommunityDeleted(realtimeRouter()), onCommunityUpdated(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityLeft(realtimeRouter()), onCommunityUserChanged(realtimeRouter()));
|
|
29043
|
-
onFetch();
|
|
29061
|
+
onFetch(true);
|
|
29044
29062
|
return () => {
|
|
29045
29063
|
log(`liveCommunities(tmpid: ${timestamp}) > dispose`);
|
|
29046
29064
|
disposers.forEach(fn => fn());
|
|
@@ -29160,13 +29178,13 @@ const liveCommunityMembers = (params, callback, config) => {
|
|
|
29160
29178
|
pushToCache(cacheKey, collection);
|
|
29161
29179
|
responder(collection);
|
|
29162
29180
|
};
|
|
29163
|
-
const onFetch = () => {
|
|
29181
|
+
const onFetch = (initial = false) => {
|
|
29164
29182
|
var _a, _b, _c;
|
|
29165
29183
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29166
29184
|
const communityMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29167
|
-
if (communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29185
|
+
if (!initial && communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29168
29186
|
return;
|
|
29169
|
-
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 } }));
|
|
29187
|
+
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 } }));
|
|
29170
29188
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
29171
29189
|
const data = {
|
|
29172
29190
|
loading,
|
|
@@ -29184,7 +29202,7 @@ const liveCommunityMembers = (params, callback, config) => {
|
|
|
29184
29202
|
}, queryOptions(policy));
|
|
29185
29203
|
};
|
|
29186
29204
|
disposers.push(onCommunityLeft(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityUserBanned(realtimeRouter()), onCommunityUserUnbanned(realtimeRouter()), onCommunityUserChanged(realtimeRouter()), onCommunityUserRoleAdded(realtimeRouter()), onCommunityUserRoleRemoved(realtimeRouter()));
|
|
29187
|
-
onFetch();
|
|
29205
|
+
onFetch(true);
|
|
29188
29206
|
return () => {
|
|
29189
29207
|
log(`liveCommunityMembers(tmpid: ${timestamp}) > dispose`);
|
|
29190
29208
|
disposers.forEach(fn => fn());
|
|
@@ -29213,7 +29231,7 @@ const queryCategories = async (query) => {
|
|
|
29213
29231
|
client.log('category/queryCategories', query);
|
|
29214
29232
|
const _a = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 }, includeDeleted } = _a, params = __rest(_a, ["page", "includeDeleted"]);
|
|
29215
29233
|
const { data } = await client.http.get(`/api/v3/community-categories`, {
|
|
29216
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
29234
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
29217
29235
|
token: toToken(page, 'skiplimit'),
|
|
29218
29236
|
} }),
|
|
29219
29237
|
});
|
|
@@ -29356,7 +29374,7 @@ const liveCategories = (params, callback, config) => {
|
|
|
29356
29374
|
.map(categoryId => pullFromCache(['category', 'get', categoryId]))
|
|
29357
29375
|
.filter(Boolean)
|
|
29358
29376
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
29359
|
-
if (params.includeDeleted
|
|
29377
|
+
if (!params.includeDeleted) {
|
|
29360
29378
|
categories = filterByPropEquality(categories, 'isDeleted', false);
|
|
29361
29379
|
}
|
|
29362
29380
|
switch (params.sortBy) {
|
|
@@ -29383,13 +29401,13 @@ const liveCategories = (params, callback, config) => {
|
|
|
29383
29401
|
* observers
|
|
29384
29402
|
*};
|
|
29385
29403
|
*/
|
|
29386
|
-
const onFetch = () => {
|
|
29404
|
+
const onFetch = (initial = false) => {
|
|
29387
29405
|
var _a, _b, _c;
|
|
29388
29406
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29389
29407
|
const categories = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29390
|
-
if (categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29408
|
+
if (!initial && categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29391
29409
|
return;
|
|
29392
|
-
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 } }));
|
|
29410
|
+
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 } }));
|
|
29393
29411
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
29394
29412
|
const data = {
|
|
29395
29413
|
loading,
|
|
@@ -29407,7 +29425,7 @@ const liveCategories = (params, callback, config) => {
|
|
|
29407
29425
|
disposers.push(() => {
|
|
29408
29426
|
// @TODO -> update once observers added
|
|
29409
29427
|
});
|
|
29410
|
-
onFetch();
|
|
29428
|
+
onFetch(true);
|
|
29411
29429
|
return () => {
|
|
29412
29430
|
log(`liveCategories(tmpid: ${timestamp}) > dispose`);
|
|
29413
29431
|
disposers.forEach(fn => fn());
|
|
@@ -30164,13 +30182,13 @@ const liveFollowers = (params, callback, config) => {
|
|
|
30164
30182
|
pushToCache(cacheKey, collection);
|
|
30165
30183
|
responder(collection);
|
|
30166
30184
|
};
|
|
30167
|
-
const onFetch = () => {
|
|
30168
|
-
var _a, _b, _c, _d
|
|
30185
|
+
const onFetch = (initial = false) => {
|
|
30186
|
+
var _a, _b, _c, _d;
|
|
30169
30187
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30170
30188
|
const followers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30171
|
-
if (followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30189
|
+
if (!initial && followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30172
30190
|
return;
|
|
30173
|
-
const query = createQuery(queryFollowers, Object.assign(Object.assign({}, queryParams), { page: (
|
|
30191
|
+
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 } }));
|
|
30174
30192
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30175
30193
|
const data = {
|
|
30176
30194
|
loading,
|
|
@@ -30186,7 +30204,7 @@ const liveFollowers = (params, callback, config) => {
|
|
|
30186
30204
|
}, queryOptions(policy));
|
|
30187
30205
|
};
|
|
30188
30206
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
30189
|
-
onFetch();
|
|
30207
|
+
onFetch(true);
|
|
30190
30208
|
return () => {
|
|
30191
30209
|
log(`liveFollowers(tmpid: ${timestamp}) > dispose`);
|
|
30192
30210
|
disposers.forEach(fn => fn());
|
|
@@ -30254,13 +30272,13 @@ const liveFollowings = (params, callback, config) => {
|
|
|
30254
30272
|
pushToCache(cacheKey, collection);
|
|
30255
30273
|
responder(collection);
|
|
30256
30274
|
};
|
|
30257
|
-
const onFetch = () => {
|
|
30258
|
-
var _a, _b, _c, _d
|
|
30275
|
+
const onFetch = (initial = false) => {
|
|
30276
|
+
var _a, _b, _c, _d;
|
|
30259
30277
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30260
30278
|
const followings = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30261
|
-
if (followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30279
|
+
if (!initial && followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30262
30280
|
return;
|
|
30263
|
-
const query = createQuery(queryFollowings, Object.assign(Object.assign({}, queryParams), { page: (
|
|
30281
|
+
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 } }));
|
|
30264
30282
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30265
30283
|
const data = {
|
|
30266
30284
|
loading,
|
|
@@ -30276,7 +30294,7 @@ const liveFollowings = (params, callback, config) => {
|
|
|
30276
30294
|
}, queryOptions(policy));
|
|
30277
30295
|
};
|
|
30278
30296
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
30279
|
-
onFetch();
|
|
30297
|
+
onFetch(true);
|
|
30280
30298
|
return () => {
|
|
30281
30299
|
log(`liveFollowings(tmpid: ${timestamp}) > dispose`);
|
|
30282
30300
|
disposers.forEach(fn => fn());
|
|
@@ -30460,14 +30478,14 @@ const livePosts = (params, callback, config) => {
|
|
|
30460
30478
|
{ targetId: params.targetId, targetType: params.targetType },
|
|
30461
30479
|
];
|
|
30462
30480
|
const responder = (data) => {
|
|
30463
|
-
var _a, _b;
|
|
30481
|
+
var _a, _b, _c;
|
|
30464
30482
|
let posts = (_a = data.data
|
|
30465
30483
|
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
30466
30484
|
.filter(Boolean)
|
|
30467
30485
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30468
30486
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
30469
30487
|
posts = posts.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
30470
|
-
if (params.includeDeleted
|
|
30488
|
+
if (!params.includeDeleted) {
|
|
30471
30489
|
posts = filterByPropEquality(posts, 'isDeleted', false);
|
|
30472
30490
|
}
|
|
30473
30491
|
if (params.tags) {
|
|
@@ -30476,10 +30494,13 @@ const livePosts = (params, callback, config) => {
|
|
|
30476
30494
|
if (params.targetType === 'community' && params.feedType) {
|
|
30477
30495
|
posts = filterByFeedType(posts, params.feedType);
|
|
30478
30496
|
}
|
|
30497
|
+
if ((_b = params.dataTypes) === null || _b === void 0 ? void 0 : _b.length) {
|
|
30498
|
+
posts = filterByPostDataTypes(posts, params.dataTypes);
|
|
30499
|
+
}
|
|
30479
30500
|
callback({
|
|
30480
30501
|
onNextPage: onFetch,
|
|
30481
30502
|
data: posts,
|
|
30482
|
-
hasNextPage: !!((
|
|
30503
|
+
hasNextPage: !!((_c = data.params) === null || _c === void 0 ? void 0 : _c.page),
|
|
30483
30504
|
loading: data.loading,
|
|
30484
30505
|
error: data.error,
|
|
30485
30506
|
});
|
|
@@ -30500,15 +30521,16 @@ const livePosts = (params, callback, config) => {
|
|
|
30500
30521
|
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
30501
30522
|
}
|
|
30502
30523
|
pushToCache(cacheKey, collection);
|
|
30524
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
30503
30525
|
responder(collection);
|
|
30504
30526
|
};
|
|
30505
|
-
const onFetch = () => {
|
|
30506
|
-
var _a, _b, _c, _d
|
|
30527
|
+
const onFetch = (initial = false) => {
|
|
30528
|
+
var _a, _b, _c, _d;
|
|
30507
30529
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30508
30530
|
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30509
|
-
if (posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30531
|
+
if (!initial && posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30510
30532
|
return;
|
|
30511
|
-
const query = createQuery(queryPosts, Object.assign(Object.assign({}, queryParams), { page: (
|
|
30533
|
+
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 } }));
|
|
30512
30534
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30513
30535
|
const data = {
|
|
30514
30536
|
loading,
|
|
@@ -30524,11 +30546,10 @@ const livePosts = (params, callback, config) => {
|
|
|
30524
30546
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
30525
30547
|
};
|
|
30526
30548
|
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')));
|
|
30527
|
-
onFetch();
|
|
30549
|
+
onFetch(true);
|
|
30528
30550
|
return () => {
|
|
30529
30551
|
log(`livePosts(tmpid: ${timestamp}) > dispose`);
|
|
30530
30552
|
disposers.forEach(fn => fn());
|
|
30531
|
-
dropFromCache(cacheKey);
|
|
30532
30553
|
};
|
|
30533
30554
|
};
|
|
30534
30555
|
|
|
@@ -30685,7 +30706,7 @@ const liveComments = (params, callback, config) => {
|
|
|
30685
30706
|
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
30686
30707
|
.filter(Boolean)
|
|
30687
30708
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30688
|
-
if (params.includeDeleted
|
|
30709
|
+
if (!params.includeDeleted) {
|
|
30689
30710
|
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
30690
30711
|
}
|
|
30691
30712
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
@@ -30714,13 +30735,13 @@ const liveComments = (params, callback, config) => {
|
|
|
30714
30735
|
pushToCache(cacheKey, collection);
|
|
30715
30736
|
responder(collection);
|
|
30716
30737
|
};
|
|
30717
|
-
const onFetch = () => {
|
|
30718
|
-
var _a, _b, _c, _d
|
|
30738
|
+
const onFetch = (initial = false) => {
|
|
30739
|
+
var _a, _b, _c, _d;
|
|
30719
30740
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30720
30741
|
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30721
|
-
if (comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30742
|
+
if (!initial && comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
30722
30743
|
return;
|
|
30723
|
-
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { page: (
|
|
30744
|
+
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 } }));
|
|
30724
30745
|
runQuery(query, ({ data: result, error, loading, prevPage, nextPage }) => {
|
|
30725
30746
|
// depend on sortBy value we have two different pagination type
|
|
30726
30747
|
const page = queryParams.sortBy ? nextPage : prevPage;
|
|
@@ -30738,7 +30759,7 @@ const liveComments = (params, callback, config) => {
|
|
|
30738
30759
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
30739
30760
|
};
|
|
30740
30761
|
disposers.push(onCommentCreated(realtimeRouter('onCreate')), onCommentUpdated(realtimeRouter('onUpdate')), onCommentDeleted(realtimeRouter('onDelete')), onCommentFlagged(realtimeRouter('onFlagged')), onCommentUnflagged(realtimeRouter('onUnflagged')), onCommentReactionAdded(realtimeRouter('onReactionAdded')), onCommentReactionRemoved(realtimeRouter('onReactionRemoved')));
|
|
30741
|
-
onFetch();
|
|
30762
|
+
onFetch(true);
|
|
30742
30763
|
return () => {
|
|
30743
30764
|
log(`liveComments(tmpid: ${timestamp}) > dispose`);
|
|
30744
30765
|
disposers.forEach(fn => fn());
|
|
@@ -31430,6 +31451,7 @@ exports.fileUrlWithSize = fileUrlWithSize;
|
|
|
31430
31451
|
exports.filterByChannelMembership = filterByChannelMembership;
|
|
31431
31452
|
exports.filterByCommunityMembership = filterByCommunityMembership;
|
|
31432
31453
|
exports.filterByFeedType = filterByFeedType;
|
|
31454
|
+
exports.filterByPostDataTypes = filterByPostDataTypes;
|
|
31433
31455
|
exports.filterByPropEquality = filterByPropEquality;
|
|
31434
31456
|
exports.filterByPropInclusion = filterByPropInclusion;
|
|
31435
31457
|
exports.follow = follow;
|