@amityco/ts-sdk-react-native 7.33.2-9759e33.0 → 7.34.1-3a2d265.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/core/payload.d.ts +4 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +5 -0
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +14 -0
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/follow.d.ts +7 -0
- package/dist/@types/domains/follow.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +15 -3
- package/dist/@types/domains/notification.d.ts.map +1 -1
- package/dist/client/api/getFeedSettings.d.ts +3 -1
- package/dist/client/api/getFeedSettings.d.ts.map +1 -1
- package/dist/client/api/setupLoginSubscriptions.d.ts.map +1 -1
- package/dist/feedRepository/index.d.ts +1 -1
- package/dist/feedRepository/index.d.ts.map +1 -1
- package/dist/feedRepository/observers/getFollowingFeed/LiveCollectionController.d.ts +13 -0
- package/dist/feedRepository/observers/getFollowingFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getFollowingFeed/PaginationController.d.ts +10 -0
- package/dist/feedRepository/observers/getFollowingFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getFollowingFeed/QueryStreamController.d.ts +22 -0
- package/dist/feedRepository/observers/getFollowingFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getFollowingFeed.d.ts +35 -0
- package/dist/feedRepository/observers/getFollowingFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/index.d.ts +1 -0
- package/dist/feedRepository/observers/index.d.ts.map +1 -1
- package/dist/feedRepository/observers/tests/integration/getFollowingFeed.integration.test.d.ts +2 -0
- package/dist/feedRepository/observers/tests/integration/getFollowingFeed.integration.test.d.ts.map +1 -0
- package/dist/feedRepository/observers/tests/unit/FollowingFeedQueryStreamController.test.d.ts +2 -0
- package/dist/feedRepository/observers/tests/unit/FollowingFeedQueryStreamController.test.d.ts.map +1 -0
- package/dist/index.cjs.js +698 -262
- package/dist/index.esm.js +629 -193
- package/dist/index.umd.js +1 -1
- package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/follow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/getAllFollowings.d.ts +34 -0
- package/dist/userRepository/relationship/follow/api/getAllFollowings.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/api/index.d.ts +1 -0
- package/dist/userRepository/relationship/follow/api/index.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/tests/getAllFollowings.test.d.ts +2 -0
- package/dist/userRepository/relationship/follow/api/tests/getAllFollowings.test.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/api/tests/integration/getAllFollowings.integration.test.d.ts +2 -0
- package/dist/userRepository/relationship/follow/api/tests/integration/getAllFollowings.integration.test.d.ts.map +1 -0
- package/dist/userRepository/relationship/follow/api/unfollow.d.ts.map +1 -1
- package/dist/userRepository/services/FollowingSyncEngine/followRealtimeOnLoginHandler.d.ts +19 -0
- package/dist/userRepository/services/FollowingSyncEngine/followRealtimeOnLoginHandler.d.ts.map +1 -0
- package/dist/userRepository/services/FollowingSyncEngine/followingSyncEngine.d.ts +61 -0
- package/dist/userRepository/services/FollowingSyncEngine/followingSyncEngine.d.ts.map +1 -0
- package/dist/userRepository/services/FollowingSyncEngine/followingSyncEngineOnLoginHandler.d.ts +3 -0
- package/dist/userRepository/services/FollowingSyncEngine/followingSyncEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -283,6 +283,14 @@ exports.FeedSortByEnum = void 0;
|
|
|
283
283
|
FeedSortByEnum["LastUpdated"] = "lastUpdated";
|
|
284
284
|
FeedSortByEnum["FirstUpdated"] = "firstUpdated";
|
|
285
285
|
})(exports.FeedSortByEnum || (exports.FeedSortByEnum = {}));
|
|
286
|
+
/** Sort order of the following feed (`GET /api/v1/me/following-feeds`). */
|
|
287
|
+
exports.FollowingFeedSortByEnum = void 0;
|
|
288
|
+
(function (FollowingFeedSortByEnum) {
|
|
289
|
+
/** Server-ranked. The backend default when `sortBy` is not sent. */
|
|
290
|
+
FollowingFeedSortByEnum["CustomRanking"] = "customRanking";
|
|
291
|
+
/** Newest first. */
|
|
292
|
+
FollowingFeedSortByEnum["LastCreated"] = "lastCreated";
|
|
293
|
+
})(exports.FollowingFeedSortByEnum || (exports.FollowingFeedSortByEnum = {}));
|
|
286
294
|
exports.FeedSourceEnum = void 0;
|
|
287
295
|
(function (FeedSourceEnum) {
|
|
288
296
|
FeedSourceEnum["Community"] = "community";
|
|
@@ -385,8 +393,8 @@ exports.AmityLiveViewerCountMode = void 0;
|
|
|
385
393
|
|
|
386
394
|
function getVersion() {
|
|
387
395
|
try {
|
|
388
|
-
// the string ''v7.
|
|
389
|
-
return 'v7.
|
|
396
|
+
// the string ''v7.34.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
397
|
+
return 'v7.34.0-cjs';
|
|
390
398
|
}
|
|
391
399
|
catch (error) {
|
|
392
400
|
return '__dev__';
|
|
@@ -411,6 +419,7 @@ const YEAR = 365 * DAY;
|
|
|
411
419
|
const ACCESS_TOKEN_WATCHER_INTERVAL = 10 * MINUTE;
|
|
412
420
|
const API_ENDPOINTS = {
|
|
413
421
|
forYouFeed: '/api/v1/feeds/for-you',
|
|
422
|
+
followingFeed: '/api/v1/me/following-feeds',
|
|
414
423
|
commentReviewQueue: (communityId) => `/api/v3/communities/${encodeURIComponent(communityId)}/comments/review-queue`,
|
|
415
424
|
};
|
|
416
425
|
// The review-queue route defaults to 10, not the SDK-wide page size, and caps at 100
|
|
@@ -2004,13 +2013,13 @@ class SessionWatcher {
|
|
|
2004
2013
|
this._listener.clear();
|
|
2005
2014
|
}
|
|
2006
2015
|
}
|
|
2007
|
-
let instance$
|
|
2016
|
+
let instance$c;
|
|
2008
2017
|
var SessionWatcher$1 = {
|
|
2009
2018
|
getInstance: () => {
|
|
2010
|
-
if (!instance$
|
|
2011
|
-
instance$
|
|
2019
|
+
if (!instance$c) {
|
|
2020
|
+
instance$c = new SessionWatcher();
|
|
2012
2021
|
}
|
|
2013
|
-
return instance$
|
|
2022
|
+
return instance$c;
|
|
2014
2023
|
},
|
|
2015
2024
|
};
|
|
2016
2025
|
|
|
@@ -2677,13 +2686,13 @@ class NetworkActivitiesWatcher {
|
|
|
2677
2686
|
this._listener.clear();
|
|
2678
2687
|
}
|
|
2679
2688
|
}
|
|
2680
|
-
let instance$
|
|
2689
|
+
let instance$b;
|
|
2681
2690
|
var NetworkActivitiesWatcher$1 = {
|
|
2682
2691
|
getInstance: () => {
|
|
2683
|
-
if (!instance$
|
|
2684
|
-
instance$
|
|
2692
|
+
if (!instance$b) {
|
|
2693
|
+
instance$b = new NetworkActivitiesWatcher();
|
|
2685
2694
|
}
|
|
2686
|
-
return instance$
|
|
2695
|
+
return instance$b;
|
|
2687
2696
|
},
|
|
2688
2697
|
};
|
|
2689
2698
|
|
|
@@ -2944,11 +2953,11 @@ class AutoSubscriptionManager {
|
|
|
2944
2953
|
this.seed();
|
|
2945
2954
|
}
|
|
2946
2955
|
}
|
|
2947
|
-
let instance$
|
|
2956
|
+
let instance$a = null;
|
|
2948
2957
|
const getAutoSubscriptionManager = () => {
|
|
2949
|
-
if (!instance$
|
|
2950
|
-
instance$
|
|
2951
|
-
return instance$
|
|
2958
|
+
if (!instance$a)
|
|
2959
|
+
instance$a = new AutoSubscriptionManager();
|
|
2960
|
+
return instance$a;
|
|
2952
2961
|
};
|
|
2953
2962
|
/** Resets the registry to its default baseline when the session ends. */
|
|
2954
2963
|
const resetAutoSubscriptionsOnLogout = () => onSessionStateChange(state => {
|
|
@@ -6315,9 +6324,11 @@ const validateTexts = async (texts) => {
|
|
|
6315
6324
|
* import { getFeedSettings } from '@amityco/ts-sdk-react-native'
|
|
6316
6325
|
* const feedSettings = await getFeedSettings()
|
|
6317
6326
|
* const postFeedSetting = feedSettings.post
|
|
6327
|
+
* const isAutoPlayEnabled = postFeedSetting?.find(({ contentType }) => contentType === 'video')?.autoPlay
|
|
6318
6328
|
* ```
|
|
6319
6329
|
*
|
|
6320
|
-
* Fetches a {@link Amity.FeedSettings} object
|
|
6330
|
+
* Fetches a {@link Amity.FeedSettings} object. Video content settings always
|
|
6331
|
+
* carry `autoPlay`, which is `false` when the server omits it.
|
|
6321
6332
|
*
|
|
6322
6333
|
* @returns A Promise of {@link Amity.FeedSettings} object
|
|
6323
6334
|
*
|
|
@@ -6328,7 +6339,14 @@ const getFeedSettings = async () => {
|
|
|
6328
6339
|
const client = getActiveClient();
|
|
6329
6340
|
const { data } = await client.http.get(`/api/v3/network-settings/feed-setting`);
|
|
6330
6341
|
return Object.fromEntries(data.feedSettings.map(({ feedType, contentSettings }) => {
|
|
6331
|
-
return [
|
|
6342
|
+
return [
|
|
6343
|
+
feedType,
|
|
6344
|
+
contentSettings === null || contentSettings === void 0 ? void 0 : contentSettings.map(setting => {
|
|
6345
|
+
var _a;
|
|
6346
|
+
return setting.contentType === 'video'
|
|
6347
|
+
? Object.assign(Object.assign({}, setting), { autoPlay: (_a = setting.autoPlay) !== null && _a !== void 0 ? _a : false }) : setting;
|
|
6348
|
+
}),
|
|
6349
|
+
];
|
|
6332
6350
|
}));
|
|
6333
6351
|
};
|
|
6334
6352
|
|
|
@@ -7059,13 +7077,13 @@ class AnalyticsEngine {
|
|
|
7059
7077
|
this._eventCapturer.resetAllBuckets();
|
|
7060
7078
|
}
|
|
7061
7079
|
}
|
|
7062
|
-
let instance$
|
|
7080
|
+
let instance$9;
|
|
7063
7081
|
var AnalyticsEngine$1 = {
|
|
7064
7082
|
getInstance: () => {
|
|
7065
|
-
if (!instance$
|
|
7066
|
-
instance$
|
|
7083
|
+
if (!instance$9) {
|
|
7084
|
+
instance$9 = new AnalyticsEngine();
|
|
7067
7085
|
}
|
|
7068
|
-
return instance$
|
|
7086
|
+
return instance$9;
|
|
7069
7087
|
},
|
|
7070
7088
|
};
|
|
7071
7089
|
|
|
@@ -7292,12 +7310,12 @@ class MessageReadReceiptSyncEngine {
|
|
|
7292
7310
|
}
|
|
7293
7311
|
}
|
|
7294
7312
|
}
|
|
7295
|
-
let instance$
|
|
7313
|
+
let instance$8 = null;
|
|
7296
7314
|
var ReadReceiptSyncEngine = {
|
|
7297
7315
|
getInstance: () => {
|
|
7298
|
-
if (!instance$
|
|
7299
|
-
instance$
|
|
7300
|
-
return instance$
|
|
7316
|
+
if (!instance$8)
|
|
7317
|
+
instance$8 = new MessageReadReceiptSyncEngine();
|
|
7318
|
+
return instance$8;
|
|
7301
7319
|
},
|
|
7302
7320
|
};
|
|
7303
7321
|
|
|
@@ -7551,12 +7569,12 @@ class LegacyMessageReadReceiptSyncEngine {
|
|
|
7551
7569
|
}
|
|
7552
7570
|
}
|
|
7553
7571
|
}
|
|
7554
|
-
let instance$
|
|
7572
|
+
let instance$7 = null;
|
|
7555
7573
|
var LegacyReadReceiptSyncEngine = {
|
|
7556
7574
|
getInstance: () => {
|
|
7557
|
-
if (!instance$
|
|
7558
|
-
instance$
|
|
7559
|
-
return instance$
|
|
7575
|
+
if (!instance$7)
|
|
7576
|
+
instance$7 = new LegacyMessageReadReceiptSyncEngine();
|
|
7577
|
+
return instance$7;
|
|
7560
7578
|
},
|
|
7561
7579
|
};
|
|
7562
7580
|
|
|
@@ -7832,12 +7850,12 @@ class ObjectResolverEngine {
|
|
|
7832
7850
|
this.stopResolver();
|
|
7833
7851
|
}
|
|
7834
7852
|
}
|
|
7835
|
-
let instance$
|
|
7853
|
+
let instance$6 = null;
|
|
7836
7854
|
var ObjectResolverEngine$1 = {
|
|
7837
7855
|
getInstance: () => {
|
|
7838
|
-
if (!instance$
|
|
7839
|
-
instance$
|
|
7840
|
-
return instance$
|
|
7856
|
+
if (!instance$6)
|
|
7857
|
+
instance$6 = new ObjectResolverEngine();
|
|
7858
|
+
return instance$6;
|
|
7841
7859
|
},
|
|
7842
7860
|
};
|
|
7843
7861
|
|
|
@@ -7987,13 +8005,13 @@ class LiveReactionSyncEngine {
|
|
|
7987
8005
|
this.stopReactionsSync();
|
|
7988
8006
|
}
|
|
7989
8007
|
}
|
|
7990
|
-
let instance$
|
|
8008
|
+
let instance$5;
|
|
7991
8009
|
var ReactionSyncEngine = {
|
|
7992
8010
|
getInstance: () => {
|
|
7993
|
-
if (!instance$
|
|
7994
|
-
instance$
|
|
8011
|
+
if (!instance$5) {
|
|
8012
|
+
instance$5 = new LiveReactionSyncEngine();
|
|
7995
8013
|
}
|
|
7996
|
-
return instance$
|
|
8014
|
+
return instance$5;
|
|
7997
8015
|
},
|
|
7998
8016
|
};
|
|
7999
8017
|
|
|
@@ -8024,7 +8042,7 @@ function prepareBlockedUserPayload(response) {
|
|
|
8024
8042
|
}
|
|
8025
8043
|
|
|
8026
8044
|
const BLOCK_LIST_LIMIT$1 = 100;
|
|
8027
|
-
const TTL_MS$
|
|
8045
|
+
const TTL_MS$2 = 5 * 60 * 1000; // 5 minutes
|
|
8028
8046
|
/**
|
|
8029
8047
|
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
8030
8048
|
* of blocked users. Provides a lazy `ensureFetched()` gate for the
|
|
@@ -8062,7 +8080,7 @@ class BlockedUserSyncEngine {
|
|
|
8062
8080
|
isCacheExpired() {
|
|
8063
8081
|
if (this.lastFetchedAt === null)
|
|
8064
8082
|
return true;
|
|
8065
|
-
return Date.now() - this.lastFetchedAt > TTL_MS$
|
|
8083
|
+
return Date.now() - this.lastFetchedAt > TTL_MS$2;
|
|
8066
8084
|
}
|
|
8067
8085
|
/**
|
|
8068
8086
|
* Ensures the local store is populated with fresh blocked-user data.
|
|
@@ -8117,12 +8135,12 @@ class BlockedUserSyncEngine {
|
|
|
8117
8135
|
.map(userLinkedObject);
|
|
8118
8136
|
}
|
|
8119
8137
|
}
|
|
8120
|
-
let instance$
|
|
8138
|
+
let instance$4 = null;
|
|
8121
8139
|
var BlockedUserSyncEngine$1 = {
|
|
8122
8140
|
getInstance: () => {
|
|
8123
|
-
if (!instance$
|
|
8124
|
-
instance$
|
|
8125
|
-
return instance$
|
|
8141
|
+
if (!instance$4)
|
|
8142
|
+
instance$4 = new BlockedUserSyncEngine();
|
|
8143
|
+
return instance$4;
|
|
8126
8144
|
},
|
|
8127
8145
|
};
|
|
8128
8146
|
|
|
@@ -8153,7 +8171,7 @@ function prepareBlockingUserPayload(response) {
|
|
|
8153
8171
|
}
|
|
8154
8172
|
|
|
8155
8173
|
const BLOCK_LIST_LIMIT = 100;
|
|
8156
|
-
const TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
8174
|
+
const TTL_MS$1 = 5 * 60 * 1000; // 5 minutes
|
|
8157
8175
|
/**
|
|
8158
8176
|
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
8159
8177
|
* of blocking users (the "blocked-by" list — users who blocked the current
|
|
@@ -8192,7 +8210,7 @@ class BlockingUserSyncEngine {
|
|
|
8192
8210
|
isCacheExpired() {
|
|
8193
8211
|
if (this.lastFetchedAt === null)
|
|
8194
8212
|
return true;
|
|
8195
|
-
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
8213
|
+
return Date.now() - this.lastFetchedAt > TTL_MS$1;
|
|
8196
8214
|
}
|
|
8197
8215
|
/**
|
|
8198
8216
|
* Ensures the local store is populated with fresh blocking-user data.
|
|
@@ -8247,12 +8265,12 @@ class BlockingUserSyncEngine {
|
|
|
8247
8265
|
.map(userLinkedObject);
|
|
8248
8266
|
}
|
|
8249
8267
|
}
|
|
8250
|
-
let instance$
|
|
8268
|
+
let instance$3 = null;
|
|
8251
8269
|
var BlockingUserSyncEngine$1 = {
|
|
8252
8270
|
getInstance: () => {
|
|
8253
|
-
if (!instance$
|
|
8254
|
-
instance$
|
|
8255
|
-
return instance$
|
|
8271
|
+
if (!instance$3)
|
|
8272
|
+
instance$3 = new BlockingUserSyncEngine();
|
|
8273
|
+
return instance$3;
|
|
8256
8274
|
},
|
|
8257
8275
|
};
|
|
8258
8276
|
|
|
@@ -8362,6 +8380,336 @@ var blockRealtimeOnLoginHandler = () => {
|
|
|
8362
8380
|
return () => disposers.forEach(dispose => dispose());
|
|
8363
8381
|
};
|
|
8364
8382
|
|
|
8383
|
+
const TTL_MS = 5 * 60 * 1000; // 5 minutes, as BlockedUserSyncEngine
|
|
8384
|
+
const isKept = (status) => status === 'accepted' || status === 'pending';
|
|
8385
|
+
/**
|
|
8386
|
+
* Session-scoped singleton engine behind `getAllFollowings()`: a 5-minute fetch gate
|
|
8387
|
+
* on `GET /api/v4/me/following-ids`, copied from BlockedUserSyncEngine.
|
|
8388
|
+
*
|
|
8389
|
+
* - `onSessionEstablished()` is a no-op — the fetch is lazy, on the first call
|
|
8390
|
+
* - `onSessionDestroyed()` resets `lastFetchedAt` and empties the list, so the next
|
|
8391
|
+
* session fetches again
|
|
8392
|
+
* - `ensureFetched()` fetches only when the window expired or nothing was fetched yet;
|
|
8393
|
+
* `lastFetchedAt` moves only on success
|
|
8394
|
+
* - the answer holds ids and statuses only, so the engine keeps it in memory — user id →
|
|
8395
|
+
* status — replaced on each fetch, never merged: a follow removed on another device
|
|
8396
|
+
* drops out at the next fetch. Nothing is written to the follow or user cache.
|
|
8397
|
+
* - `onFollowChanged()` applies every follow change of the session by its status; a change
|
|
8398
|
+
* that arrives while a fetch is in flight is replayed on top of the answer, so the older
|
|
8399
|
+
* answer does not drop it. Concurrent calls share one in-flight fetch.
|
|
8400
|
+
*
|
|
8401
|
+
* @internal
|
|
8402
|
+
*/
|
|
8403
|
+
class FollowingSyncEngine {
|
|
8404
|
+
constructor() {
|
|
8405
|
+
/** Epoch ms of the last successful fetch. null = never fetched in this session. */
|
|
8406
|
+
this.lastFetchedAt = null;
|
|
8407
|
+
/** user id → status, in order: the session's changes first, then the answer's order. */
|
|
8408
|
+
this.followings = new Map();
|
|
8409
|
+
/** Bumped on sign-out, so a fetch from the old session cannot fill the new one. */
|
|
8410
|
+
this.session = 0;
|
|
8411
|
+
/** The in-flight fetch, shared by concurrent calls. */
|
|
8412
|
+
this.fetching = null;
|
|
8413
|
+
/** Changes applied while `fetching` is in flight, replayed on top of its answer. */
|
|
8414
|
+
this.changesDuringFetch = [];
|
|
8415
|
+
}
|
|
8416
|
+
/** No-op — the fetch is lazy, triggered by getAllFollowings(). */
|
|
8417
|
+
// eslint-disable-next-line class-methods-use-this
|
|
8418
|
+
onSessionEstablished() {
|
|
8419
|
+
// intentionally empty
|
|
8420
|
+
}
|
|
8421
|
+
/** Resets the window so the next session starts with a fresh fetch. */
|
|
8422
|
+
onSessionDestroyed() {
|
|
8423
|
+
this.lastFetchedAt = null;
|
|
8424
|
+
this.followings = new Map();
|
|
8425
|
+
this.fetching = null;
|
|
8426
|
+
this.changesDuringFetch = [];
|
|
8427
|
+
this.session += 1;
|
|
8428
|
+
}
|
|
8429
|
+
/** No-op — the window does not depend on the token. */
|
|
8430
|
+
// eslint-disable-next-line class-methods-use-this
|
|
8431
|
+
onTokenExpired() {
|
|
8432
|
+
// intentionally empty
|
|
8433
|
+
}
|
|
8434
|
+
/**
|
|
8435
|
+
* Called for every follow change the SDK sees during the session. A follow whose
|
|
8436
|
+
* `from` is another user is ignored. Status `accepted` or `pending` sets the user with
|
|
8437
|
+
* that status and moves them to the front; any other status (`none` after an unfollow,
|
|
8438
|
+
* a cancel, a decline or a removed follower; `blocked`) removes them.
|
|
8439
|
+
*/
|
|
8440
|
+
onFollowChanged(follow) {
|
|
8441
|
+
if (!follow || follow.from !== getActiveClient().userId)
|
|
8442
|
+
return;
|
|
8443
|
+
if (this.fetching)
|
|
8444
|
+
this.changesDuringFetch.push(follow);
|
|
8445
|
+
this.apply(follow);
|
|
8446
|
+
}
|
|
8447
|
+
apply(follow) {
|
|
8448
|
+
const rest = [...this.followings].filter(([userId]) => userId !== follow.to);
|
|
8449
|
+
this.followings = new Map(isKept(follow.status) ? [[follow.to, follow.status], ...rest] : rest);
|
|
8450
|
+
}
|
|
8451
|
+
isCacheExpired() {
|
|
8452
|
+
if (this.lastFetchedAt === null)
|
|
8453
|
+
return true;
|
|
8454
|
+
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
8455
|
+
}
|
|
8456
|
+
/**
|
|
8457
|
+
* Fetches whom the user follows (up to 5,000 ids and statuses, one response, no
|
|
8458
|
+
* `status` so both accepted and pending come back) when the window has expired. A
|
|
8459
|
+
* failure propagates and leaves the window and the list unchanged, so the next call
|
|
8460
|
+
* retries.
|
|
8461
|
+
*/
|
|
8462
|
+
async ensureFetched() {
|
|
8463
|
+
if (!this.isCacheExpired())
|
|
8464
|
+
return;
|
|
8465
|
+
if (!this.fetching) {
|
|
8466
|
+
const { session } = this;
|
|
8467
|
+
this.changesDuringFetch = [];
|
|
8468
|
+
this.fetching = this.fetch(session).finally(() => {
|
|
8469
|
+
if (session !== this.session)
|
|
8470
|
+
return;
|
|
8471
|
+
this.fetching = null;
|
|
8472
|
+
this.changesDuringFetch = [];
|
|
8473
|
+
});
|
|
8474
|
+
}
|
|
8475
|
+
await this.fetching;
|
|
8476
|
+
}
|
|
8477
|
+
async fetch(session) {
|
|
8478
|
+
var _a;
|
|
8479
|
+
const client = getActiveClient();
|
|
8480
|
+
const { data } = await client.http.get('/api/v4/me/following-ids');
|
|
8481
|
+
if (session !== this.session)
|
|
8482
|
+
return; // signed out while in flight
|
|
8483
|
+
// replaced, never merged
|
|
8484
|
+
this.followings = new Map(((_a = data === null || data === void 0 ? void 0 : data.follows) !== null && _a !== void 0 ? _a : [])
|
|
8485
|
+
.filter(follow => isKept(follow.status))
|
|
8486
|
+
.map(follow => [follow.userId, follow.status]));
|
|
8487
|
+
// a change made while the request was in flight is newer than the answer
|
|
8488
|
+
this.changesDuringFetch.forEach(change => this.apply(change));
|
|
8489
|
+
this.lastFetchedAt = Date.now();
|
|
8490
|
+
}
|
|
8491
|
+
/** The kept entries, in order. */
|
|
8492
|
+
getFollowings() {
|
|
8493
|
+
return [...this.followings].map(([userId, status]) => ({ userId, status }));
|
|
8494
|
+
}
|
|
8495
|
+
}
|
|
8496
|
+
let instance$2 = null;
|
|
8497
|
+
var FollowingSyncEngine$1 = {
|
|
8498
|
+
getInstance: () => {
|
|
8499
|
+
if (!instance$2)
|
|
8500
|
+
instance$2 = new FollowingSyncEngine();
|
|
8501
|
+
return instance$2;
|
|
8502
|
+
},
|
|
8503
|
+
};
|
|
8504
|
+
|
|
8505
|
+
var followingSyncEngineOnLoginHandler = () => {
|
|
8506
|
+
const followingSyncEngine = FollowingSyncEngine$1.getInstance();
|
|
8507
|
+
onSessionStateChange(state => {
|
|
8508
|
+
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
8509
|
+
followingSyncEngine.onSessionEstablished();
|
|
8510
|
+
}
|
|
8511
|
+
else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
8512
|
+
followingSyncEngine.onTokenExpired();
|
|
8513
|
+
}
|
|
8514
|
+
else {
|
|
8515
|
+
followingSyncEngine.onSessionDestroyed();
|
|
8516
|
+
}
|
|
8517
|
+
});
|
|
8518
|
+
return () => {
|
|
8519
|
+
followingSyncEngine.onSessionDestroyed();
|
|
8520
|
+
};
|
|
8521
|
+
};
|
|
8522
|
+
|
|
8523
|
+
const createFollowEventSubscriber = (event, callback) => {
|
|
8524
|
+
const client = getActiveClient();
|
|
8525
|
+
const filter = (data) => {
|
|
8526
|
+
const payload = prepareFollowersPayload(data);
|
|
8527
|
+
if (!client.cache) {
|
|
8528
|
+
callback(payload.follows[0]);
|
|
8529
|
+
}
|
|
8530
|
+
else {
|
|
8531
|
+
ingestInCache(payload);
|
|
8532
|
+
callback(payload.follows[0]);
|
|
8533
|
+
}
|
|
8534
|
+
};
|
|
8535
|
+
return createEventSubscriber(client, event, event, filter);
|
|
8536
|
+
};
|
|
8537
|
+
const createLocalFollowEventSubscriber = (event, callback) => {
|
|
8538
|
+
const client = getActiveClient();
|
|
8539
|
+
const filter = (data) => {
|
|
8540
|
+
const payload = prepareFollowStatusPayload(data);
|
|
8541
|
+
if (!client.cache) {
|
|
8542
|
+
callback(payload.follows[0]);
|
|
8543
|
+
}
|
|
8544
|
+
else {
|
|
8545
|
+
ingestInCache(payload);
|
|
8546
|
+
callback(payload.follows[0]);
|
|
8547
|
+
}
|
|
8548
|
+
};
|
|
8549
|
+
return createEventSubscriber(client, event, event, filter);
|
|
8550
|
+
};
|
|
8551
|
+
|
|
8552
|
+
/**
|
|
8553
|
+
* ```js
|
|
8554
|
+
* import { onUserFollowed } from '@amityco/ts-sdk-react-native'
|
|
8555
|
+
* const dispose = onUserFollowed(status => {
|
|
8556
|
+
* // ...
|
|
8557
|
+
* })
|
|
8558
|
+
* ```
|
|
8559
|
+
*
|
|
8560
|
+
* Fired when a user follows another users and confirmation is not required
|
|
8561
|
+
*
|
|
8562
|
+
* @param callback The function to call when the event was fired
|
|
8563
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
8564
|
+
*
|
|
8565
|
+
* @category Follow Events
|
|
8566
|
+
*/
|
|
8567
|
+
const onUserFollowed = (callback) => createFollowEventSubscriber('follow.created', callback);
|
|
8568
|
+
|
|
8569
|
+
/**
|
|
8570
|
+
* ```js
|
|
8571
|
+
* import { onFollowerRequested } from '@amityco/ts-sdk-react-native'
|
|
8572
|
+
* const dispose = onFollowerRequested(status => {
|
|
8573
|
+
* // ...
|
|
8574
|
+
* })
|
|
8575
|
+
* ```
|
|
8576
|
+
*
|
|
8577
|
+
* Fired when a user follows another users and confirmation is required
|
|
8578
|
+
*
|
|
8579
|
+
* @param callback The function to call when the event was fired
|
|
8580
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
8581
|
+
*
|
|
8582
|
+
* @category Follow Events
|
|
8583
|
+
*/
|
|
8584
|
+
const onFollowerRequested = (callback) => createFollowEventSubscriber('follow.requested', callback);
|
|
8585
|
+
|
|
8586
|
+
/**
|
|
8587
|
+
* ```js
|
|
8588
|
+
* import { onFollowRequestAccepted } from '@amityco/ts-sdk-react-native'
|
|
8589
|
+
* const dispose = onFollowRequestAccepted(status => {
|
|
8590
|
+
* // ...
|
|
8591
|
+
* })
|
|
8592
|
+
* ```
|
|
8593
|
+
*
|
|
8594
|
+
* Fired when a follow request has been accepted
|
|
8595
|
+
*
|
|
8596
|
+
* @param callback The function to call when the event was fired
|
|
8597
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
8598
|
+
*
|
|
8599
|
+
* @category Follow Events
|
|
8600
|
+
*/
|
|
8601
|
+
const onFollowRequestAccepted = (callback) => createFollowEventSubscriber('follow.accepted', callback);
|
|
8602
|
+
|
|
8603
|
+
/**
|
|
8604
|
+
* ```js
|
|
8605
|
+
* import { onUserUnfollowed } from '@amityco/ts-sdk-react-native'
|
|
8606
|
+
* const dispose = onUserFollowed(status => {
|
|
8607
|
+
* // ...
|
|
8608
|
+
* })
|
|
8609
|
+
* ```
|
|
8610
|
+
*
|
|
8611
|
+
* Fired when a user unfollows
|
|
8612
|
+
*
|
|
8613
|
+
* @param callback The function to call when the event was fired
|
|
8614
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
8615
|
+
*
|
|
8616
|
+
* @category Follow Events
|
|
8617
|
+
*/
|
|
8618
|
+
const onUserUnfollowed = (callback) => createFollowEventSubscriber('follow.unfollowed', callback);
|
|
8619
|
+
|
|
8620
|
+
/**
|
|
8621
|
+
* ```js
|
|
8622
|
+
* import { onFollowRequestCanceled } from '@amityco/ts-sdk-react-native'
|
|
8623
|
+
* const dispose = onFollowRequestCanceled(status => {
|
|
8624
|
+
* // ...
|
|
8625
|
+
* })
|
|
8626
|
+
* ```
|
|
8627
|
+
*
|
|
8628
|
+
* Fired when a follow request has been canceled
|
|
8629
|
+
*
|
|
8630
|
+
* @param callback The function to call when the event was fired
|
|
8631
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
8632
|
+
*
|
|
8633
|
+
* @category Follow Events
|
|
8634
|
+
*/
|
|
8635
|
+
const onFollowRequestCanceled = (callback) => createFollowEventSubscriber('follow.requestCanceled', callback);
|
|
8636
|
+
|
|
8637
|
+
/**
|
|
8638
|
+
* ```js
|
|
8639
|
+
* import { onFollowRequestDeclined } from '@amityco/ts-sdk-react-native'
|
|
8640
|
+
* const dispose = onFollowRequestDeclined(status => {
|
|
8641
|
+
* // ...
|
|
8642
|
+
* })
|
|
8643
|
+
* ```
|
|
8644
|
+
*
|
|
8645
|
+
* Fired when a follow request has been declined
|
|
8646
|
+
*
|
|
8647
|
+
* @param callback The function to call when the event was fired
|
|
8648
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
8649
|
+
*
|
|
8650
|
+
* @category Follow Events
|
|
8651
|
+
*/
|
|
8652
|
+
const onFollowRequestDeclined = (callback) => createFollowEventSubscriber('follow.requestDeclined', callback);
|
|
8653
|
+
|
|
8654
|
+
/**
|
|
8655
|
+
* ```js
|
|
8656
|
+
* import { onFollowerDeleted } from '@amityco/ts-sdk-react-native'
|
|
8657
|
+
* const dispose = onFollowerDeleted(status => {
|
|
8658
|
+
* // ...
|
|
8659
|
+
* })
|
|
8660
|
+
* ```
|
|
8661
|
+
*
|
|
8662
|
+
* Fired when a follower has been deleted
|
|
8663
|
+
*
|
|
8664
|
+
* @param callback The function to call when the event was fired
|
|
8665
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
8666
|
+
*
|
|
8667
|
+
* @category Follow Events
|
|
8668
|
+
*/
|
|
8669
|
+
const onFollowerDeleted = (callback) => createFollowEventSubscriber('follow.followerDeleted', callback);
|
|
8670
|
+
|
|
8671
|
+
const onLocalUserFollowed = (callback) => createLocalFollowEventSubscriber('local.follow.created', callback);
|
|
8672
|
+
|
|
8673
|
+
const onLocalFollowerRequested = (callback) => createLocalFollowEventSubscriber('local.follow.requested', callback);
|
|
8674
|
+
|
|
8675
|
+
const onLocalUserUnfollowed = (callback) => createLocalFollowEventSubscriber('local.follow.unfollowed', callback);
|
|
8676
|
+
|
|
8677
|
+
// Each event file directly, not the events barrel: the barrel's onFollowInfoUpdated imports
|
|
8678
|
+
/**
|
|
8679
|
+
* Keeps `getAllFollowings()` current for the whole session: every follow change — from
|
|
8680
|
+
* this device (local echo) or another (MQTT) — goes to `FollowingSyncEngine.onFollowChanged`,
|
|
8681
|
+
* which ignores follows of other users and applies the rest by status: a follow adds the
|
|
8682
|
+
* user as accepted, a request as pending, an accepted request turns accepted, and an
|
|
8683
|
+
* unfollow, a canceled or declined request, a removed follower or a block takes the user out.
|
|
8684
|
+
* `blockUser` also calls the engine itself: its local event swaps `from` and `to`.
|
|
8685
|
+
* `user.didBlock` is read here rather than through `onUserDidBlock`, which passes on only
|
|
8686
|
+
* the payload's first follow: every follow in it goes to the engine, as on Android and iOS,
|
|
8687
|
+
* so the signed-in user's block is applied wherever it sits in the payload.
|
|
8688
|
+
* The MQTT events arrive on the followers and followings topics of the BLOCK
|
|
8689
|
+
* auto-subscription (on by default).
|
|
8690
|
+
*
|
|
8691
|
+
* Registered via `setupLoginSubscriptions`; the returned unsubscriber is torn
|
|
8692
|
+
* down on logout.
|
|
8693
|
+
*/
|
|
8694
|
+
var followRealtimeOnLoginHandler = () => {
|
|
8695
|
+
const engine = FollowingSyncEngine$1.getInstance();
|
|
8696
|
+
const apply = (follow) => engine.onFollowChanged(follow);
|
|
8697
|
+
const disposers = [
|
|
8698
|
+
onUserFollowed(apply),
|
|
8699
|
+
onFollowerRequested(apply),
|
|
8700
|
+
onFollowRequestAccepted(apply),
|
|
8701
|
+
onUserUnfollowed(apply),
|
|
8702
|
+
onFollowRequestCanceled(apply),
|
|
8703
|
+
onFollowRequestDeclined(apply),
|
|
8704
|
+
onFollowerDeleted(apply),
|
|
8705
|
+
createEventSubscriber(getActiveClient(), 'user.didBlock', 'user.didBlock', payload => { var _a; return ((_a = payload === null || payload === void 0 ? void 0 : payload.follows) !== null && _a !== void 0 ? _a : []).forEach(apply); }),
|
|
8706
|
+
onLocalUserFollowed(apply),
|
|
8707
|
+
onLocalFollowerRequested(apply),
|
|
8708
|
+
onLocalUserUnfollowed(apply),
|
|
8709
|
+
];
|
|
8710
|
+
return () => disposers.forEach(dispose => dispose());
|
|
8711
|
+
};
|
|
8712
|
+
|
|
8365
8713
|
class CursorController {
|
|
8366
8714
|
constructor(networkId, userId) {
|
|
8367
8715
|
this.networkId = networkId;
|
|
@@ -9010,7 +9358,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
|
|
|
9010
9358
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
9011
9359
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
9012
9360
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
9013
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler(), userFlagByMeOnLoginHandler());
|
|
9361
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), followingSyncEngineOnLoginHandler(), followRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler(), userFlagByMeOnLoginHandler());
|
|
9014
9362
|
if (client.useLegacyUnreadCount) {
|
|
9015
9363
|
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
9016
9364
|
}
|
|
@@ -11407,6 +11755,14 @@ const blockUser = async (userId) => {
|
|
|
11407
11755
|
};
|
|
11408
11756
|
const payload = prepareFollowStatusPayload(blockedUnfollowStatus);
|
|
11409
11757
|
fireEvent('local.follow.unfollowed', payload);
|
|
11758
|
+
// the local event above swaps from and to, so getAllFollowings() cannot see this block in it
|
|
11759
|
+
if (client.userId) {
|
|
11760
|
+
FollowingSyncEngine$1.getInstance().onFollowChanged({
|
|
11761
|
+
from: client.userId,
|
|
11762
|
+
to: userId,
|
|
11763
|
+
status: 'blocked',
|
|
11764
|
+
});
|
|
11765
|
+
}
|
|
11410
11766
|
return data;
|
|
11411
11767
|
};
|
|
11412
11768
|
/* end_public_function */
|
|
@@ -11471,6 +11827,8 @@ const follow = async (userId) => {
|
|
|
11471
11827
|
ingestInCache(data, { cachedAt });
|
|
11472
11828
|
}
|
|
11473
11829
|
const payload = prepareFollowStatusPayload(data);
|
|
11830
|
+
// at once: the local event below is delivered on a later tick
|
|
11831
|
+
FollowingSyncEngine$1.getInstance().onFollowChanged(data.follows[0]);
|
|
11474
11832
|
if (data.follows[0].status === 'accepted') {
|
|
11475
11833
|
fireEvent('local.follow.created', payload);
|
|
11476
11834
|
}
|
|
@@ -11482,245 +11840,144 @@ const follow = async (userId) => {
|
|
|
11482
11840
|
cachedAt,
|
|
11483
11841
|
};
|
|
11484
11842
|
};
|
|
11485
|
-
/* end_public_function */
|
|
11486
|
-
|
|
11487
|
-
/* begin_public_function
|
|
11488
|
-
id: user.relationship.unfollow
|
|
11489
|
-
*/
|
|
11490
|
-
/**
|
|
11491
|
-
* ```js
|
|
11492
|
-
* import { unfollow } from '@amityco/ts-sdk-react-native'
|
|
11493
|
-
* await unfollow('foobar')
|
|
11494
|
-
* ```
|
|
11495
|
-
*
|
|
11496
|
-
* Cancel the follow request or unfollow the user
|
|
11497
|
-
*
|
|
11498
|
-
* @param userId the ID of the {@link Amity.InternalUser}
|
|
11499
|
-
* @returns A success boolean if the user {@link Amity.InternalUser} was unfollowed
|
|
11500
|
-
*
|
|
11501
|
-
* @category Follow API
|
|
11502
|
-
* @async
|
|
11503
|
-
*/
|
|
11504
|
-
const unfollow = async (userId) => {
|
|
11505
|
-
const client = getActiveClient();
|
|
11506
|
-
client.log('follow/unfollow', userId);
|
|
11507
|
-
const { data } = await client.http.delete(`/api/v4/me/following/${userId}`);
|
|
11508
|
-
if (client.cache) {
|
|
11509
|
-
ingestInCache(data);
|
|
11510
|
-
}
|
|
11511
|
-
const payload = prepareFollowStatusPayload(data);
|
|
11512
|
-
fireEvent('local.follow.unfollowed', payload);
|
|
11513
|
-
return true;
|
|
11514
|
-
};
|
|
11515
|
-
/* end_public_function */
|
|
11516
|
-
|
|
11517
|
-
/* begin_public_function
|
|
11518
|
-
id: user.relationship.accept_follow
|
|
11519
|
-
*/
|
|
11520
|
-
/**
|
|
11521
|
-
* ```js
|
|
11522
|
-
* import { UserRepository } from '@amityco/ts-sdk-react-native'
|
|
11523
|
-
* await UserRepository.Relationship.acceptMyFollower('foobar')
|
|
11524
|
-
* ```
|
|
11525
|
-
*
|
|
11526
|
-
* Accept the follow request
|
|
11527
|
-
*
|
|
11528
|
-
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
11529
|
-
* @returns A success boolean if the follow request was accepted
|
|
11530
|
-
*
|
|
11531
|
-
* @category Follow API
|
|
11532
|
-
* @async
|
|
11533
|
-
*/
|
|
11534
|
-
const acceptMyFollower = async (userId) => {
|
|
11535
|
-
const client = getActiveClient();
|
|
11536
|
-
client.log('follow/acceptMyFollower', userId);
|
|
11537
|
-
const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
|
|
11538
|
-
if (client.cache) {
|
|
11539
|
-
ingestInCache(data);
|
|
11540
|
-
}
|
|
11541
|
-
const payload = prepareFollowStatusPayload(data);
|
|
11542
|
-
fireEvent('local.follow.accepted', payload);
|
|
11543
|
-
return true;
|
|
11544
|
-
};
|
|
11545
|
-
/* end_public_function */
|
|
11546
|
-
|
|
11547
|
-
/* begin_public_function
|
|
11548
|
-
id: user.relationship.decline_follow
|
|
11549
|
-
*/
|
|
11550
|
-
/**
|
|
11551
|
-
* ```js
|
|
11552
|
-
* import { UserRepository } from '@amityco/ts-sdk-react-native'
|
|
11553
|
-
* await UserRepository.Relationship.declineMyFollower('foobar')
|
|
11554
|
-
* ```
|
|
11555
|
-
*
|
|
11556
|
-
* Decline the follow request or delete the follower
|
|
11557
|
-
*
|
|
11558
|
-
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
11559
|
-
* @returns A success boolean if the follow request was decline
|
|
11560
|
-
*
|
|
11561
|
-
* @category Follow API
|
|
11562
|
-
* @async
|
|
11563
|
-
*/
|
|
11564
|
-
const declineMyFollower = async (userId) => {
|
|
11565
|
-
const client = getActiveClient();
|
|
11566
|
-
client.log('follow/declineMyFollower', userId);
|
|
11567
|
-
const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
|
|
11568
|
-
if (client.cache) {
|
|
11569
|
-
ingestInCache(data);
|
|
11570
|
-
}
|
|
11571
|
-
const payload = prepareFollowStatusPayload(data);
|
|
11572
|
-
fireEvent('local.follow.requestDeclined', payload);
|
|
11573
|
-
return true;
|
|
11574
|
-
};
|
|
11575
|
-
/* end_public_function */
|
|
11576
|
-
|
|
11577
|
-
const createFollowEventSubscriber = (event, callback) => {
|
|
11578
|
-
const client = getActiveClient();
|
|
11579
|
-
const filter = (data) => {
|
|
11580
|
-
const payload = prepareFollowersPayload(data);
|
|
11581
|
-
if (!client.cache) {
|
|
11582
|
-
callback(payload.follows[0]);
|
|
11583
|
-
}
|
|
11584
|
-
else {
|
|
11585
|
-
ingestInCache(payload);
|
|
11586
|
-
callback(payload.follows[0]);
|
|
11587
|
-
}
|
|
11588
|
-
};
|
|
11589
|
-
return createEventSubscriber(client, event, event, filter);
|
|
11590
|
-
};
|
|
11591
|
-
const createLocalFollowEventSubscriber = (event, callback) => {
|
|
11592
|
-
const client = getActiveClient();
|
|
11593
|
-
const filter = (data) => {
|
|
11594
|
-
const payload = prepareFollowStatusPayload(data);
|
|
11595
|
-
if (!client.cache) {
|
|
11596
|
-
callback(payload.follows[0]);
|
|
11597
|
-
}
|
|
11598
|
-
else {
|
|
11599
|
-
ingestInCache(payload);
|
|
11600
|
-
callback(payload.follows[0]);
|
|
11601
|
-
}
|
|
11602
|
-
};
|
|
11603
|
-
return createEventSubscriber(client, event, event, filter);
|
|
11604
|
-
};
|
|
11605
|
-
|
|
11606
|
-
/**
|
|
11607
|
-
* ```js
|
|
11608
|
-
* import { onUserFollowed } from '@amityco/ts-sdk-react-native'
|
|
11609
|
-
* const dispose = onUserFollowed(status => {
|
|
11610
|
-
* // ...
|
|
11611
|
-
* })
|
|
11612
|
-
* ```
|
|
11613
|
-
*
|
|
11614
|
-
* Fired when a user follows another users and confirmation is not required
|
|
11615
|
-
*
|
|
11616
|
-
* @param callback The function to call when the event was fired
|
|
11617
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
11618
|
-
*
|
|
11619
|
-
* @category Follow Events
|
|
11620
|
-
*/
|
|
11621
|
-
const onUserFollowed = (callback) => createFollowEventSubscriber('follow.created', callback);
|
|
11622
|
-
|
|
11623
|
-
/**
|
|
11624
|
-
* ```js
|
|
11625
|
-
* import { onUserUnfollowed } from '@amityco/ts-sdk-react-native'
|
|
11626
|
-
* const dispose = onUserFollowed(status => {
|
|
11627
|
-
* // ...
|
|
11628
|
-
* })
|
|
11629
|
-
* ```
|
|
11630
|
-
*
|
|
11631
|
-
* Fired when a user unfollows
|
|
11632
|
-
*
|
|
11633
|
-
* @param callback The function to call when the event was fired
|
|
11634
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
11635
|
-
*
|
|
11636
|
-
* @category Follow Events
|
|
11637
|
-
*/
|
|
11638
|
-
const onUserUnfollowed = (callback) => createFollowEventSubscriber('follow.unfollowed', callback);
|
|
11639
|
-
|
|
11640
|
-
/**
|
|
11641
|
-
* ```js
|
|
11642
|
-
* import { onFollowerDeleted } from '@amityco/ts-sdk-react-native'
|
|
11643
|
-
* const dispose = onFollowerDeleted(status => {
|
|
11644
|
-
* // ...
|
|
11645
|
-
* })
|
|
11646
|
-
* ```
|
|
11647
|
-
*
|
|
11648
|
-
* Fired when a follower has been deleted
|
|
11649
|
-
*
|
|
11650
|
-
* @param callback The function to call when the event was fired
|
|
11651
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
11652
|
-
*
|
|
11653
|
-
* @category Follow Events
|
|
11654
|
-
*/
|
|
11655
|
-
const onFollowerDeleted = (callback) => createFollowEventSubscriber('follow.followerDeleted', callback);
|
|
11843
|
+
/* end_public_function */
|
|
11656
11844
|
|
|
11845
|
+
/* begin_public_function
|
|
11846
|
+
id: user.relationship.unfollow
|
|
11847
|
+
*/
|
|
11657
11848
|
/**
|
|
11658
11849
|
* ```js
|
|
11659
|
-
* import {
|
|
11660
|
-
*
|
|
11661
|
-
* // ...
|
|
11662
|
-
* })
|
|
11850
|
+
* import { unfollow } from '@amityco/ts-sdk-react-native'
|
|
11851
|
+
* await unfollow('foobar')
|
|
11663
11852
|
* ```
|
|
11664
11853
|
*
|
|
11665
|
-
*
|
|
11854
|
+
* Cancel the follow request or unfollow the user
|
|
11666
11855
|
*
|
|
11667
|
-
* @param
|
|
11668
|
-
* @returns
|
|
11856
|
+
* @param userId the ID of the {@link Amity.InternalUser}
|
|
11857
|
+
* @returns A success boolean if the user {@link Amity.InternalUser} was unfollowed
|
|
11669
11858
|
*
|
|
11670
|
-
* @category Follow
|
|
11859
|
+
* @category Follow API
|
|
11860
|
+
* @async
|
|
11671
11861
|
*/
|
|
11672
|
-
const
|
|
11862
|
+
const unfollow = async (userId) => {
|
|
11863
|
+
const client = getActiveClient();
|
|
11864
|
+
client.log('follow/unfollow', userId);
|
|
11865
|
+
const { data } = await client.http.delete(`/api/v4/me/following/${userId}`);
|
|
11866
|
+
if (client.cache) {
|
|
11867
|
+
ingestInCache(data);
|
|
11868
|
+
}
|
|
11869
|
+
const payload = prepareFollowStatusPayload(data);
|
|
11870
|
+
// at once: the local event below is delivered on a later tick
|
|
11871
|
+
FollowingSyncEngine$1.getInstance().onFollowChanged(data.follows[0]);
|
|
11872
|
+
fireEvent('local.follow.unfollowed', payload);
|
|
11873
|
+
return true;
|
|
11874
|
+
};
|
|
11875
|
+
/* end_public_function */
|
|
11673
11876
|
|
|
11877
|
+
/* begin_public_function
|
|
11878
|
+
id: user.relationship.accept_follow
|
|
11879
|
+
*/
|
|
11674
11880
|
/**
|
|
11675
11881
|
* ```js
|
|
11676
|
-
* import {
|
|
11677
|
-
*
|
|
11678
|
-
* // ...
|
|
11679
|
-
* })
|
|
11882
|
+
* import { UserRepository } from '@amityco/ts-sdk-react-native'
|
|
11883
|
+
* await UserRepository.Relationship.acceptMyFollower('foobar')
|
|
11680
11884
|
* ```
|
|
11681
11885
|
*
|
|
11682
|
-
*
|
|
11886
|
+
* Accept the follow request
|
|
11683
11887
|
*
|
|
11684
|
-
* @param
|
|
11685
|
-
* @returns
|
|
11888
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
11889
|
+
* @returns A success boolean if the follow request was accepted
|
|
11686
11890
|
*
|
|
11687
|
-
* @category Follow
|
|
11891
|
+
* @category Follow API
|
|
11892
|
+
* @async
|
|
11688
11893
|
*/
|
|
11689
|
-
const
|
|
11894
|
+
const acceptMyFollower = async (userId) => {
|
|
11895
|
+
const client = getActiveClient();
|
|
11896
|
+
client.log('follow/acceptMyFollower', userId);
|
|
11897
|
+
const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
|
|
11898
|
+
if (client.cache) {
|
|
11899
|
+
ingestInCache(data);
|
|
11900
|
+
}
|
|
11901
|
+
const payload = prepareFollowStatusPayload(data);
|
|
11902
|
+
fireEvent('local.follow.accepted', payload);
|
|
11903
|
+
return true;
|
|
11904
|
+
};
|
|
11905
|
+
/* end_public_function */
|
|
11690
11906
|
|
|
11907
|
+
/* begin_public_function
|
|
11908
|
+
id: user.relationship.decline_follow
|
|
11909
|
+
*/
|
|
11691
11910
|
/**
|
|
11692
11911
|
* ```js
|
|
11693
|
-
* import {
|
|
11694
|
-
*
|
|
11695
|
-
* // ...
|
|
11696
|
-
* })
|
|
11912
|
+
* import { UserRepository } from '@amityco/ts-sdk-react-native'
|
|
11913
|
+
* await UserRepository.Relationship.declineMyFollower('foobar')
|
|
11697
11914
|
* ```
|
|
11698
11915
|
*
|
|
11699
|
-
*
|
|
11916
|
+
* Decline the follow request or delete the follower
|
|
11700
11917
|
*
|
|
11701
|
-
* @param
|
|
11702
|
-
* @returns
|
|
11918
|
+
* @param userId the ID of the {@link Amity.InternalUser} follower
|
|
11919
|
+
* @returns A success boolean if the follow request was decline
|
|
11703
11920
|
*
|
|
11704
|
-
* @category Follow
|
|
11921
|
+
* @category Follow API
|
|
11922
|
+
* @async
|
|
11705
11923
|
*/
|
|
11706
|
-
const
|
|
11924
|
+
const declineMyFollower = async (userId) => {
|
|
11925
|
+
const client = getActiveClient();
|
|
11926
|
+
client.log('follow/declineMyFollower', userId);
|
|
11927
|
+
const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
|
|
11928
|
+
if (client.cache) {
|
|
11929
|
+
ingestInCache(data);
|
|
11930
|
+
}
|
|
11931
|
+
const payload = prepareFollowStatusPayload(data);
|
|
11932
|
+
fireEvent('local.follow.requestDeclined', payload);
|
|
11933
|
+
return true;
|
|
11934
|
+
};
|
|
11935
|
+
/* end_public_function */
|
|
11707
11936
|
|
|
11937
|
+
/* begin_public_function
|
|
11938
|
+
id: user.relationship.get_all_followings
|
|
11939
|
+
*/
|
|
11708
11940
|
/**
|
|
11709
11941
|
* ```js
|
|
11710
|
-
* import {
|
|
11711
|
-
*
|
|
11712
|
-
*
|
|
11713
|
-
*
|
|
11942
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
11943
|
+
*
|
|
11944
|
+
* const followings = await UserRepository.Relationship.getAllFollowings()
|
|
11945
|
+
* const statusOf = new Map(followings.map(f => [f.userId, f.status]))
|
|
11946
|
+
* // 'accepted' → no button; 'pending' → Pending; missing → Follow
|
|
11714
11947
|
* ```
|
|
11715
11948
|
*
|
|
11716
|
-
*
|
|
11949
|
+
* Returns whom the signed-in user follows as a one-shot list of at most 5,000 (the most a
|
|
11950
|
+
* user can follow), from one request with no paging: each followed user's id and the
|
|
11951
|
+
* follow's status — `accepted`, or `pending` for a request not yet accepted. A user
|
|
11952
|
+
* missing from the list is not followed. The list holds ids and statuses only, no user
|
|
11953
|
+
* profiles.
|
|
11717
11954
|
*
|
|
11718
|
-
*
|
|
11719
|
-
*
|
|
11955
|
+
* Use it to show the follow button next to each author in the post feed: match each
|
|
11956
|
+
* author by user id against `userId`.
|
|
11720
11957
|
*
|
|
11721
|
-
*
|
|
11958
|
+
* Keeping the app current: the function answers once, so call it again to see changes —
|
|
11959
|
+
* for example when more posts load or when the feed comes back into view. The answer is
|
|
11960
|
+
* kept on the device for 5 minutes, so a call within that window costs no request. Changes
|
|
11961
|
+
* made in this app show at once. Changes made elsewhere — on another device, or by the
|
|
11962
|
+
* other user accepting a request or removing the user as a follower — show once their
|
|
11963
|
+
* real-time event arrives; the SDK receives these on the followers and followings topics
|
|
11964
|
+
* of `AmityAutoSubscription.BLOCK`, on by default. An event missed while offline, or with
|
|
11965
|
+
* that subscription turned off, shows at the next fetch, after the 5 minutes.
|
|
11966
|
+
*
|
|
11967
|
+
* @returns A promise that resolves to the signed-in user's {@link Amity.FollowingUserStatus} list
|
|
11968
|
+
*
|
|
11969
|
+
* @category Follow API
|
|
11970
|
+
* @async
|
|
11722
11971
|
*/
|
|
11723
|
-
const
|
|
11972
|
+
const getAllFollowings = async () => {
|
|
11973
|
+
const client = getActiveClient();
|
|
11974
|
+
client.log('follow/getAllFollowings');
|
|
11975
|
+
const engine = FollowingSyncEngine$1.getInstance();
|
|
11976
|
+
// Fetch only when the 5-minute window has expired (no-op otherwise)
|
|
11977
|
+
await engine.ensureFetched();
|
|
11978
|
+
return engine.getFollowings();
|
|
11979
|
+
};
|
|
11980
|
+
/* end_public_function */
|
|
11724
11981
|
|
|
11725
11982
|
/**
|
|
11726
11983
|
* ```js
|
|
@@ -11826,12 +12083,6 @@ const onFollowInfoUpdated = (callback) => {
|
|
|
11826
12083
|
};
|
|
11827
12084
|
};
|
|
11828
12085
|
|
|
11829
|
-
const onLocalUserFollowed = (callback) => createLocalFollowEventSubscriber('local.follow.created', callback);
|
|
11830
|
-
|
|
11831
|
-
const onLocalUserUnfollowed = (callback) => createLocalFollowEventSubscriber('local.follow.unfollowed', callback);
|
|
11832
|
-
|
|
11833
|
-
const onLocalFollowerRequested = (callback) => createLocalFollowEventSubscriber('local.follow.requested', callback);
|
|
11834
|
-
|
|
11835
12086
|
const onLocalFollowRequestAccepted = (callback) => createLocalFollowEventSubscriber('local.follow.accepted', callback);
|
|
11836
12087
|
|
|
11837
12088
|
const onLocalFollowRequestDeclined = (callback) => createLocalFollowEventSubscriber('local.follow.requestDeclined', callback);
|
|
@@ -12553,6 +12804,7 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
12553
12804
|
unfollow: unfollow,
|
|
12554
12805
|
acceptMyFollower: acceptMyFollower,
|
|
12555
12806
|
declineMyFollower: declineMyFollower,
|
|
12807
|
+
getAllFollowings: getAllFollowings,
|
|
12556
12808
|
onUserFollowed: onUserFollowed,
|
|
12557
12809
|
onUserUnfollowed: onUserUnfollowed,
|
|
12558
12810
|
onFollowerDeleted: onFollowerDeleted,
|
|
@@ -30638,6 +30890,189 @@ const getForYouFeed = (callback) => {
|
|
|
30638
30890
|
};
|
|
30639
30891
|
/* end_public_function */
|
|
30640
30892
|
|
|
30893
|
+
class FollowingFeedQueryStreamController extends QueryStreamController {
|
|
30894
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
30895
|
+
super(query, cacheKey);
|
|
30896
|
+
this.notifyChange = notifyChange;
|
|
30897
|
+
this.preparePayload = preparePayload;
|
|
30898
|
+
}
|
|
30899
|
+
async saveToMainDB(response) {
|
|
30900
|
+
const processedPayload = await this.preparePayload(response);
|
|
30901
|
+
const client = getActiveClient();
|
|
30902
|
+
const cachedAt = client.cache && Date.now();
|
|
30903
|
+
if (client.cache) {
|
|
30904
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
30905
|
+
}
|
|
30906
|
+
}
|
|
30907
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
30908
|
+
var _a, _b;
|
|
30909
|
+
if (refresh) {
|
|
30910
|
+
pushToCache(this.cacheKey, {
|
|
30911
|
+
data: response.posts.map(getResolver('post')),
|
|
30912
|
+
});
|
|
30913
|
+
}
|
|
30914
|
+
else {
|
|
30915
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30916
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30917
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
30918
|
+
}
|
|
30919
|
+
}
|
|
30920
|
+
/**
|
|
30921
|
+
* The SDK does not know the viewer's follow list or the network's `social.globalFeed`
|
|
30922
|
+
* switches, so it cannot tell whether a new post belongs in this feed. A created or
|
|
30923
|
+
* approved post, by anyone (the current user included), never changes the list: it
|
|
30924
|
+
* appears on the next first-page load. Deleted and declined posts are removed; any
|
|
30925
|
+
* other event re-emits so listed posts render their new state.
|
|
30926
|
+
*/
|
|
30927
|
+
reactor(action) {
|
|
30928
|
+
return (post) => {
|
|
30929
|
+
var _a;
|
|
30930
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
30931
|
+
return;
|
|
30932
|
+
}
|
|
30933
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30934
|
+
if (!collection)
|
|
30935
|
+
return;
|
|
30936
|
+
// A child post event never adds or removes an entry; it re-emits only when its parent is listed
|
|
30937
|
+
if (post.parentPostId) {
|
|
30938
|
+
if (!collection.data.includes(post.parentPostId))
|
|
30939
|
+
return;
|
|
30940
|
+
}
|
|
30941
|
+
else if (action === EnumPostActions.OnPostDeleted ||
|
|
30942
|
+
action === EnumPostActions.OnPostDeclined) {
|
|
30943
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
30944
|
+
}
|
|
30945
|
+
pushToCache(this.cacheKey, collection);
|
|
30946
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
30947
|
+
};
|
|
30948
|
+
}
|
|
30949
|
+
subscribeRTE(createSubscriber) {
|
|
30950
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
30951
|
+
}
|
|
30952
|
+
}
|
|
30953
|
+
|
|
30954
|
+
/**
|
|
30955
|
+
* `GET /api/v1/me/following-feeds` reads `limit` and `token` as flat query params.
|
|
30956
|
+
* Unlike the global feed, they must not be nested in `options`: the endpoint forwards
|
|
30957
|
+
* only `{ limit, token }`, so a nested token would be dropped and every page would be page one.
|
|
30958
|
+
*/
|
|
30959
|
+
class FollowingFeedPaginationController extends PaginationController {
|
|
30960
|
+
async getRequest(queryParams, token) {
|
|
30961
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_SIZE, sortBy } = queryParams;
|
|
30962
|
+
const params = token ? { token } : { limit };
|
|
30963
|
+
if (sortBy)
|
|
30964
|
+
params.sortBy = sortBy;
|
|
30965
|
+
const { data: queryResponse } = await this.http.get(API_ENDPOINTS.followingFeed, { params });
|
|
30966
|
+
return queryResponse;
|
|
30967
|
+
}
|
|
30968
|
+
}
|
|
30969
|
+
|
|
30970
|
+
class FollowingFeedLiveCollectionController extends LiveCollectionController {
|
|
30971
|
+
constructor(query, callback) {
|
|
30972
|
+
const queryStreamId = hash__default["default"](query);
|
|
30973
|
+
const cacheKey = ['followingFeed', 'collection', queryStreamId];
|
|
30974
|
+
const paginationController = new FollowingFeedPaginationController(query);
|
|
30975
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
30976
|
+
this.query = query;
|
|
30977
|
+
this.queryStreamController = new FollowingFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
30978
|
+
this.callback = callback.bind(this);
|
|
30979
|
+
this.loadPage({ initial: true });
|
|
30980
|
+
}
|
|
30981
|
+
setup() {
|
|
30982
|
+
var _a;
|
|
30983
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30984
|
+
if (!collection) {
|
|
30985
|
+
pushToCache(this.cacheKey, {
|
|
30986
|
+
data: [],
|
|
30987
|
+
params: {},
|
|
30988
|
+
});
|
|
30989
|
+
}
|
|
30990
|
+
}
|
|
30991
|
+
async persistModel(queryPayload) {
|
|
30992
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
30993
|
+
}
|
|
30994
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
30995
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
30996
|
+
}
|
|
30997
|
+
startSubscription() {
|
|
30998
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
30999
|
+
}
|
|
31000
|
+
notifyChange({ origin, loading, error }) {
|
|
31001
|
+
var _a, _b;
|
|
31002
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31003
|
+
if (!collection)
|
|
31004
|
+
return;
|
|
31005
|
+
const data = ((_b = collection.data
|
|
31006
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
31007
|
+
.filter(isNonNullable)
|
|
31008
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
31009
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
31010
|
+
return;
|
|
31011
|
+
this.callback({
|
|
31012
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
31013
|
+
data,
|
|
31014
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
31015
|
+
loading,
|
|
31016
|
+
error,
|
|
31017
|
+
});
|
|
31018
|
+
}
|
|
31019
|
+
}
|
|
31020
|
+
|
|
31021
|
+
/* begin_public_function
|
|
31022
|
+
id: feed.query.following_feed
|
|
31023
|
+
api_style: live_collection
|
|
31024
|
+
*/
|
|
31025
|
+
/**
|
|
31026
|
+
* ```js
|
|
31027
|
+
* import { FeedRepository, FollowingFeedSortByEnum } from '@amityco/ts-sdk'
|
|
31028
|
+
*
|
|
31029
|
+
* const unsub = FeedRepository.getFollowingFeed(
|
|
31030
|
+
* { sortBy: FollowingFeedSortByEnum.LastCreated, limit: 20 },
|
|
31031
|
+
* ({ data: posts, hasNextPage, onNextPage, loading, error }) => processResponse(posts),
|
|
31032
|
+
* )
|
|
31033
|
+
* ```
|
|
31034
|
+
*
|
|
31035
|
+
* Observe all mutations on a list of {@link Amity.Post} for the current user's following feed.
|
|
31036
|
+
* Which posts match is decided by the server, from the network's `social.globalFeed` setting:
|
|
31037
|
+
* - `lastCreated`: posts by the users the current user follows, plus the current user's own
|
|
31038
|
+
* posts, newest first.
|
|
31039
|
+
* - `customRanking` (the default): server-ranked posts by the current user, the users they
|
|
31040
|
+
* follow and the communities they joined.
|
|
31041
|
+
*
|
|
31042
|
+
* A new post, the current user's own included, is not added in real time: it appears
|
|
31043
|
+
* when the feed is next loaded from the first page (for example, a new subscription).
|
|
31044
|
+
* With `customRanking` the server may take up to 5 minutes to include it.
|
|
31045
|
+
* Deleted and declined posts are removed at once.
|
|
31046
|
+
*
|
|
31047
|
+
* When the network enforces module entitlement and the `feed` module is not entitled,
|
|
31048
|
+
* the request fails with `400325` (`ModuleNotEntitled`), reported through `error`.
|
|
31049
|
+
*
|
|
31050
|
+
* @param params.sortBy order of the feed. When omitted, the server default (`customRanking`) applies
|
|
31051
|
+
* @param params.limit page size of the first request (1 - 100)
|
|
31052
|
+
* @param callback the function to call when new data are available
|
|
31053
|
+
* @param config
|
|
31054
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the posts
|
|
31055
|
+
*
|
|
31056
|
+
* @category Posts Live Collection
|
|
31057
|
+
*/
|
|
31058
|
+
const getFollowingFeed = (params, callback, config) => {
|
|
31059
|
+
const { log, cache } = getActiveClient();
|
|
31060
|
+
if (!cache) {
|
|
31061
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
31062
|
+
}
|
|
31063
|
+
const timestamp = Date.now();
|
|
31064
|
+
log(`getFollowingFeed(tmpid: ${timestamp}) > listen`);
|
|
31065
|
+
const liveCollection = new FollowingFeedLiveCollectionController(params, callback);
|
|
31066
|
+
const disposers = liveCollection.startSubscription();
|
|
31067
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
31068
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
31069
|
+
return () => {
|
|
31070
|
+
log(`getFollowingFeed(tmpid: ${timestamp}) > dispose`);
|
|
31071
|
+
disposers.forEach(fn => fn());
|
|
31072
|
+
};
|
|
31073
|
+
};
|
|
31074
|
+
/* end_public_function */
|
|
31075
|
+
|
|
30641
31076
|
var index$e = /*#__PURE__*/Object.freeze({
|
|
30642
31077
|
__proto__: null,
|
|
30643
31078
|
queryGlobalFeed: queryGlobalFeed,
|
|
@@ -30646,6 +31081,7 @@ var index$e = /*#__PURE__*/Object.freeze({
|
|
|
30646
31081
|
getUserFeed: getUserFeed,
|
|
30647
31082
|
getCommunityFeed: getCommunityFeed,
|
|
30648
31083
|
getForYouFeed: getForYouFeed,
|
|
31084
|
+
getFollowingFeed: getFollowingFeed,
|
|
30649
31085
|
AmityForYouFeedDisabledError: AmityForYouFeedDisabledError
|
|
30650
31086
|
});
|
|
30651
31087
|
|