@amityco/ts-sdk 7.33.2-1fd595a2.0 → 7.33.2-427e58f0.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/@types/domains/follow.d.ts +6 -4
- package/dist/@types/domains/follow.d.ts.map +1 -1
- package/dist/index.cjs.js +32 -41
- package/dist/index.esm.js +32 -41
- package/dist/index.umd.js +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerLiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers/FollowerPaginationController.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts +6 -3
- package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingLiveCollectionController.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings/FollowingPaginationController.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts +1 -11
- package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts.map +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -39,16 +39,18 @@ declare global {
|
|
|
39
39
|
userId: Amity.InternalUser['userId'];
|
|
40
40
|
status?: Exclude<Amity.FollowStatusType, 'none'>;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* the result
|
|
42
|
+
* Followers only: return the follows from these users (up to 100 ids), in one page.
|
|
43
|
+
* A user missing from the result does not follow the signed-in user.
|
|
44
|
+
* Only works on the signed-in user's own followers list.
|
|
45
|
+
* An empty array returns an empty list without a server call.
|
|
44
46
|
*/
|
|
45
47
|
userIds?: Amity.InternalUser['userId'][];
|
|
46
48
|
page?: Amity.PageRaw;
|
|
47
49
|
};
|
|
48
50
|
type FollowerLiveCollection = Amity.LiveCollectionParams<Omit<QueryFollowers, 'page'>>;
|
|
49
51
|
type FollowerLiveCollectionCache = Amity.LiveCollectionCache<Amity.FollowInfo['userId'], Pick<QueryFollowers, 'page'>>;
|
|
50
|
-
type QueryFollowings = QueryFollowers
|
|
51
|
-
type FollowingLiveCollection =
|
|
52
|
+
type QueryFollowings = Omit<QueryFollowers, 'userIds'>;
|
|
53
|
+
type FollowingLiveCollection = Amity.LiveCollectionParams<Omit<QueryFollowings, 'page'>>;
|
|
52
54
|
type FollowingLiveCollectionCache = FollowerLiveCollectionCache;
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/follow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,oBAAoB;YAC7B,WAAW,gBAAgB;YAC3B,UAAU,eAAe;YACzB,UAAU,eAAe;YACzB,UAAU,eAAe;YACzB,UAAU,eAAe;YACzB,YAAY,iBAAiB;YAC7B,SAAS,cAAc;SACxB;QAED,KAAK,gBAAgB,GAAG,GAAG,oBAAoB,EAAE,CAAC;QAElD,WAAW,oBAAoB;YAC7B,GAAG,QAAQ;YACX,OAAO,YAAY;YACnB,QAAQ,aAAa;YACrB,OAAO,YAAY;YACnB,IAAI,SAAS;SACd;QAED,KAAK,gBAAgB,GAAG,GAAG,oBAAoB,EAAE,CAAC;QAElD,KAAK,eAAe,GAAG;YACrB,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACnC,EAAE,EAAE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACjC,MAAM,EAAE,OAAO,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;SAC1C,GAAG,KAAK,CAAC,SAAS,GACjB,KAAK,CAAC,SAAS,CAAC;QAElB,KAAK,oBAAoB,GAAG,KAAK,CAAC,eAAe,CAAC;QAClD,KAAK,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KACjE;CACF"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -395,6 +395,8 @@ const API_ENDPOINTS = {
|
|
|
395
395
|
// The review-queue route defaults to 10, not the SDK-wide page size, and caps at 100
|
|
396
396
|
const COMMENT_REVIEW_QUEUE_DEFAULT_PAGINATION_SIZE = 10;
|
|
397
397
|
const COMMENT_REVIEW_QUEUE_MAX_PAGINATION_SIZE = 100;
|
|
398
|
+
// The me/followers and me/following `userIds` filter takes up to 100 ids, answered in one page
|
|
399
|
+
const FOLLOW_USER_IDS_PAGINATION_LIMIT = 100;
|
|
398
400
|
|
|
399
401
|
// cache constants
|
|
400
402
|
const CACHE_KEY_GET = 'get';
|
|
@@ -11736,19 +11738,25 @@ class PaginationController {
|
|
|
11736
11738
|
|
|
11737
11739
|
class FollowerPaginationController extends PaginationController {
|
|
11738
11740
|
async getRequest(queryParams, token) {
|
|
11739
|
-
|
|
11740
|
-
const { userId, userIds } = queryParams, rest = __rest(queryParams, ["userId", "userIds"]);
|
|
11741
|
-
// An empty `userIds` filter matches nobody; omitting it on the request would
|
|
11742
|
-
// return the unfiltered list instead.
|
|
11743
|
-
if ((userIds === null || userIds === void 0 ? void 0 : userIds.length) === 0)
|
|
11744
|
-
return { follows: [], users: [], files: [], paging: {} };
|
|
11745
|
-
// With `userIds` the whole result fits in one page, so default the limit to it.
|
|
11746
|
-
const { limit = (_a = userIds === null || userIds === void 0 ? void 0 : userIds.length) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT } = rest, params = __rest(rest, ["limit"]);
|
|
11747
|
-
const options = token ? { token } : { limit };
|
|
11741
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId, userIds } = queryParams, params = __rest(queryParams, ["limit", "userId", "userIds"]);
|
|
11748
11742
|
const client = getActiveClient();
|
|
11743
|
+
if (userIds) {
|
|
11744
|
+
// An empty filter matches nobody; sending no ids would return the whole list instead
|
|
11745
|
+
if (userIds.length === 0)
|
|
11746
|
+
return { follows: [], users: [], files: [], paging: {} };
|
|
11747
|
+
if (client.userId !== userId) {
|
|
11748
|
+
throw new ASCInvalidParameterError("userIds can only be used on the signed-in user's own followers list");
|
|
11749
|
+
}
|
|
11750
|
+
// core reads `limit` and `token` only as top-level params, never inside `options`
|
|
11751
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/me/followers`, {
|
|
11752
|
+
params: Object.assign(Object.assign(Object.assign(Object.assign({}, params), { userIds, limit: FOLLOW_USER_IDS_PAGINATION_LIMIT }), (token && { token })), { isDeleted: false }),
|
|
11753
|
+
});
|
|
11754
|
+
return queryResponse;
|
|
11755
|
+
}
|
|
11756
|
+
const options = token ? { token } : { limit };
|
|
11749
11757
|
const path = client.userId === userId ? `/api/v4/me/followers` : `/api/v4/users/${userId}/followers`;
|
|
11750
11758
|
const { data: queryResponse } = await this.http.get(path, {
|
|
11751
|
-
params: Object.assign(Object.assign(
|
|
11759
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
11752
11760
|
});
|
|
11753
11761
|
return queryResponse;
|
|
11754
11762
|
}
|
|
@@ -12024,15 +12032,16 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12024
12032
|
if (this.query.status && this.query.status !== "all" /* Amity.FollowStatusTypeEnum.All */) {
|
|
12025
12033
|
followers = followers.filter(follower => follower.status === this.query.status);
|
|
12026
12034
|
}
|
|
12027
|
-
if (this.query.userIds) {
|
|
12028
|
-
const userIds = new Set(this.query.userIds);
|
|
12029
|
-
followers = followers.filter(follower => userIds.has(follower.from));
|
|
12030
|
-
}
|
|
12031
12035
|
followers = followers.filter(follower => {
|
|
12032
12036
|
var _a;
|
|
12033
12037
|
const fromUser = (_a = pullFromCache(['user', 'get', follower.from])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12034
12038
|
return (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) == null || (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) === false;
|
|
12035
12039
|
});
|
|
12040
|
+
// With a userIds filter, keep realtime follows with other users out of the list
|
|
12041
|
+
if (this.query.userIds) {
|
|
12042
|
+
const userIds = new Set(this.query.userIds);
|
|
12043
|
+
followers = followers.filter(follower => userIds.has(follower.from));
|
|
12044
|
+
}
|
|
12036
12045
|
return followers;
|
|
12037
12046
|
}
|
|
12038
12047
|
}
|
|
@@ -12052,8 +12061,8 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12052
12061
|
*
|
|
12053
12062
|
* Observe all mutations on a list of {@link Amity.FollowStatus} followers for a given userId
|
|
12054
12063
|
*
|
|
12055
|
-
* To check the relationship with specific users (e.g. the
|
|
12056
|
-
*
|
|
12064
|
+
* To check the relationship with specific users (e.g. the users on screen), pass the signed-in
|
|
12065
|
+
* user's `userId` and up to 100 `userIds`. The result only holds those users, in one page:
|
|
12057
12066
|
*
|
|
12058
12067
|
* ```js
|
|
12059
12068
|
* getFollowers({ userId: client.userId, userIds: ['a', 'b', 'c'] }, ({ data }) => {
|
|
@@ -12062,7 +12071,10 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12062
12071
|
* ```
|
|
12063
12072
|
*
|
|
12064
12073
|
* @param params.userId the user
|
|
12065
|
-
* @param params.
|
|
12074
|
+
* @param params.status filter by follow status, defaults to all
|
|
12075
|
+
* @param params.userIds only return the followers with these users (up to 100 ids, in one page).
|
|
12076
|
+
* A user missing from the result has no relationship. Only allowed when `userId` is the
|
|
12077
|
+
* signed-in user, otherwise the callback gets an {@link ASCInvalidParameterError}.
|
|
12066
12078
|
* @param callback the function to call when new data are available
|
|
12067
12079
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
12068
12080
|
*
|
|
@@ -12088,19 +12100,12 @@ const getFollowers = (params, callback, config) => {
|
|
|
12088
12100
|
|
|
12089
12101
|
class FollowingPaginationController extends PaginationController {
|
|
12090
12102
|
async getRequest(queryParams, token) {
|
|
12091
|
-
|
|
12092
|
-
const { userId, userIds } = queryParams, rest = __rest(queryParams, ["userId", "userIds"]);
|
|
12093
|
-
// An empty `userIds` filter matches nobody; omitting it on the request would
|
|
12094
|
-
// return the unfiltered list instead.
|
|
12095
|
-
if ((userIds === null || userIds === void 0 ? void 0 : userIds.length) === 0)
|
|
12096
|
-
return { follows: [], users: [], files: [], paging: {} };
|
|
12097
|
-
// With `userIds` the whole result fits in one page, so default the limit to it.
|
|
12098
|
-
const { limit = (_a = userIds === null || userIds === void 0 ? void 0 : userIds.length) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT } = rest, params = __rest(rest, ["limit"]);
|
|
12103
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId } = queryParams, params = __rest(queryParams, ["limit", "userId"]);
|
|
12099
12104
|
const options = token ? { token } : { limit };
|
|
12100
12105
|
const client = getActiveClient();
|
|
12101
12106
|
const path = client.userId === userId ? `/api/v4/me/following` : `/api/v4/users/${userId}/following`;
|
|
12102
12107
|
const { data: queryResponse } = await this.http.get(path, {
|
|
12103
|
-
params: Object.assign(Object.assign(
|
|
12108
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
12104
12109
|
});
|
|
12105
12110
|
return queryResponse;
|
|
12106
12111
|
}
|
|
@@ -12252,10 +12257,6 @@ class FollowingLiveCollectionController extends LiveCollectionController {
|
|
|
12252
12257
|
if (this.query.status && this.query.status !== "all" /* Amity.FollowStatusTypeEnum.All */) {
|
|
12253
12258
|
followings = followings.filter(following => following.status === this.query.status);
|
|
12254
12259
|
}
|
|
12255
|
-
if (this.query.userIds) {
|
|
12256
|
-
const userIds = new Set(this.query.userIds);
|
|
12257
|
-
followings = followings.filter(following => userIds.has(following.to));
|
|
12258
|
-
}
|
|
12259
12260
|
followings = followings.filter(following => {
|
|
12260
12261
|
var _a;
|
|
12261
12262
|
const toUser = (_a = pullFromCache(['user', 'get', following.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
@@ -12280,17 +12281,7 @@ class FollowingLiveCollectionController extends LiveCollectionController {
|
|
|
12280
12281
|
*
|
|
12281
12282
|
* Observe all mutations on a list of {@link Amity.FollowStatus} followings for a given userId
|
|
12282
12283
|
*
|
|
12283
|
-
*
|
|
12284
|
-
* pass `userIds` (max 100). The result then only contains those users, in a single page:
|
|
12285
|
-
*
|
|
12286
|
-
* ```js
|
|
12287
|
-
* getFollowings({ userId: client.userId, userIds: ['a', 'b', 'c'] }, ({ data }) => {
|
|
12288
|
-
* // users missing from `data` have no relationship
|
|
12289
|
-
* })
|
|
12290
|
-
* ```
|
|
12291
|
-
*
|
|
12292
|
-
* @param params.userId the user
|
|
12293
|
-
* @param params.userIds only return relationships with these users (max 100)
|
|
12284
|
+
* @param userId the user
|
|
12294
12285
|
* @param callback the function to call when new data are available
|
|
12295
12286
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
12296
12287
|
*
|
package/dist/index.esm.js
CHANGED
|
@@ -379,6 +379,8 @@ const API_ENDPOINTS = {
|
|
|
379
379
|
// The review-queue route defaults to 10, not the SDK-wide page size, and caps at 100
|
|
380
380
|
const COMMENT_REVIEW_QUEUE_DEFAULT_PAGINATION_SIZE = 10;
|
|
381
381
|
const COMMENT_REVIEW_QUEUE_MAX_PAGINATION_SIZE = 100;
|
|
382
|
+
// The me/followers and me/following `userIds` filter takes up to 100 ids, answered in one page
|
|
383
|
+
const FOLLOW_USER_IDS_PAGINATION_LIMIT = 100;
|
|
382
384
|
|
|
383
385
|
// cache constants
|
|
384
386
|
const CACHE_KEY_GET = 'get';
|
|
@@ -11736,19 +11738,25 @@ class PaginationController {
|
|
|
11736
11738
|
|
|
11737
11739
|
class FollowerPaginationController extends PaginationController {
|
|
11738
11740
|
async getRequest(queryParams, token) {
|
|
11739
|
-
|
|
11740
|
-
const { userId, userIds } = queryParams, rest = __rest(queryParams, ["userId", "userIds"]);
|
|
11741
|
-
// An empty `userIds` filter matches nobody; omitting it on the request would
|
|
11742
|
-
// return the unfiltered list instead.
|
|
11743
|
-
if ((userIds === null || userIds === void 0 ? void 0 : userIds.length) === 0)
|
|
11744
|
-
return { follows: [], users: [], files: [], paging: {} };
|
|
11745
|
-
// With `userIds` the whole result fits in one page, so default the limit to it.
|
|
11746
|
-
const { limit = (_a = userIds === null || userIds === void 0 ? void 0 : userIds.length) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT } = rest, params = __rest(rest, ["limit"]);
|
|
11747
|
-
const options = token ? { token } : { limit };
|
|
11741
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId, userIds } = queryParams, params = __rest(queryParams, ["limit", "userId", "userIds"]);
|
|
11748
11742
|
const client = getActiveClient();
|
|
11743
|
+
if (userIds) {
|
|
11744
|
+
// An empty filter matches nobody; sending no ids would return the whole list instead
|
|
11745
|
+
if (userIds.length === 0)
|
|
11746
|
+
return { follows: [], users: [], files: [], paging: {} };
|
|
11747
|
+
if (client.userId !== userId) {
|
|
11748
|
+
throw new ASCInvalidParameterError("userIds can only be used on the signed-in user's own followers list");
|
|
11749
|
+
}
|
|
11750
|
+
// core reads `limit` and `token` only as top-level params, never inside `options`
|
|
11751
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/me/followers`, {
|
|
11752
|
+
params: Object.assign(Object.assign(Object.assign(Object.assign({}, params), { userIds, limit: FOLLOW_USER_IDS_PAGINATION_LIMIT }), (token && { token })), { isDeleted: false }),
|
|
11753
|
+
});
|
|
11754
|
+
return queryResponse;
|
|
11755
|
+
}
|
|
11756
|
+
const options = token ? { token } : { limit };
|
|
11749
11757
|
const path = client.userId === userId ? `/api/v4/me/followers` : `/api/v4/users/${userId}/followers`;
|
|
11750
11758
|
const { data: queryResponse } = await this.http.get(path, {
|
|
11751
|
-
params: Object.assign(Object.assign(
|
|
11759
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
11752
11760
|
});
|
|
11753
11761
|
return queryResponse;
|
|
11754
11762
|
}
|
|
@@ -12024,15 +12032,16 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12024
12032
|
if (this.query.status && this.query.status !== "all" /* Amity.FollowStatusTypeEnum.All */) {
|
|
12025
12033
|
followers = followers.filter(follower => follower.status === this.query.status);
|
|
12026
12034
|
}
|
|
12027
|
-
if (this.query.userIds) {
|
|
12028
|
-
const userIds = new Set(this.query.userIds);
|
|
12029
|
-
followers = followers.filter(follower => userIds.has(follower.from));
|
|
12030
|
-
}
|
|
12031
12035
|
followers = followers.filter(follower => {
|
|
12032
12036
|
var _a;
|
|
12033
12037
|
const fromUser = (_a = pullFromCache(['user', 'get', follower.from])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12034
12038
|
return (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) == null || (fromUser === null || fromUser === void 0 ? void 0 : fromUser.isDeleted) === false;
|
|
12035
12039
|
});
|
|
12040
|
+
// With a userIds filter, keep realtime follows with other users out of the list
|
|
12041
|
+
if (this.query.userIds) {
|
|
12042
|
+
const userIds = new Set(this.query.userIds);
|
|
12043
|
+
followers = followers.filter(follower => userIds.has(follower.from));
|
|
12044
|
+
}
|
|
12036
12045
|
return followers;
|
|
12037
12046
|
}
|
|
12038
12047
|
}
|
|
@@ -12052,8 +12061,8 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12052
12061
|
*
|
|
12053
12062
|
* Observe all mutations on a list of {@link Amity.FollowStatus} followers for a given userId
|
|
12054
12063
|
*
|
|
12055
|
-
* To check the relationship with specific users (e.g. the
|
|
12056
|
-
*
|
|
12064
|
+
* To check the relationship with specific users (e.g. the users on screen), pass the signed-in
|
|
12065
|
+
* user's `userId` and up to 100 `userIds`. The result only holds those users, in one page:
|
|
12057
12066
|
*
|
|
12058
12067
|
* ```js
|
|
12059
12068
|
* getFollowers({ userId: client.userId, userIds: ['a', 'b', 'c'] }, ({ data }) => {
|
|
@@ -12062,7 +12071,10 @@ class FollowerLiveCollectionController extends LiveCollectionController {
|
|
|
12062
12071
|
* ```
|
|
12063
12072
|
*
|
|
12064
12073
|
* @param params.userId the user
|
|
12065
|
-
* @param params.
|
|
12074
|
+
* @param params.status filter by follow status, defaults to all
|
|
12075
|
+
* @param params.userIds only return the followers with these users (up to 100 ids, in one page).
|
|
12076
|
+
* A user missing from the result has no relationship. Only allowed when `userId` is the
|
|
12077
|
+
* signed-in user, otherwise the callback gets an {@link ASCInvalidParameterError}.
|
|
12066
12078
|
* @param callback the function to call when new data are available
|
|
12067
12079
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
12068
12080
|
*
|
|
@@ -12088,19 +12100,12 @@ const getFollowers = (params, callback, config) => {
|
|
|
12088
12100
|
|
|
12089
12101
|
class FollowingPaginationController extends PaginationController {
|
|
12090
12102
|
async getRequest(queryParams, token) {
|
|
12091
|
-
|
|
12092
|
-
const { userId, userIds } = queryParams, rest = __rest(queryParams, ["userId", "userIds"]);
|
|
12093
|
-
// An empty `userIds` filter matches nobody; omitting it on the request would
|
|
12094
|
-
// return the unfiltered list instead.
|
|
12095
|
-
if ((userIds === null || userIds === void 0 ? void 0 : userIds.length) === 0)
|
|
12096
|
-
return { follows: [], users: [], files: [], paging: {} };
|
|
12097
|
-
// With `userIds` the whole result fits in one page, so default the limit to it.
|
|
12098
|
-
const { limit = (_a = userIds === null || userIds === void 0 ? void 0 : userIds.length) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT } = rest, params = __rest(rest, ["limit"]);
|
|
12103
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, userId } = queryParams, params = __rest(queryParams, ["limit", "userId"]);
|
|
12099
12104
|
const options = token ? { token } : { limit };
|
|
12100
12105
|
const client = getActiveClient();
|
|
12101
12106
|
const path = client.userId === userId ? `/api/v4/me/following` : `/api/v4/users/${userId}/following`;
|
|
12102
12107
|
const { data: queryResponse } = await this.http.get(path, {
|
|
12103
|
-
params: Object.assign(Object.assign(
|
|
12108
|
+
params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
|
|
12104
12109
|
});
|
|
12105
12110
|
return queryResponse;
|
|
12106
12111
|
}
|
|
@@ -12252,10 +12257,6 @@ class FollowingLiveCollectionController extends LiveCollectionController {
|
|
|
12252
12257
|
if (this.query.status && this.query.status !== "all" /* Amity.FollowStatusTypeEnum.All */) {
|
|
12253
12258
|
followings = followings.filter(following => following.status === this.query.status);
|
|
12254
12259
|
}
|
|
12255
|
-
if (this.query.userIds) {
|
|
12256
|
-
const userIds = new Set(this.query.userIds);
|
|
12257
|
-
followings = followings.filter(following => userIds.has(following.to));
|
|
12258
|
-
}
|
|
12259
12260
|
followings = followings.filter(following => {
|
|
12260
12261
|
var _a;
|
|
12261
12262
|
const toUser = (_a = pullFromCache(['user', 'get', following.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
@@ -12280,17 +12281,7 @@ class FollowingLiveCollectionController extends LiveCollectionController {
|
|
|
12280
12281
|
*
|
|
12281
12282
|
* Observe all mutations on a list of {@link Amity.FollowStatus} followings for a given userId
|
|
12282
12283
|
*
|
|
12283
|
-
*
|
|
12284
|
-
* pass `userIds` (max 100). The result then only contains those users, in a single page:
|
|
12285
|
-
*
|
|
12286
|
-
* ```js
|
|
12287
|
-
* getFollowings({ userId: client.userId, userIds: ['a', 'b', 'c'] }, ({ data }) => {
|
|
12288
|
-
* // users missing from `data` have no relationship
|
|
12289
|
-
* })
|
|
12290
|
-
* ```
|
|
12291
|
-
*
|
|
12292
|
-
* @param params.userId the user
|
|
12293
|
-
* @param params.userIds only return relationships with these users (max 100)
|
|
12284
|
+
* @param userId the user
|
|
12294
12285
|
* @param callback the function to call when new data are available
|
|
12295
12286
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
12296
12287
|
*
|