@amityco/ts-sdk 0.0.1-beta.38 → 0.0.1-beta.39
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/@types/core/model.d.ts +2 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +2 -2
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +1 -2
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +1 -1
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +1 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +8 -0
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/channel/observers/liveChannels.d.ts.map +1 -1
- package/dist/client/api/connectClient.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/core/model/index.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/core/query/paging.d.ts +2 -2
- package/dist/core/query/paging.d.ts.map +1 -1
- package/dist/core/query/tests/paging.test.d.ts +2 -0
- package/dist/core/query/tests/paging.test.d.ts.map +1 -0
- package/dist/index.cjs.js +180 -71
- package/dist/index.esm.js +178 -71
- package/dist/index.umd.js +4 -4
- package/dist/message/api/queryMessages.d.ts +2 -2
- package/dist/message/api/queryMessages.d.ts.map +1 -1
- package/dist/post/observers/livePosts.d.ts +2 -2
- package/dist/post/observers/livePosts.d.ts.map +1 -1
- package/dist/report/api/createReport.d.ts.map +1 -1
- package/dist/report/api/deleteReport.d.ts.map +1 -1
- package/dist/report/api/tests/createReport.test.d.ts +2 -0
- package/dist/report/api/tests/createReport.test.d.ts.map +1 -0
- package/dist/report/api/tests/deleteReport.test.d.ts +2 -0
- package/dist/report/api/tests/deleteReport.test.d.ts.map +1 -0
- package/dist/user/api/queryUsers.d.ts +1 -6
- package/dist/user/api/queryUsers.d.ts.map +1 -1
- package/dist/user/observers/index.d.ts +1 -0
- package/dist/user/observers/index.d.ts.map +1 -1
- package/dist/user/observers/liveUsers.d.ts +18 -0
- package/dist/user/observers/liveUsers.d.ts.map +1 -0
- package/dist/user/observers/tests/liveUsers.test.d.ts +2 -0
- package/dist/user/observers/tests/liveUsers.test.d.ts.map +1 -0
- package/dist/utils/liveObject.d.ts +1 -1
- package/dist/utils/liveObject.d.ts.map +1 -1
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/feed.d.ts +21 -0
- package/dist/utils/tests/dummy/feed.d.ts.map +1 -0
- package/dist/utils/tests/dummy/index.d.ts +1 -0
- package/dist/utils/tests/dummy/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/post.d.ts +9 -0
- package/dist/utils/tests/dummy/post.d.ts.map +1 -1
- package/dist/utils/tests/dummy/user.d.ts +63 -0
- package/dist/utils/tests/dummy/user.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/model.ts +4 -0
- package/src/@types/domains/channel.ts +2 -2
- package/src/@types/domains/feed.ts +1 -3
- package/src/@types/domains/message.ts +4 -1
- package/src/@types/domains/post.ts +1 -1
- package/src/@types/domains/user.ts +14 -0
- package/src/cache/api/tests/ingestInCache.test.ts +2 -0
- package/src/channel/observers/liveChannels.ts +29 -24
- package/src/client/api/connectClient.ts +0 -2
- package/src/core/model/idResolvers.ts +2 -0
- package/src/core/model/identifyModel.ts +1 -0
- package/src/core/model/index.ts +2 -0
- package/src/core/query/filtering.ts +33 -3
- package/src/core/query/paging.ts +5 -4
- package/src/core/query/tests/paging.test.ts +66 -0
- package/src/message/api/queryMessages.ts +7 -7
- package/src/message/api/tests/queryMessages.test.ts +6 -6
- package/src/message/tests/observers/liveMessages.test.ts +4 -4
- package/src/post/observers/livePosts.ts +14 -22
- package/src/post/observers/tests/livePosts.test.ts +65 -8
- package/src/report/api/createReport.ts +1 -6
- package/src/report/api/deleteReport.ts +2 -6
- package/src/report/api/tests/createReport.test.ts +93 -0
- package/src/report/api/tests/deleteReport.test.ts +93 -0
- package/src/user/api/queryUsers.ts +1 -6
- package/src/user/observers/index.ts +1 -0
- package/src/user/observers/liveUsers.ts +162 -0
- package/src/user/observers/tests/liveUsers.test.ts +202 -0
- package/src/utils/tests/dummy/channel.ts +1 -0
- package/src/utils/tests/dummy/feed.ts +13 -0
- package/src/utils/tests/dummy/index.ts +2 -0
- package/src/utils/tests/dummy/post.ts +6 -2
- package/src/utils/tests/dummy/user.ts +36 -0
package/dist/index.cjs.js
CHANGED
|
@@ -177,14 +177,14 @@ const partialMatch = (predicate, candidate) => {
|
|
|
177
177
|
const checkIfShouldGoesToTombstone = (errorCode) => [400400 /* Amity.ServerError.ITEM_NOT_FOUND */, 400300 /* Amity.ServerError.FORBIDDEN */].includes(errorCode);
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
|
-
* Type guard to find if the a given decoded backend token uses "skip
|
|
180
|
+
* Type guard to find if the a given decoded backend token uses "skip" pagination style
|
|
181
181
|
*
|
|
182
182
|
* @param json any json object as extracted from the backend
|
|
183
183
|
* @returns success boolean if the token has either "skip" or "limit" props
|
|
184
184
|
*
|
|
185
185
|
* @hidden
|
|
186
186
|
*/
|
|
187
|
-
const
|
|
187
|
+
const isSkip = (json) => ['skip'].some(prop => prop in json);
|
|
188
188
|
/**
|
|
189
189
|
* Type guard to find if the a given decoded backend token uses "after/before" pagination style
|
|
190
190
|
*
|
|
@@ -284,7 +284,7 @@ const toPage = (token) => {
|
|
|
284
284
|
return undefined;
|
|
285
285
|
// don't try catch, let it throw
|
|
286
286
|
const json = JSON.parse(jsBase64.decode(token));
|
|
287
|
-
if (
|
|
287
|
+
if (isSkip(json)) {
|
|
288
288
|
return {
|
|
289
289
|
after: json.skip,
|
|
290
290
|
limit: json.limit,
|
|
@@ -511,6 +511,7 @@ const idResolvers = {
|
|
|
511
511
|
stream: ({ streamId }) => streamId,
|
|
512
512
|
follow: ({ from, to }) => `${from}#${to}`,
|
|
513
513
|
followCount: ({ userId }) => userId,
|
|
514
|
+
feed: ({ targetId, feedId }) => `${targetId}#${feedId}`,
|
|
514
515
|
};
|
|
515
516
|
/**
|
|
516
517
|
* Retrieve the id resolver matching a domain name
|
|
@@ -548,6 +549,7 @@ const CRITERIAS = {
|
|
|
548
549
|
stream: ['streamId'],
|
|
549
550
|
follow: ['from', 'to'],
|
|
550
551
|
followCount: ['userId', 'followerCount'],
|
|
552
|
+
feed: ['feedId', 'feedType'],
|
|
551
553
|
};
|
|
552
554
|
/** @hidden */
|
|
553
555
|
const hasKeys = (object, needles) => {
|
|
@@ -608,6 +610,7 @@ const PAYLOAD2MODEL = {
|
|
|
608
610
|
videoStreamings: 'stream',
|
|
609
611
|
follows: 'follow',
|
|
610
612
|
followCounts: 'followCount',
|
|
613
|
+
feeds: 'feed',
|
|
611
614
|
};
|
|
612
615
|
/** hidden */
|
|
613
616
|
const hasUpdates = (prevData, nextData) => {
|
|
@@ -1074,10 +1077,36 @@ const filterByChannelMembership = (collection, membership, userId) => {
|
|
|
1074
1077
|
'get',
|
|
1075
1078
|
channelUserCacheKey,
|
|
1076
1079
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1077
|
-
if (membership === 'member'
|
|
1078
|
-
return
|
|
1080
|
+
if (membership === 'member') {
|
|
1081
|
+
return channelUser && channelUser.membership !== 'none';
|
|
1079
1082
|
}
|
|
1080
|
-
|
|
1083
|
+
// only membership value remainging is 'notMember'
|
|
1084
|
+
return !channelUser || channelUser.membership === 'none';
|
|
1085
|
+
});
|
|
1086
|
+
};
|
|
1087
|
+
/**
|
|
1088
|
+
* Filter a channel collection by membership of the userId
|
|
1089
|
+
*
|
|
1090
|
+
* @param collection the channel collection to filter
|
|
1091
|
+
* @param feedType to be filtered by
|
|
1092
|
+
* @returns a filtered collection with items only matching the criteria
|
|
1093
|
+
*
|
|
1094
|
+
* @hidden
|
|
1095
|
+
*/
|
|
1096
|
+
const filterByFeedType = (collection, feedType) => {
|
|
1097
|
+
/*
|
|
1098
|
+
* It is possible that the targetId & feedId are the same for most of the posts
|
|
1099
|
+
* But since cache is in-memory, i've avoided memoizing, to avoid premature
|
|
1100
|
+
* optimization. Can be revisited if performance issues arise
|
|
1101
|
+
*/
|
|
1102
|
+
return collection.filter(({ targetId, feedId }) => {
|
|
1103
|
+
var _a;
|
|
1104
|
+
const feed = (_a = pullFromCache([
|
|
1105
|
+
'feed',
|
|
1106
|
+
'get',
|
|
1107
|
+
getResolver('feed')({ targetId, feedId }),
|
|
1108
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1109
|
+
return feed && feed.feedType === feedType;
|
|
1081
1110
|
});
|
|
1082
1111
|
};
|
|
1083
1112
|
|
|
@@ -20820,7 +20849,7 @@ const connectClient = async (params, sessionHandler, config) => {
|
|
|
20820
20849
|
setSessionState(state);
|
|
20821
20850
|
disconnectClient();
|
|
20822
20851
|
subscriptions.forEach(fn => fn());
|
|
20823
|
-
})
|
|
20852
|
+
}));
|
|
20824
20853
|
return client.ws.connected;
|
|
20825
20854
|
};
|
|
20826
20855
|
|
|
@@ -21509,6 +21538,101 @@ const liveUser = (userId, callback) => {
|
|
|
21509
21538
|
]);
|
|
21510
21539
|
};
|
|
21511
21540
|
|
|
21541
|
+
/**
|
|
21542
|
+
* ```js
|
|
21543
|
+
* import { liveUsers } from '@amityco/ts-sdk'
|
|
21544
|
+
*
|
|
21545
|
+
* let users = []
|
|
21546
|
+
* const unsub = liveUsers({}, response => merge(users, response.data))
|
|
21547
|
+
* ```
|
|
21548
|
+
*
|
|
21549
|
+
* Observe all mutations on a list of {@link Amity.User}s
|
|
21550
|
+
*
|
|
21551
|
+
* @param params for querying users
|
|
21552
|
+
* @param callback the function to call when new data are available
|
|
21553
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the users
|
|
21554
|
+
*
|
|
21555
|
+
* @category Category Live Collection
|
|
21556
|
+
*/
|
|
21557
|
+
const liveUsers = (params, callback, config) => {
|
|
21558
|
+
const { log, cache } = getActiveClient();
|
|
21559
|
+
if (!cache) {
|
|
21560
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
21561
|
+
}
|
|
21562
|
+
const timestamp = Date.now();
|
|
21563
|
+
log(`liveUsers(tmpid: ${timestamp}) > listen`);
|
|
21564
|
+
const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
|
|
21565
|
+
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
21566
|
+
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
21567
|
+
const disposers = [];
|
|
21568
|
+
const cacheKey = ['user', 'collection', {}];
|
|
21569
|
+
const responder = (data) => {
|
|
21570
|
+
var _a, _b;
|
|
21571
|
+
let users = (_a = data.data
|
|
21572
|
+
.map(userId => pullFromCache(['user', 'get', userId]))
|
|
21573
|
+
.filter(Boolean)
|
|
21574
|
+
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
21575
|
+
users = filterByPropEquality(users, 'displayName', params.displayName);
|
|
21576
|
+
switch (params.sortBy) {
|
|
21577
|
+
case 'firstCreated':
|
|
21578
|
+
users = users.sort(sortByFirstCreated);
|
|
21579
|
+
break;
|
|
21580
|
+
case 'lastCreated':
|
|
21581
|
+
users = users.sort(sortByLastCreated);
|
|
21582
|
+
break;
|
|
21583
|
+
default:
|
|
21584
|
+
users = users
|
|
21585
|
+
// this needs to be aligned with the backend data type
|
|
21586
|
+
.map(u => (u.displayName ? u : Object.assign(Object.assign({}, u), { displayName: '' })))
|
|
21587
|
+
// @ts-ignore
|
|
21588
|
+
.sort(sortByDisplayName);
|
|
21589
|
+
}
|
|
21590
|
+
callback({
|
|
21591
|
+
onNextPage: onFetch,
|
|
21592
|
+
data: users,
|
|
21593
|
+
hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
|
|
21594
|
+
loading: data.loading,
|
|
21595
|
+
error: data.error,
|
|
21596
|
+
});
|
|
21597
|
+
};
|
|
21598
|
+
const realtimeRouter = (_) => (user) => {
|
|
21599
|
+
var _a;
|
|
21600
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21601
|
+
if (!collection)
|
|
21602
|
+
return;
|
|
21603
|
+
collection.data = [...new Set([user.userId, ...collection.data])];
|
|
21604
|
+
pushToCache(cacheKey, collection);
|
|
21605
|
+
responder(collection);
|
|
21606
|
+
};
|
|
21607
|
+
const onFetch = () => {
|
|
21608
|
+
var _a, _b, _c;
|
|
21609
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21610
|
+
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
21611
|
+
if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
21612
|
+
return;
|
|
21613
|
+
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 } }));
|
|
21614
|
+
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
21615
|
+
const data = {
|
|
21616
|
+
loading,
|
|
21617
|
+
error,
|
|
21618
|
+
params: { page },
|
|
21619
|
+
data: users,
|
|
21620
|
+
};
|
|
21621
|
+
if (result) {
|
|
21622
|
+
data.data = [...new Set([...users, ...result.map(getResolver('user'))])];
|
|
21623
|
+
}
|
|
21624
|
+
pushToCache(cacheKey, data);
|
|
21625
|
+
responder(data);
|
|
21626
|
+
}, queryOptions(policy));
|
|
21627
|
+
};
|
|
21628
|
+
disposers.push(onUserUpdated(realtimeRouter()), onUserDeleted(realtimeRouter()), onUserFlagged(realtimeRouter()), onUserUnflagged(realtimeRouter()), onUserFlagCleared(realtimeRouter()));
|
|
21629
|
+
onFetch();
|
|
21630
|
+
return () => {
|
|
21631
|
+
log(`liveUsers(tmpid: ${timestamp}) > dispose`);
|
|
21632
|
+
disposers.forEach(fn => fn());
|
|
21633
|
+
};
|
|
21634
|
+
};
|
|
21635
|
+
|
|
21512
21636
|
/**
|
|
21513
21637
|
* ```js
|
|
21514
21638
|
* import { observeUser } from '@amityco/ts-sdk'
|
|
@@ -22190,8 +22314,8 @@ const queryMessages = async (query) => {
|
|
|
22190
22314
|
pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
|
|
22191
22315
|
}
|
|
22192
22316
|
fireEvent('local.message.fetched', { messages });
|
|
22193
|
-
const nextPage =
|
|
22194
|
-
const prevPage =
|
|
22317
|
+
const nextPage = toPageRaw(paging.next);
|
|
22318
|
+
const prevPage = toPageRaw(paging.previous);
|
|
22195
22319
|
return { data: messages, cachedAt, prevPage, nextPage };
|
|
22196
22320
|
};
|
|
22197
22321
|
/**
|
|
@@ -22222,8 +22346,8 @@ queryMessages.locally = (query) => {
|
|
|
22222
22346
|
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
22223
22347
|
.filter(Boolean)
|
|
22224
22348
|
.map(({ data }) => data);
|
|
22225
|
-
const prevPage =
|
|
22226
|
-
const nextPage =
|
|
22349
|
+
const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
22350
|
+
const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
22227
22351
|
return messages.length === ((_b = data === null || data === void 0 ? void 0 : data.messages) === null || _b === void 0 ? void 0 : _b.length)
|
|
22228
22352
|
? { data: messages, cachedAt, prevPage, nextPage }
|
|
22229
22353
|
: undefined;
|
|
@@ -24868,13 +24992,7 @@ const createReport = async (referenceType, referenceId) => {
|
|
|
24868
24992
|
const { data } = await client.http.post(getAPIUrl());
|
|
24869
24993
|
if (client.cache)
|
|
24870
24994
|
ingestInCache(referenceType === 'message' ? prepareMessagePayload(data) : data);
|
|
24871
|
-
|
|
24872
|
-
fireEvent('message.flagged', data);
|
|
24873
|
-
}
|
|
24874
|
-
else {
|
|
24875
|
-
// @ts-ignore
|
|
24876
|
-
fireEvent(`${referenceType}.flagged`, data);
|
|
24877
|
-
}
|
|
24995
|
+
fireEvent(`${referenceType}.flagged`, data);
|
|
24878
24996
|
return !!data;
|
|
24879
24997
|
};
|
|
24880
24998
|
|
|
@@ -24907,13 +25025,8 @@ const deleteReport = async (referenceType, referenceId) => {
|
|
|
24907
25025
|
const { data } = await client.http.delete(getAPIUrl());
|
|
24908
25026
|
if (client.cache)
|
|
24909
25027
|
ingestInCache(referenceType === 'message' ? prepareMessagePayload(data) : data);
|
|
24910
|
-
|
|
24911
|
-
|
|
24912
|
-
}
|
|
24913
|
-
else {
|
|
24914
|
-
// @ts-ignore
|
|
24915
|
-
fireEvent(`${referenceType}.unflagged`, data);
|
|
24916
|
-
}
|
|
25028
|
+
// @ts-ignore
|
|
25029
|
+
fireEvent(`${referenceType}.unflagged`, data);
|
|
24917
25030
|
return !!data;
|
|
24918
25031
|
};
|
|
24919
25032
|
|
|
@@ -26355,22 +26468,29 @@ const liveChannels = (params, callback, config) => {
|
|
|
26355
26468
|
if (params.membership && userId) {
|
|
26356
26469
|
channels = filterByChannelMembership(channels, params.membership, userId);
|
|
26357
26470
|
}
|
|
26358
|
-
|
|
26359
|
-
|
|
26360
|
-
|
|
26361
|
-
|
|
26362
|
-
|
|
26363
|
-
|
|
26364
|
-
|
|
26365
|
-
|
|
26366
|
-
|
|
26367
|
-
|
|
26368
|
-
|
|
26369
|
-
|
|
26370
|
-
|
|
26371
|
-
|
|
26372
|
-
|
|
26373
|
-
|
|
26471
|
+
switch (params.sortBy) {
|
|
26472
|
+
case 'firstCreated':
|
|
26473
|
+
channels = channels.sort(sortByFirstCreated);
|
|
26474
|
+
break;
|
|
26475
|
+
case 'lastCreated':
|
|
26476
|
+
channels = channels.sort(sortByLastCreated);
|
|
26477
|
+
break;
|
|
26478
|
+
case 'displayName':
|
|
26479
|
+
/*
|
|
26480
|
+
* The server returns channels with empty | null displayName's first before
|
|
26481
|
+
* returning sorted list of channels with displayNames
|
|
26482
|
+
*
|
|
26483
|
+
* This section needs to be updated as displayNames can be null as well
|
|
26484
|
+
*/
|
|
26485
|
+
channels = channels
|
|
26486
|
+
// this needs to be aligned with the backend data type
|
|
26487
|
+
.map(c => (c.displayName ? c : Object.assign(Object.assign({}, c), { displayName: '' })))
|
|
26488
|
+
// @ts-ignore
|
|
26489
|
+
.sort(sortByDisplayName);
|
|
26490
|
+
break;
|
|
26491
|
+
default:
|
|
26492
|
+
channels = channels.sort(sortByLastActivity);
|
|
26493
|
+
break;
|
|
26374
26494
|
}
|
|
26375
26495
|
callback({
|
|
26376
26496
|
onNextPage: onFetch,
|
|
@@ -26380,17 +26500,12 @@ const liveChannels = (params, callback, config) => {
|
|
|
26380
26500
|
error: data.error,
|
|
26381
26501
|
});
|
|
26382
26502
|
};
|
|
26383
|
-
const realtimeRouter = (
|
|
26503
|
+
const realtimeRouter = (_) => (channel) => {
|
|
26384
26504
|
var _a;
|
|
26385
26505
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26386
26506
|
if (!collection)
|
|
26387
26507
|
return;
|
|
26388
|
-
|
|
26389
|
-
collection.data = collection.data.filter(c => c !== channel.channelId);
|
|
26390
|
-
}
|
|
26391
|
-
else {
|
|
26392
|
-
collection.data = [...new Set([channel.channelId, ...collection.data])];
|
|
26393
|
-
}
|
|
26508
|
+
collection.data = [...new Set([channel.channelId, ...collection.data])];
|
|
26394
26509
|
pushToCache(cacheKey, collection);
|
|
26395
26510
|
responder(collection);
|
|
26396
26511
|
};
|
|
@@ -26415,7 +26530,7 @@ const liveChannels = (params, callback, config) => {
|
|
|
26415
26530
|
responder(data);
|
|
26416
26531
|
}, queryOptions(policy));
|
|
26417
26532
|
};
|
|
26418
|
-
disposers.push(onChannelCreated(realtimeRouter(
|
|
26533
|
+
disposers.push(onChannelCreated(realtimeRouter()), onChannelDeleted(realtimeRouter()), onChannelUpdated(realtimeRouter()), onChannelMuted(realtimeRouter()), onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onMessageCreated(() => null));
|
|
26419
26534
|
onFetch();
|
|
26420
26535
|
return () => {
|
|
26421
26536
|
log(`liveChannels(tmpid: ${timestamp}) > dispose`);
|
|
@@ -28909,8 +29024,8 @@ const livePost = (postId, callback) => {
|
|
|
28909
29024
|
*
|
|
28910
29025
|
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
28911
29026
|
*
|
|
28912
|
-
* @param targetType the type of the target
|
|
28913
|
-
* @param targetId the ID of the target
|
|
29027
|
+
* @param param.targetType the type of the target
|
|
29028
|
+
* @param param.targetId the ID of the target
|
|
28914
29029
|
* @param callback the function to call when new data are available
|
|
28915
29030
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
28916
29031
|
*
|
|
@@ -28944,6 +29059,9 @@ const livePosts = (params, callback, config) => {
|
|
|
28944
29059
|
if (params.tags) {
|
|
28945
29060
|
posts = posts.filter(p => { var _a; return (_a = p.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.tags) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
|
|
28946
29061
|
}
|
|
29062
|
+
if (params.targetType === 'community' && params.feedType) {
|
|
29063
|
+
posts = filterByFeedType(posts, params.feedType);
|
|
29064
|
+
}
|
|
28947
29065
|
callback({
|
|
28948
29066
|
onNextPage: onFetch,
|
|
28949
29067
|
data: posts,
|
|
@@ -28957,27 +29075,16 @@ const livePosts = (params, callback, config) => {
|
|
|
28957
29075
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28958
29076
|
if (params.targetId !== post.targetId || params.targetType !== post.targetType || !collection)
|
|
28959
29077
|
return;
|
|
28960
|
-
if (['onCreate', 'onApproved'].includes(action)) {
|
|
28961
|
-
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
28962
|
-
}
|
|
28963
|
-
else if (['onDelete', 'onDeclined'].includes(action)) {
|
|
28964
|
-
collection.data = collection.data.filter(p => p !== post.postId);
|
|
28965
|
-
/*
|
|
28966
|
-
* if isDeleted is true, collection should add deleted items to the
|
|
28967
|
-
* begining of the collection
|
|
28968
|
-
*/
|
|
28969
|
-
if (params.isDeleted)
|
|
28970
|
-
collection.data.unshift(post.postId);
|
|
28971
|
-
}
|
|
28972
29078
|
/*
|
|
28973
|
-
*
|
|
28974
|
-
*
|
|
28975
|
-
* The responder should pull the feed from cache once available and should
|
|
28976
|
-
* match the collection to feedType param
|
|
28977
|
-
* https://ekoapp.atlassian.net/browse/ASC-9382
|
|
29079
|
+
* This is not ideal, but currently this is the only way to update the
|
|
29080
|
+
* collection on post declined
|
|
28978
29081
|
*/
|
|
28979
|
-
if (
|
|
28980
|
-
collection.data = collection.data.filter(
|
|
29082
|
+
if (action === 'onDeclined') {
|
|
29083
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
29084
|
+
}
|
|
29085
|
+
else {
|
|
29086
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
29087
|
+
}
|
|
28981
29088
|
pushToCache(cacheKey, collection);
|
|
28982
29089
|
responder(collection);
|
|
28983
29090
|
};
|
|
@@ -29862,6 +29969,7 @@ exports.dropFromCache = dropFromCache;
|
|
|
29862
29969
|
exports.enableCache = enableCache;
|
|
29863
29970
|
exports.fileUrlWithSize = fileUrlWithSize;
|
|
29864
29971
|
exports.filterByChannelMembership = filterByChannelMembership;
|
|
29972
|
+
exports.filterByFeedType = filterByFeedType;
|
|
29865
29973
|
exports.filterByPropEquality = filterByPropEquality;
|
|
29866
29974
|
exports.filterByPropInclusion = filterByPropInclusion;
|
|
29867
29975
|
exports.follow = follow;
|
|
@@ -29913,7 +30021,7 @@ exports.isMutator = isMutator;
|
|
|
29913
30021
|
exports.isOffline = isOffline;
|
|
29914
30022
|
exports.isPaged = isPaged;
|
|
29915
30023
|
exports.isReportedByMe = isReportedByMe;
|
|
29916
|
-
exports.
|
|
30024
|
+
exports.isSkip = isSkip;
|
|
29917
30025
|
exports.joinChannel = joinChannel;
|
|
29918
30026
|
exports.joinCommunity = joinCommunity;
|
|
29919
30027
|
exports.leaveChannel = leaveChannel;
|
|
@@ -29935,6 +30043,7 @@ exports.liveReactions = liveReactions;
|
|
|
29935
30043
|
exports.liveSubChannel = liveSubChannel;
|
|
29936
30044
|
exports.liveSubChannels = liveSubChannels;
|
|
29937
30045
|
exports.liveUser = liveUser;
|
|
30046
|
+
exports.liveUsers = liveUsers;
|
|
29938
30047
|
exports.mergeInCache = mergeInCache;
|
|
29939
30048
|
exports.observeChannel = observeChannel;
|
|
29940
30049
|
exports.observeChannels = observeChannels;
|