@amityco/ts-sdk-react-native 7.33.2-9759e33.0 → 7.34.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.
Files changed (52) hide show
  1. package/dist/@types/core/payload.d.ts +4 -0
  2. package/dist/@types/core/payload.d.ts.map +1 -1
  3. package/dist/@types/domains/content.d.ts +5 -0
  4. package/dist/@types/domains/content.d.ts.map +1 -1
  5. package/dist/@types/domains/feed.d.ts +14 -0
  6. package/dist/@types/domains/feed.d.ts.map +1 -1
  7. package/dist/@types/domains/follow.d.ts +7 -0
  8. package/dist/@types/domains/follow.d.ts.map +1 -1
  9. package/dist/@types/domains/notification.d.ts +15 -3
  10. package/dist/@types/domains/notification.d.ts.map +1 -1
  11. package/dist/client/api/getFeedSettings.d.ts +3 -1
  12. package/dist/client/api/getFeedSettings.d.ts.map +1 -1
  13. package/dist/client/api/setupLoginSubscriptions.d.ts.map +1 -1
  14. package/dist/feedRepository/index.d.ts +1 -1
  15. package/dist/feedRepository/index.d.ts.map +1 -1
  16. package/dist/feedRepository/observers/getFollowingFeed/LiveCollectionController.d.ts +13 -0
  17. package/dist/feedRepository/observers/getFollowingFeed/LiveCollectionController.d.ts.map +1 -0
  18. package/dist/feedRepository/observers/getFollowingFeed/PaginationController.d.ts +10 -0
  19. package/dist/feedRepository/observers/getFollowingFeed/PaginationController.d.ts.map +1 -0
  20. package/dist/feedRepository/observers/getFollowingFeed/QueryStreamController.d.ts +22 -0
  21. package/dist/feedRepository/observers/getFollowingFeed/QueryStreamController.d.ts.map +1 -0
  22. package/dist/feedRepository/observers/getFollowingFeed.d.ts +35 -0
  23. package/dist/feedRepository/observers/getFollowingFeed.d.ts.map +1 -0
  24. package/dist/feedRepository/observers/index.d.ts +1 -0
  25. package/dist/feedRepository/observers/index.d.ts.map +1 -1
  26. package/dist/feedRepository/observers/tests/integration/getFollowingFeed.integration.test.d.ts +2 -0
  27. package/dist/feedRepository/observers/tests/integration/getFollowingFeed.integration.test.d.ts.map +1 -0
  28. package/dist/feedRepository/observers/tests/unit/FollowingFeedQueryStreamController.test.d.ts +2 -0
  29. package/dist/feedRepository/observers/tests/unit/FollowingFeedQueryStreamController.test.d.ts.map +1 -0
  30. package/dist/index.cjs.js +699 -263
  31. package/dist/index.esm.js +630 -194
  32. package/dist/index.umd.js +1 -1
  33. package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
  34. package/dist/userRepository/relationship/follow/api/follow.d.ts.map +1 -1
  35. package/dist/userRepository/relationship/follow/api/getAllFollowings.d.ts +34 -0
  36. package/dist/userRepository/relationship/follow/api/getAllFollowings.d.ts.map +1 -0
  37. package/dist/userRepository/relationship/follow/api/index.d.ts +1 -0
  38. package/dist/userRepository/relationship/follow/api/index.d.ts.map +1 -1
  39. package/dist/userRepository/relationship/follow/api/tests/getAllFollowings.test.d.ts +2 -0
  40. package/dist/userRepository/relationship/follow/api/tests/getAllFollowings.test.d.ts.map +1 -0
  41. package/dist/userRepository/relationship/follow/api/tests/integration/getAllFollowings.integration.test.d.ts +2 -0
  42. package/dist/userRepository/relationship/follow/api/tests/integration/getAllFollowings.integration.test.d.ts.map +1 -0
  43. package/dist/userRepository/relationship/follow/api/unfollow.d.ts.map +1 -1
  44. package/dist/userRepository/services/FollowingSyncEngine/followRealtimeOnLoginHandler.d.ts +19 -0
  45. package/dist/userRepository/services/FollowingSyncEngine/followRealtimeOnLoginHandler.d.ts.map +1 -0
  46. package/dist/userRepository/services/FollowingSyncEngine/followingSyncEngine.d.ts +61 -0
  47. package/dist/userRepository/services/FollowingSyncEngine/followingSyncEngine.d.ts.map +1 -0
  48. package/dist/userRepository/services/FollowingSyncEngine/followingSyncEngineOnLoginHandler.d.ts +3 -0
  49. package/dist/userRepository/services/FollowingSyncEngine/followingSyncEngineOnLoginHandler.d.ts.map +1 -0
  50. package/dist/utils/constants.d.ts +1 -0
  51. package/dist/utils/constants.d.ts.map +1 -1
  52. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -248,6 +248,14 @@ var FeedSortByEnum;
248
248
  FeedSortByEnum["LastUpdated"] = "lastUpdated";
249
249
  FeedSortByEnum["FirstUpdated"] = "firstUpdated";
250
250
  })(FeedSortByEnum || (FeedSortByEnum = {}));
251
+ /** Sort order of the following feed (`GET /api/v1/me/following-feeds`). */
252
+ var FollowingFeedSortByEnum;
253
+ (function (FollowingFeedSortByEnum) {
254
+ /** Server-ranked. The backend default when `sortBy` is not sent. */
255
+ FollowingFeedSortByEnum["CustomRanking"] = "customRanking";
256
+ /** Newest first. */
257
+ FollowingFeedSortByEnum["LastCreated"] = "lastCreated";
258
+ })(FollowingFeedSortByEnum || (FollowingFeedSortByEnum = {}));
251
259
  var FeedSourceEnum;
252
260
  (function (FeedSourceEnum) {
253
261
  FeedSourceEnum["Community"] = "community";
@@ -350,8 +358,8 @@ var AmityLiveViewerCountMode;
350
358
 
351
359
  function getVersion() {
352
360
  try {
353
- // the string ''v7.33.1-esm'' should be replaced by actual value by @rollup/plugin-replace
354
- return 'v7.33.1-esm';
361
+ // the string ''v7.34.0-esm'' should be replaced by actual value by @rollup/plugin-replace
362
+ return 'v7.34.0-esm';
355
363
  }
356
364
  catch (error) {
357
365
  return '__dev__';
@@ -376,6 +384,7 @@ const YEAR = 365 * DAY;
376
384
  const ACCESS_TOKEN_WATCHER_INTERVAL = 10 * MINUTE;
377
385
  const API_ENDPOINTS = {
378
386
  forYouFeed: '/api/v1/feeds/for-you',
387
+ followingFeed: '/api/v1/me/following-feeds',
379
388
  commentReviewQueue: (communityId) => `/api/v3/communities/${encodeURIComponent(communityId)}/comments/review-queue`,
380
389
  };
381
390
  // The review-queue route defaults to 10, not the SDK-wide page size, and caps at 100
@@ -1969,13 +1978,13 @@ class SessionWatcher {
1969
1978
  this._listener.clear();
1970
1979
  }
1971
1980
  }
1972
- let instance$b;
1981
+ let instance$c;
1973
1982
  var SessionWatcher$1 = {
1974
1983
  getInstance: () => {
1975
- if (!instance$b) {
1976
- instance$b = new SessionWatcher();
1984
+ if (!instance$c) {
1985
+ instance$c = new SessionWatcher();
1977
1986
  }
1978
- return instance$b;
1987
+ return instance$c;
1979
1988
  },
1980
1989
  };
1981
1990
 
@@ -2642,13 +2651,13 @@ class NetworkActivitiesWatcher {
2642
2651
  this._listener.clear();
2643
2652
  }
2644
2653
  }
2645
- let instance$a;
2654
+ let instance$b;
2646
2655
  var NetworkActivitiesWatcher$1 = {
2647
2656
  getInstance: () => {
2648
- if (!instance$a) {
2649
- instance$a = new NetworkActivitiesWatcher();
2657
+ if (!instance$b) {
2658
+ instance$b = new NetworkActivitiesWatcher();
2650
2659
  }
2651
- return instance$a;
2660
+ return instance$b;
2652
2661
  },
2653
2662
  };
2654
2663
 
@@ -2909,11 +2918,11 @@ class AutoSubscriptionManager {
2909
2918
  this.seed();
2910
2919
  }
2911
2920
  }
2912
- let instance$9 = null;
2921
+ let instance$a = null;
2913
2922
  const getAutoSubscriptionManager = () => {
2914
- if (!instance$9)
2915
- instance$9 = new AutoSubscriptionManager();
2916
- return instance$9;
2923
+ if (!instance$a)
2924
+ instance$a = new AutoSubscriptionManager();
2925
+ return instance$a;
2917
2926
  };
2918
2927
  /** Resets the registry to its default baseline when the session ends. */
2919
2928
  const resetAutoSubscriptionsOnLogout = () => onSessionStateChange(state => {
@@ -6296,9 +6305,11 @@ const validateTexts = async (texts) => {
6296
6305
  * import { getFeedSettings } from '@amityco/ts-sdk-react-native'
6297
6306
  * const feedSettings = await getFeedSettings()
6298
6307
  * const postFeedSetting = feedSettings.post
6308
+ * const isAutoPlayEnabled = postFeedSetting?.find(({ contentType }) => contentType === 'video')?.autoPlay
6299
6309
  * ```
6300
6310
  *
6301
- * Fetches a {@link Amity.FeedSettings} object
6311
+ * Fetches a {@link Amity.FeedSettings} object. Video content settings always
6312
+ * carry `autoPlay`, which is `false` when the server omits it.
6302
6313
  *
6303
6314
  * @returns A Promise of {@link Amity.FeedSettings} object
6304
6315
  *
@@ -6309,7 +6320,14 @@ const getFeedSettings = async () => {
6309
6320
  const client = getActiveClient();
6310
6321
  const { data } = await client.http.get(`/api/v3/network-settings/feed-setting`);
6311
6322
  return Object.fromEntries(data.feedSettings.map(({ feedType, contentSettings }) => {
6312
- return [feedType, contentSettings];
6323
+ return [
6324
+ feedType,
6325
+ contentSettings === null || contentSettings === void 0 ? void 0 : contentSettings.map(setting => {
6326
+ var _a;
6327
+ return setting.contentType === 'video'
6328
+ ? Object.assign(Object.assign({}, setting), { autoPlay: (_a = setting.autoPlay) !== null && _a !== void 0 ? _a : false }) : setting;
6329
+ }),
6330
+ ];
6313
6331
  }));
6314
6332
  };
6315
6333
 
@@ -7040,13 +7058,13 @@ class AnalyticsEngine {
7040
7058
  this._eventCapturer.resetAllBuckets();
7041
7059
  }
7042
7060
  }
7043
- let instance$8;
7061
+ let instance$9;
7044
7062
  var AnalyticsEngine$1 = {
7045
7063
  getInstance: () => {
7046
- if (!instance$8) {
7047
- instance$8 = new AnalyticsEngine();
7064
+ if (!instance$9) {
7065
+ instance$9 = new AnalyticsEngine();
7048
7066
  }
7049
- return instance$8;
7067
+ return instance$9;
7050
7068
  },
7051
7069
  };
7052
7070
 
@@ -7273,12 +7291,12 @@ class MessageReadReceiptSyncEngine {
7273
7291
  }
7274
7292
  }
7275
7293
  }
7276
- let instance$7 = null;
7294
+ let instance$8 = null;
7277
7295
  var ReadReceiptSyncEngine = {
7278
7296
  getInstance: () => {
7279
- if (!instance$7)
7280
- instance$7 = new MessageReadReceiptSyncEngine();
7281
- return instance$7;
7297
+ if (!instance$8)
7298
+ instance$8 = new MessageReadReceiptSyncEngine();
7299
+ return instance$8;
7282
7300
  },
7283
7301
  };
7284
7302
 
@@ -7532,12 +7550,12 @@ class LegacyMessageReadReceiptSyncEngine {
7532
7550
  }
7533
7551
  }
7534
7552
  }
7535
- let instance$6 = null;
7553
+ let instance$7 = null;
7536
7554
  var LegacyReadReceiptSyncEngine = {
7537
7555
  getInstance: () => {
7538
- if (!instance$6)
7539
- instance$6 = new LegacyMessageReadReceiptSyncEngine();
7540
- return instance$6;
7556
+ if (!instance$7)
7557
+ instance$7 = new LegacyMessageReadReceiptSyncEngine();
7558
+ return instance$7;
7541
7559
  },
7542
7560
  };
7543
7561
 
@@ -7813,12 +7831,12 @@ class ObjectResolverEngine {
7813
7831
  this.stopResolver();
7814
7832
  }
7815
7833
  }
7816
- let instance$5 = null;
7834
+ let instance$6 = null;
7817
7835
  var ObjectResolverEngine$1 = {
7818
7836
  getInstance: () => {
7819
- if (!instance$5)
7820
- instance$5 = new ObjectResolverEngine();
7821
- return instance$5;
7837
+ if (!instance$6)
7838
+ instance$6 = new ObjectResolverEngine();
7839
+ return instance$6;
7822
7840
  },
7823
7841
  };
7824
7842
 
@@ -7968,13 +7986,13 @@ class LiveReactionSyncEngine {
7968
7986
  this.stopReactionsSync();
7969
7987
  }
7970
7988
  }
7971
- let instance$4;
7989
+ let instance$5;
7972
7990
  var ReactionSyncEngine = {
7973
7991
  getInstance: () => {
7974
- if (!instance$4) {
7975
- instance$4 = new LiveReactionSyncEngine();
7992
+ if (!instance$5) {
7993
+ instance$5 = new LiveReactionSyncEngine();
7976
7994
  }
7977
- return instance$4;
7995
+ return instance$5;
7978
7996
  },
7979
7997
  };
7980
7998
 
@@ -8005,7 +8023,7 @@ function prepareBlockedUserPayload(response) {
8005
8023
  }
8006
8024
 
8007
8025
  const BLOCK_LIST_LIMIT$1 = 100;
8008
- const TTL_MS$1 = 5 * 60 * 1000; // 5 minutes
8026
+ const TTL_MS$2 = 5 * 60 * 1000; // 5 minutes
8009
8027
  /**
8010
8028
  * Session-scoped singleton engine that manages TTL-based fetching and caching
8011
8029
  * of blocked users. Provides a lazy `ensureFetched()` gate for the
@@ -8043,7 +8061,7 @@ class BlockedUserSyncEngine {
8043
8061
  isCacheExpired() {
8044
8062
  if (this.lastFetchedAt === null)
8045
8063
  return true;
8046
- return Date.now() - this.lastFetchedAt > TTL_MS$1;
8064
+ return Date.now() - this.lastFetchedAt > TTL_MS$2;
8047
8065
  }
8048
8066
  /**
8049
8067
  * Ensures the local store is populated with fresh blocked-user data.
@@ -8098,12 +8116,12 @@ class BlockedUserSyncEngine {
8098
8116
  .map(userLinkedObject);
8099
8117
  }
8100
8118
  }
8101
- let instance$3 = null;
8119
+ let instance$4 = null;
8102
8120
  var BlockedUserSyncEngine$1 = {
8103
8121
  getInstance: () => {
8104
- if (!instance$3)
8105
- instance$3 = new BlockedUserSyncEngine();
8106
- return instance$3;
8122
+ if (!instance$4)
8123
+ instance$4 = new BlockedUserSyncEngine();
8124
+ return instance$4;
8107
8125
  },
8108
8126
  };
8109
8127
 
@@ -8134,7 +8152,7 @@ function prepareBlockingUserPayload(response) {
8134
8152
  }
8135
8153
 
8136
8154
  const BLOCK_LIST_LIMIT = 100;
8137
- const TTL_MS = 5 * 60 * 1000; // 5 minutes
8155
+ const TTL_MS$1 = 5 * 60 * 1000; // 5 minutes
8138
8156
  /**
8139
8157
  * Session-scoped singleton engine that manages TTL-based fetching and caching
8140
8158
  * of blocking users (the "blocked-by" list — users who blocked the current
@@ -8173,7 +8191,7 @@ class BlockingUserSyncEngine {
8173
8191
  isCacheExpired() {
8174
8192
  if (this.lastFetchedAt === null)
8175
8193
  return true;
8176
- return Date.now() - this.lastFetchedAt > TTL_MS;
8194
+ return Date.now() - this.lastFetchedAt > TTL_MS$1;
8177
8195
  }
8178
8196
  /**
8179
8197
  * Ensures the local store is populated with fresh blocking-user data.
@@ -8228,12 +8246,12 @@ class BlockingUserSyncEngine {
8228
8246
  .map(userLinkedObject);
8229
8247
  }
8230
8248
  }
8231
- let instance$2 = null;
8249
+ let instance$3 = null;
8232
8250
  var BlockingUserSyncEngine$1 = {
8233
8251
  getInstance: () => {
8234
- if (!instance$2)
8235
- instance$2 = new BlockingUserSyncEngine();
8236
- return instance$2;
8252
+ if (!instance$3)
8253
+ instance$3 = new BlockingUserSyncEngine();
8254
+ return instance$3;
8237
8255
  },
8238
8256
  };
8239
8257
 
@@ -8343,6 +8361,336 @@ var blockRealtimeOnLoginHandler = () => {
8343
8361
  return () => disposers.forEach(dispose => dispose());
8344
8362
  };
8345
8363
 
8364
+ const TTL_MS = 5 * 60 * 1000; // 5 minutes, as BlockedUserSyncEngine
8365
+ const isKept = (status) => status === 'accepted' || status === 'pending';
8366
+ /**
8367
+ * Session-scoped singleton engine behind `getAllFollowings()`: a 5-minute fetch gate
8368
+ * on `GET /api/v4/me/following-ids`, copied from BlockedUserSyncEngine.
8369
+ *
8370
+ * - `onSessionEstablished()` is a no-op — the fetch is lazy, on the first call
8371
+ * - `onSessionDestroyed()` resets `lastFetchedAt` and empties the list, so the next
8372
+ * session fetches again
8373
+ * - `ensureFetched()` fetches only when the window expired or nothing was fetched yet;
8374
+ * `lastFetchedAt` moves only on success
8375
+ * - the answer holds ids and statuses only, so the engine keeps it in memory — user id →
8376
+ * status — replaced on each fetch, never merged: a follow removed on another device
8377
+ * drops out at the next fetch. Nothing is written to the follow or user cache.
8378
+ * - `onFollowChanged()` applies every follow change of the session by its status; a change
8379
+ * that arrives while a fetch is in flight is replayed on top of the answer, so the older
8380
+ * answer does not drop it. Concurrent calls share one in-flight fetch.
8381
+ *
8382
+ * @internal
8383
+ */
8384
+ class FollowingSyncEngine {
8385
+ constructor() {
8386
+ /** Epoch ms of the last successful fetch. null = never fetched in this session. */
8387
+ this.lastFetchedAt = null;
8388
+ /** user id → status, in order: the session's changes first, then the answer's order. */
8389
+ this.followings = new Map();
8390
+ /** Bumped on sign-out, so a fetch from the old session cannot fill the new one. */
8391
+ this.session = 0;
8392
+ /** The in-flight fetch, shared by concurrent calls. */
8393
+ this.fetching = null;
8394
+ /** Changes applied while `fetching` is in flight, replayed on top of its answer. */
8395
+ this.changesDuringFetch = [];
8396
+ }
8397
+ /** No-op — the fetch is lazy, triggered by getAllFollowings(). */
8398
+ // eslint-disable-next-line class-methods-use-this
8399
+ onSessionEstablished() {
8400
+ // intentionally empty
8401
+ }
8402
+ /** Resets the window so the next session starts with a fresh fetch. */
8403
+ onSessionDestroyed() {
8404
+ this.lastFetchedAt = null;
8405
+ this.followings = new Map();
8406
+ this.fetching = null;
8407
+ this.changesDuringFetch = [];
8408
+ this.session += 1;
8409
+ }
8410
+ /** No-op — the window does not depend on the token. */
8411
+ // eslint-disable-next-line class-methods-use-this
8412
+ onTokenExpired() {
8413
+ // intentionally empty
8414
+ }
8415
+ /**
8416
+ * Called for every follow change the SDK sees during the session. A follow whose
8417
+ * `from` is another user is ignored. Status `accepted` or `pending` sets the user with
8418
+ * that status and moves them to the front; any other status (`none` after an unfollow,
8419
+ * a cancel, a decline or a removed follower; `blocked`) removes them.
8420
+ */
8421
+ onFollowChanged(follow) {
8422
+ if (!follow || follow.from !== getActiveClient().userId)
8423
+ return;
8424
+ if (this.fetching)
8425
+ this.changesDuringFetch.push(follow);
8426
+ this.apply(follow);
8427
+ }
8428
+ apply(follow) {
8429
+ const rest = [...this.followings].filter(([userId]) => userId !== follow.to);
8430
+ this.followings = new Map(isKept(follow.status) ? [[follow.to, follow.status], ...rest] : rest);
8431
+ }
8432
+ isCacheExpired() {
8433
+ if (this.lastFetchedAt === null)
8434
+ return true;
8435
+ return Date.now() - this.lastFetchedAt > TTL_MS;
8436
+ }
8437
+ /**
8438
+ * Fetches whom the user follows (up to 5,000 ids and statuses, one response, no
8439
+ * `status` so both accepted and pending come back) when the window has expired. A
8440
+ * failure propagates and leaves the window and the list unchanged, so the next call
8441
+ * retries.
8442
+ */
8443
+ async ensureFetched() {
8444
+ if (!this.isCacheExpired())
8445
+ return;
8446
+ if (!this.fetching) {
8447
+ const { session } = this;
8448
+ this.changesDuringFetch = [];
8449
+ this.fetching = this.fetch(session).finally(() => {
8450
+ if (session !== this.session)
8451
+ return;
8452
+ this.fetching = null;
8453
+ this.changesDuringFetch = [];
8454
+ });
8455
+ }
8456
+ await this.fetching;
8457
+ }
8458
+ async fetch(session) {
8459
+ var _a;
8460
+ const client = getActiveClient();
8461
+ const { data } = await client.http.get('/api/v4/me/following-ids');
8462
+ if (session !== this.session)
8463
+ return; // signed out while in flight
8464
+ // replaced, never merged
8465
+ this.followings = new Map(((_a = data === null || data === void 0 ? void 0 : data.follows) !== null && _a !== void 0 ? _a : [])
8466
+ .filter(follow => isKept(follow.status))
8467
+ .map(follow => [follow.userId, follow.status]));
8468
+ // a change made while the request was in flight is newer than the answer
8469
+ this.changesDuringFetch.forEach(change => this.apply(change));
8470
+ this.lastFetchedAt = Date.now();
8471
+ }
8472
+ /** The kept entries, in order. */
8473
+ getFollowings() {
8474
+ return [...this.followings].map(([userId, status]) => ({ userId, status }));
8475
+ }
8476
+ }
8477
+ let instance$2 = null;
8478
+ var FollowingSyncEngine$1 = {
8479
+ getInstance: () => {
8480
+ if (!instance$2)
8481
+ instance$2 = new FollowingSyncEngine();
8482
+ return instance$2;
8483
+ },
8484
+ };
8485
+
8486
+ var followingSyncEngineOnLoginHandler = () => {
8487
+ const followingSyncEngine = FollowingSyncEngine$1.getInstance();
8488
+ onSessionStateChange(state => {
8489
+ if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
8490
+ followingSyncEngine.onSessionEstablished();
8491
+ }
8492
+ else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
8493
+ followingSyncEngine.onTokenExpired();
8494
+ }
8495
+ else {
8496
+ followingSyncEngine.onSessionDestroyed();
8497
+ }
8498
+ });
8499
+ return () => {
8500
+ followingSyncEngine.onSessionDestroyed();
8501
+ };
8502
+ };
8503
+
8504
+ const createFollowEventSubscriber = (event, callback) => {
8505
+ const client = getActiveClient();
8506
+ const filter = (data) => {
8507
+ const payload = prepareFollowersPayload(data);
8508
+ if (!client.cache) {
8509
+ callback(payload.follows[0]);
8510
+ }
8511
+ else {
8512
+ ingestInCache(payload);
8513
+ callback(payload.follows[0]);
8514
+ }
8515
+ };
8516
+ return createEventSubscriber(client, event, event, filter);
8517
+ };
8518
+ const createLocalFollowEventSubscriber = (event, callback) => {
8519
+ const client = getActiveClient();
8520
+ const filter = (data) => {
8521
+ const payload = prepareFollowStatusPayload(data);
8522
+ if (!client.cache) {
8523
+ callback(payload.follows[0]);
8524
+ }
8525
+ else {
8526
+ ingestInCache(payload);
8527
+ callback(payload.follows[0]);
8528
+ }
8529
+ };
8530
+ return createEventSubscriber(client, event, event, filter);
8531
+ };
8532
+
8533
+ /**
8534
+ * ```js
8535
+ * import { onUserFollowed } from '@amityco/ts-sdk-react-native'
8536
+ * const dispose = onUserFollowed(status => {
8537
+ * // ...
8538
+ * })
8539
+ * ```
8540
+ *
8541
+ * Fired when a user follows another users and confirmation is not required
8542
+ *
8543
+ * @param callback The function to call when the event was fired
8544
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
8545
+ *
8546
+ * @category Follow Events
8547
+ */
8548
+ const onUserFollowed = (callback) => createFollowEventSubscriber('follow.created', callback);
8549
+
8550
+ /**
8551
+ * ```js
8552
+ * import { onFollowerRequested } from '@amityco/ts-sdk-react-native'
8553
+ * const dispose = onFollowerRequested(status => {
8554
+ * // ...
8555
+ * })
8556
+ * ```
8557
+ *
8558
+ * Fired when a user follows another users and confirmation is required
8559
+ *
8560
+ * @param callback The function to call when the event was fired
8561
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
8562
+ *
8563
+ * @category Follow Events
8564
+ */
8565
+ const onFollowerRequested = (callback) => createFollowEventSubscriber('follow.requested', callback);
8566
+
8567
+ /**
8568
+ * ```js
8569
+ * import { onFollowRequestAccepted } from '@amityco/ts-sdk-react-native'
8570
+ * const dispose = onFollowRequestAccepted(status => {
8571
+ * // ...
8572
+ * })
8573
+ * ```
8574
+ *
8575
+ * Fired when a follow request has been accepted
8576
+ *
8577
+ * @param callback The function to call when the event was fired
8578
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
8579
+ *
8580
+ * @category Follow Events
8581
+ */
8582
+ const onFollowRequestAccepted = (callback) => createFollowEventSubscriber('follow.accepted', callback);
8583
+
8584
+ /**
8585
+ * ```js
8586
+ * import { onUserUnfollowed } from '@amityco/ts-sdk-react-native'
8587
+ * const dispose = onUserFollowed(status => {
8588
+ * // ...
8589
+ * })
8590
+ * ```
8591
+ *
8592
+ * Fired when a user unfollows
8593
+ *
8594
+ * @param callback The function to call when the event was fired
8595
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
8596
+ *
8597
+ * @category Follow Events
8598
+ */
8599
+ const onUserUnfollowed = (callback) => createFollowEventSubscriber('follow.unfollowed', callback);
8600
+
8601
+ /**
8602
+ * ```js
8603
+ * import { onFollowRequestCanceled } from '@amityco/ts-sdk-react-native'
8604
+ * const dispose = onFollowRequestCanceled(status => {
8605
+ * // ...
8606
+ * })
8607
+ * ```
8608
+ *
8609
+ * Fired when a follow request has been canceled
8610
+ *
8611
+ * @param callback The function to call when the event was fired
8612
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
8613
+ *
8614
+ * @category Follow Events
8615
+ */
8616
+ const onFollowRequestCanceled = (callback) => createFollowEventSubscriber('follow.requestCanceled', callback);
8617
+
8618
+ /**
8619
+ * ```js
8620
+ * import { onFollowRequestDeclined } from '@amityco/ts-sdk-react-native'
8621
+ * const dispose = onFollowRequestDeclined(status => {
8622
+ * // ...
8623
+ * })
8624
+ * ```
8625
+ *
8626
+ * Fired when a follow request has been declined
8627
+ *
8628
+ * @param callback The function to call when the event was fired
8629
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
8630
+ *
8631
+ * @category Follow Events
8632
+ */
8633
+ const onFollowRequestDeclined = (callback) => createFollowEventSubscriber('follow.requestDeclined', callback);
8634
+
8635
+ /**
8636
+ * ```js
8637
+ * import { onFollowerDeleted } from '@amityco/ts-sdk-react-native'
8638
+ * const dispose = onFollowerDeleted(status => {
8639
+ * // ...
8640
+ * })
8641
+ * ```
8642
+ *
8643
+ * Fired when a follower has been deleted
8644
+ *
8645
+ * @param callback The function to call when the event was fired
8646
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
8647
+ *
8648
+ * @category Follow Events
8649
+ */
8650
+ const onFollowerDeleted = (callback) => createFollowEventSubscriber('follow.followerDeleted', callback);
8651
+
8652
+ const onLocalUserFollowed = (callback) => createLocalFollowEventSubscriber('local.follow.created', callback);
8653
+
8654
+ const onLocalFollowerRequested = (callback) => createLocalFollowEventSubscriber('local.follow.requested', callback);
8655
+
8656
+ const onLocalUserUnfollowed = (callback) => createLocalFollowEventSubscriber('local.follow.unfollowed', callback);
8657
+
8658
+ // Each event file directly, not the events barrel: the barrel's onFollowInfoUpdated imports
8659
+ /**
8660
+ * Keeps `getAllFollowings()` current for the whole session: every follow change — from
8661
+ * this device (local echo) or another (MQTT) — goes to `FollowingSyncEngine.onFollowChanged`,
8662
+ * which ignores follows of other users and applies the rest by status: a follow adds the
8663
+ * user as accepted, a request as pending, an accepted request turns accepted, and an
8664
+ * unfollow, a canceled or declined request, a removed follower or a block takes the user out.
8665
+ * `blockUser` also calls the engine itself: its local event swaps `from` and `to`.
8666
+ * `user.didBlock` is read here rather than through `onUserDidBlock`, which passes on only
8667
+ * the payload's first follow: every follow in it goes to the engine, as on Android and iOS,
8668
+ * so the signed-in user's block is applied wherever it sits in the payload.
8669
+ * The MQTT events arrive on the followers and followings topics of the BLOCK
8670
+ * auto-subscription (on by default).
8671
+ *
8672
+ * Registered via `setupLoginSubscriptions`; the returned unsubscriber is torn
8673
+ * down on logout.
8674
+ */
8675
+ var followRealtimeOnLoginHandler = () => {
8676
+ const engine = FollowingSyncEngine$1.getInstance();
8677
+ const apply = (follow) => engine.onFollowChanged(follow);
8678
+ const disposers = [
8679
+ onUserFollowed(apply),
8680
+ onFollowerRequested(apply),
8681
+ onFollowRequestAccepted(apply),
8682
+ onUserUnfollowed(apply),
8683
+ onFollowRequestCanceled(apply),
8684
+ onFollowRequestDeclined(apply),
8685
+ onFollowerDeleted(apply),
8686
+ 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); }),
8687
+ onLocalUserFollowed(apply),
8688
+ onLocalFollowerRequested(apply),
8689
+ onLocalUserUnfollowed(apply),
8690
+ ];
8691
+ return () => disposers.forEach(dispose => dispose());
8692
+ };
8693
+
8346
8694
  class CursorController {
8347
8695
  constructor(networkId, userId) {
8348
8696
  this.networkId = networkId;
@@ -8991,7 +9339,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
8991
9339
  // NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
8992
9340
  // the channel because currently backend can't handle this, so every time a user is banned from
8993
9341
  // a channel or the channel is deleted the channel's unread count will not be reset to zero
8994
- onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler(), userFlagByMeOnLoginHandler());
9342
+ onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), followingSyncEngineOnLoginHandler(), followRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler(), userFlagByMeOnLoginHandler());
8995
9343
  if (client.useLegacyUnreadCount) {
8996
9344
  subscriptions.push(readReceiptSyncEngineOnLoginHandler());
8997
9345
  }
@@ -11388,6 +11736,14 @@ const blockUser = async (userId) => {
11388
11736
  };
11389
11737
  const payload = prepareFollowStatusPayload(blockedUnfollowStatus);
11390
11738
  fireEvent('local.follow.unfollowed', payload);
11739
+ // the local event above swaps from and to, so getAllFollowings() cannot see this block in it
11740
+ if (client.userId) {
11741
+ FollowingSyncEngine$1.getInstance().onFollowChanged({
11742
+ from: client.userId,
11743
+ to: userId,
11744
+ status: 'blocked',
11745
+ });
11746
+ }
11391
11747
  return data;
11392
11748
  };
11393
11749
  /* end_public_function */
@@ -11452,6 +11808,8 @@ const follow = async (userId) => {
11452
11808
  ingestInCache(data, { cachedAt });
11453
11809
  }
11454
11810
  const payload = prepareFollowStatusPayload(data);
11811
+ // at once: the local event below is delivered on a later tick
11812
+ FollowingSyncEngine$1.getInstance().onFollowChanged(data.follows[0]);
11455
11813
  if (data.follows[0].status === 'accepted') {
11456
11814
  fireEvent('local.follow.created', payload);
11457
11815
  }
@@ -11490,6 +11848,8 @@ const unfollow = async (userId) => {
11490
11848
  ingestInCache(data);
11491
11849
  }
11492
11850
  const payload = prepareFollowStatusPayload(data);
11851
+ // at once: the local event below is delivered on a later tick
11852
+ FollowingSyncEngine$1.getInstance().onFollowChanged(data.follows[0]);
11493
11853
  fireEvent('local.follow.unfollowed', payload);
11494
11854
  return true;
11495
11855
  };
@@ -11555,153 +11915,50 @@ const declineMyFollower = async (userId) => {
11555
11915
  };
11556
11916
  /* end_public_function */
11557
11917
 
11558
- const createFollowEventSubscriber = (event, callback) => {
11559
- const client = getActiveClient();
11560
- const filter = (data) => {
11561
- const payload = prepareFollowersPayload(data);
11562
- if (!client.cache) {
11563
- callback(payload.follows[0]);
11564
- }
11565
- else {
11566
- ingestInCache(payload);
11567
- callback(payload.follows[0]);
11568
- }
11569
- };
11570
- return createEventSubscriber(client, event, event, filter);
11571
- };
11572
- const createLocalFollowEventSubscriber = (event, callback) => {
11573
- const client = getActiveClient();
11574
- const filter = (data) => {
11575
- const payload = prepareFollowStatusPayload(data);
11576
- if (!client.cache) {
11577
- callback(payload.follows[0]);
11578
- }
11579
- else {
11580
- ingestInCache(payload);
11581
- callback(payload.follows[0]);
11582
- }
11583
- };
11584
- return createEventSubscriber(client, event, event, filter);
11585
- };
11586
-
11587
- /**
11588
- * ```js
11589
- * import { onUserFollowed } from '@amityco/ts-sdk-react-native'
11590
- * const dispose = onUserFollowed(status => {
11591
- * // ...
11592
- * })
11593
- * ```
11594
- *
11595
- * Fired when a user follows another users and confirmation is not required
11596
- *
11597
- * @param callback The function to call when the event was fired
11598
- * @returns an {@link Amity.Unsubscriber} function to stop listening
11599
- *
11600
- * @category Follow Events
11601
- */
11602
- const onUserFollowed = (callback) => createFollowEventSubscriber('follow.created', callback);
11603
-
11604
- /**
11605
- * ```js
11606
- * import { onUserUnfollowed } from '@amityco/ts-sdk-react-native'
11607
- * const dispose = onUserFollowed(status => {
11608
- * // ...
11609
- * })
11610
- * ```
11611
- *
11612
- * Fired when a user unfollows
11613
- *
11614
- * @param callback The function to call when the event was fired
11615
- * @returns an {@link Amity.Unsubscriber} function to stop listening
11616
- *
11617
- * @category Follow Events
11618
- */
11619
- const onUserUnfollowed = (callback) => createFollowEventSubscriber('follow.unfollowed', callback);
11620
-
11621
- /**
11622
- * ```js
11623
- * import { onFollowerDeleted } from '@amityco/ts-sdk-react-native'
11624
- * const dispose = onFollowerDeleted(status => {
11625
- * // ...
11626
- * })
11627
- * ```
11628
- *
11629
- * Fired when a follower has been deleted
11630
- *
11631
- * @param callback The function to call when the event was fired
11632
- * @returns an {@link Amity.Unsubscriber} function to stop listening
11633
- *
11634
- * @category Follow Events
11635
- */
11636
- const onFollowerDeleted = (callback) => createFollowEventSubscriber('follow.followerDeleted', callback);
11637
-
11638
- /**
11639
- * ```js
11640
- * import { onFollowerRequested } from '@amityco/ts-sdk-react-native'
11641
- * const dispose = onFollowerRequested(status => {
11642
- * // ...
11643
- * })
11644
- * ```
11645
- *
11646
- * Fired when a user follows another users and confirmation is required
11647
- *
11648
- * @param callback The function to call when the event was fired
11649
- * @returns an {@link Amity.Unsubscriber} function to stop listening
11650
- *
11651
- * @category Follow Events
11652
- */
11653
- const onFollowerRequested = (callback) => createFollowEventSubscriber('follow.requested', callback);
11654
-
11918
+ /* begin_public_function
11919
+ id: user.relationship.get_all_followings
11920
+ */
11655
11921
  /**
11656
11922
  * ```js
11657
- * import { onFollowRequestCanceled } from '@amityco/ts-sdk-react-native'
11658
- * const dispose = onFollowRequestCanceled(status => {
11659
- * // ...
11660
- * })
11661
- * ```
11662
- *
11663
- * Fired when a follow request has been canceled
11664
- *
11665
- * @param callback The function to call when the event was fired
11666
- * @returns an {@link Amity.Unsubscriber} function to stop listening
11923
+ * import { UserRepository } from '@amityco/ts-sdk'
11667
11924
  *
11668
- * @category Follow Events
11669
- */
11670
- const onFollowRequestCanceled = (callback) => createFollowEventSubscriber('follow.requestCanceled', callback);
11671
-
11672
- /**
11673
- * ```js
11674
- * import { onFollowRequestAccepted } from '@amityco/ts-sdk-react-native'
11675
- * const dispose = onFollowRequestAccepted(status => {
11676
- * // ...
11677
- * })
11925
+ * const followings = await UserRepository.Relationship.getAllFollowings()
11926
+ * const statusOf = new Map(followings.map(f => [f.userId, f.status]))
11927
+ * // 'accepted' → no button; 'pending' → Pending; missing → Follow
11678
11928
  * ```
11679
11929
  *
11680
- * Fired when a follow request has been accepted
11681
- *
11682
- * @param callback The function to call when the event was fired
11683
- * @returns an {@link Amity.Unsubscriber} function to stop listening
11930
+ * Returns whom the signed-in user follows as a one-shot list of at most 5,000 (the most a
11931
+ * user can follow), from one request with no paging: each followed user's id and the
11932
+ * follow's status — `accepted`, or `pending` for a request not yet accepted. A user
11933
+ * missing from the list is not followed. The list holds ids and statuses only, no user
11934
+ * profiles.
11684
11935
  *
11685
- * @category Follow Events
11686
- */
11687
- const onFollowRequestAccepted = (callback) => createFollowEventSubscriber('follow.accepted', callback);
11688
-
11689
- /**
11690
- * ```js
11691
- * import { onFollowRequestDeclined } from '@amityco/ts-sdk-react-native'
11692
- * const dispose = onFollowRequestDeclined(status => {
11693
- * // ...
11694
- * })
11695
- * ```
11936
+ * Use it to show the follow button next to each author in the post feed: match each
11937
+ * author by user id against `userId`.
11696
11938
  *
11697
- * Fired when a follow request has been declined
11939
+ * Keeping the app current: the function answers once, so call it again to see changes —
11940
+ * for example when more posts load or when the feed comes back into view. The answer is
11941
+ * kept on the device for 5 minutes, so a call within that window costs no request. Changes
11942
+ * made in this app show at once. Changes made elsewhere — on another device, or by the
11943
+ * other user accepting a request or removing the user as a follower — show once their
11944
+ * real-time event arrives; the SDK receives these on the followers and followings topics
11945
+ * of `AmityAutoSubscription.BLOCK`, on by default. An event missed while offline, or with
11946
+ * that subscription turned off, shows at the next fetch, after the 5 minutes.
11698
11947
  *
11699
- * @param callback The function to call when the event was fired
11700
- * @returns an {@link Amity.Unsubscriber} function to stop listening
11948
+ * @returns A promise that resolves to the signed-in user's {@link Amity.FollowingUserStatus} list
11701
11949
  *
11702
- * @category Follow Events
11950
+ * @category Follow API
11951
+ * @async
11703
11952
  */
11704
- const onFollowRequestDeclined = (callback) => createFollowEventSubscriber('follow.requestDeclined', callback);
11953
+ const getAllFollowings = async () => {
11954
+ const client = getActiveClient();
11955
+ client.log('follow/getAllFollowings');
11956
+ const engine = FollowingSyncEngine$1.getInstance();
11957
+ // Fetch only when the 5-minute window has expired (no-op otherwise)
11958
+ await engine.ensureFetched();
11959
+ return engine.getFollowings();
11960
+ };
11961
+ /* end_public_function */
11705
11962
 
11706
11963
  /**
11707
11964
  * ```js
@@ -11807,12 +12064,6 @@ const onFollowInfoUpdated = (callback) => {
11807
12064
  };
11808
12065
  };
11809
12066
 
11810
- const onLocalUserFollowed = (callback) => createLocalFollowEventSubscriber('local.follow.created', callback);
11811
-
11812
- const onLocalUserUnfollowed = (callback) => createLocalFollowEventSubscriber('local.follow.unfollowed', callback);
11813
-
11814
- const onLocalFollowerRequested = (callback) => createLocalFollowEventSubscriber('local.follow.requested', callback);
11815
-
11816
12067
  const onLocalFollowRequestAccepted = (callback) => createLocalFollowEventSubscriber('local.follow.accepted', callback);
11817
12068
 
11818
12069
  const onLocalFollowRequestDeclined = (callback) => createLocalFollowEventSubscriber('local.follow.requestDeclined', callback);
@@ -12534,6 +12785,7 @@ var index$s = /*#__PURE__*/Object.freeze({
12534
12785
  unfollow: unfollow,
12535
12786
  acceptMyFollower: acceptMyFollower,
12536
12787
  declineMyFollower: declineMyFollower,
12788
+ getAllFollowings: getAllFollowings,
12537
12789
  onUserFollowed: onUserFollowed,
12538
12790
  onUserUnfollowed: onUserUnfollowed,
12539
12791
  onFollowerDeleted: onFollowerDeleted,
@@ -14279,7 +14531,7 @@ const getWatchSessionStorage = () => {
14279
14531
  return storageInstance;
14280
14532
  };
14281
14533
 
14282
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
14534
+ const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
14283
14535
  /*
14284
14536
  * The crypto algorithm used for importing key and signing string
14285
14537
  */
@@ -30619,6 +30871,189 @@ const getForYouFeed = (callback) => {
30619
30871
  };
30620
30872
  /* end_public_function */
30621
30873
 
30874
+ class FollowingFeedQueryStreamController extends QueryStreamController {
30875
+ constructor(query, cacheKey, notifyChange, preparePayload) {
30876
+ super(query, cacheKey);
30877
+ this.notifyChange = notifyChange;
30878
+ this.preparePayload = preparePayload;
30879
+ }
30880
+ async saveToMainDB(response) {
30881
+ const processedPayload = await this.preparePayload(response);
30882
+ const client = getActiveClient();
30883
+ const cachedAt = client.cache && Date.now();
30884
+ if (client.cache) {
30885
+ ingestInCache(processedPayload, { cachedAt });
30886
+ }
30887
+ }
30888
+ appendToQueryStream(response, direction, refresh = false) {
30889
+ var _a, _b;
30890
+ if (refresh) {
30891
+ pushToCache(this.cacheKey, {
30892
+ data: response.posts.map(getResolver('post')),
30893
+ });
30894
+ }
30895
+ else {
30896
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30897
+ const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
30898
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
30899
+ }
30900
+ }
30901
+ /**
30902
+ * The SDK does not know the viewer's follow list or the network's `social.globalFeed`
30903
+ * switches, so it cannot tell whether a new post belongs in this feed. A created or
30904
+ * approved post, by anyone (the current user included), never changes the list: it
30905
+ * appears on the next first-page load. Deleted and declined posts are removed; any
30906
+ * other event re-emits so listed posts render their new state.
30907
+ */
30908
+ reactor(action) {
30909
+ return (post) => {
30910
+ var _a;
30911
+ if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
30912
+ return;
30913
+ }
30914
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30915
+ if (!collection)
30916
+ return;
30917
+ // A child post event never adds or removes an entry; it re-emits only when its parent is listed
30918
+ if (post.parentPostId) {
30919
+ if (!collection.data.includes(post.parentPostId))
30920
+ return;
30921
+ }
30922
+ else if (action === EnumPostActions.OnPostDeleted ||
30923
+ action === EnumPostActions.OnPostDeclined) {
30924
+ collection.data = collection.data.filter(postId => postId !== post.postId);
30925
+ }
30926
+ pushToCache(this.cacheKey, collection);
30927
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
30928
+ };
30929
+ }
30930
+ subscribeRTE(createSubscriber) {
30931
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
30932
+ }
30933
+ }
30934
+
30935
+ /**
30936
+ * `GET /api/v1/me/following-feeds` reads `limit` and `token` as flat query params.
30937
+ * Unlike the global feed, they must not be nested in `options`: the endpoint forwards
30938
+ * only `{ limit, token }`, so a nested token would be dropped and every page would be page one.
30939
+ */
30940
+ class FollowingFeedPaginationController extends PaginationController {
30941
+ async getRequest(queryParams, token) {
30942
+ const { limit = COLLECTION_DEFAULT_PAGINATION_SIZE, sortBy } = queryParams;
30943
+ const params = token ? { token } : { limit };
30944
+ if (sortBy)
30945
+ params.sortBy = sortBy;
30946
+ const { data: queryResponse } = await this.http.get(API_ENDPOINTS.followingFeed, { params });
30947
+ return queryResponse;
30948
+ }
30949
+ }
30950
+
30951
+ class FollowingFeedLiveCollectionController extends LiveCollectionController {
30952
+ constructor(query, callback) {
30953
+ const queryStreamId = hash(query);
30954
+ const cacheKey = ['followingFeed', 'collection', queryStreamId];
30955
+ const paginationController = new FollowingFeedPaginationController(query);
30956
+ super(paginationController, queryStreamId, cacheKey, callback);
30957
+ this.query = query;
30958
+ this.queryStreamController = new FollowingFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
30959
+ this.callback = callback.bind(this);
30960
+ this.loadPage({ initial: true });
30961
+ }
30962
+ setup() {
30963
+ var _a;
30964
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30965
+ if (!collection) {
30966
+ pushToCache(this.cacheKey, {
30967
+ data: [],
30968
+ params: {},
30969
+ });
30970
+ }
30971
+ }
30972
+ async persistModel(queryPayload) {
30973
+ await this.queryStreamController.saveToMainDB(queryPayload);
30974
+ }
30975
+ persistQueryStream({ response, direction, refresh, }) {
30976
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
30977
+ }
30978
+ startSubscription() {
30979
+ return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
30980
+ }
30981
+ notifyChange({ origin, loading, error }) {
30982
+ var _a, _b;
30983
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30984
+ if (!collection)
30985
+ return;
30986
+ const data = ((_b = collection.data
30987
+ .map(id => pullFromCache(['post', 'get', id]))
30988
+ .filter(isNonNullable)
30989
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
30990
+ if (!this.shouldNotify(data) && origin === 'event')
30991
+ return;
30992
+ this.callback({
30993
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
30994
+ data,
30995
+ hasNextPage: !!this.paginationController.getNextToken(),
30996
+ loading,
30997
+ error,
30998
+ });
30999
+ }
31000
+ }
31001
+
31002
+ /* begin_public_function
31003
+ id: feed.query.following_feed
31004
+ api_style: live_collection
31005
+ */
31006
+ /**
31007
+ * ```js
31008
+ * import { FeedRepository, FollowingFeedSortByEnum } from '@amityco/ts-sdk'
31009
+ *
31010
+ * const unsub = FeedRepository.getFollowingFeed(
31011
+ * { sortBy: FollowingFeedSortByEnum.LastCreated, limit: 20 },
31012
+ * ({ data: posts, hasNextPage, onNextPage, loading, error }) => processResponse(posts),
31013
+ * )
31014
+ * ```
31015
+ *
31016
+ * Observe all mutations on a list of {@link Amity.Post} for the current user's following feed.
31017
+ * Which posts match is decided by the server, from the network's `social.globalFeed` setting:
31018
+ * - `lastCreated`: posts by the users the current user follows, plus the current user's own
31019
+ * posts, newest first.
31020
+ * - `customRanking` (the default): server-ranked posts by the current user, the users they
31021
+ * follow and the communities they joined.
31022
+ *
31023
+ * A new post, the current user's own included, is not added in real time: it appears
31024
+ * when the feed is next loaded from the first page (for example, a new subscription).
31025
+ * With `customRanking` the server may take up to 5 minutes to include it.
31026
+ * Deleted and declined posts are removed at once.
31027
+ *
31028
+ * When the network enforces module entitlement and the `feed` module is not entitled,
31029
+ * the request fails with `400325` (`ModuleNotEntitled`), reported through `error`.
31030
+ *
31031
+ * @param params.sortBy order of the feed. When omitted, the server default (`customRanking`) applies
31032
+ * @param params.limit page size of the first request (1 - 100)
31033
+ * @param callback the function to call when new data are available
31034
+ * @param config
31035
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the posts
31036
+ *
31037
+ * @category Posts Live Collection
31038
+ */
31039
+ const getFollowingFeed = (params, callback, config) => {
31040
+ const { log, cache } = getActiveClient();
31041
+ if (!cache) {
31042
+ console.log(ENABLE_CACHE_MESSAGE);
31043
+ }
31044
+ const timestamp = Date.now();
31045
+ log(`getFollowingFeed(tmpid: ${timestamp}) > listen`);
31046
+ const liveCollection = new FollowingFeedLiveCollectionController(params, callback);
31047
+ const disposers = liveCollection.startSubscription();
31048
+ const cacheKey = liveCollection.getCacheKey();
31049
+ disposers.push(() => dropFromCache(cacheKey));
31050
+ return () => {
31051
+ log(`getFollowingFeed(tmpid: ${timestamp}) > dispose`);
31052
+ disposers.forEach(fn => fn());
31053
+ };
31054
+ };
31055
+ /* end_public_function */
31056
+
30622
31057
  var index$e = /*#__PURE__*/Object.freeze({
30623
31058
  __proto__: null,
30624
31059
  queryGlobalFeed: queryGlobalFeed,
@@ -30627,6 +31062,7 @@ var index$e = /*#__PURE__*/Object.freeze({
30627
31062
  getUserFeed: getUserFeed,
30628
31063
  getCommunityFeed: getCommunityFeed,
30629
31064
  getForYouFeed: getForYouFeed,
31065
+ getFollowingFeed: getFollowingFeed,
30630
31066
  AmityForYouFeedDisabledError: AmityForYouFeedDisabledError
30631
31067
  });
30632
31068
 
@@ -38537,4 +38973,4 @@ const getContentFlagReasons = () => Object.values(ContentFlagReasonEnum);
38537
38973
  const getContentFlagReasonKey = (reason) => CONTENT_FLAG_REASON_KEYS[reason];
38538
38974
  /* end_public_function */
38539
38975
 
38540
- export { API_REGIONS, index$6 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, ContentFlagReasonEnum as AmityContentFlagReasonType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmityLiveViewerCountMode, AmityModuleNotEntitledError, AmitySharableContentType, AnalyticsSourceTypeEnum, index$g as CategoryRepository, index$k as ChannelRepository, index$t as Client, index$f as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$h as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, index as CuratedContentRepository, DefaultCommunityPostSetting, index$2 as EventRepository, FeedDataTypeEnum, index$e as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$q as FileRepository, FileType, GET_WATCHER_URLS, index$4 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$3 as LiveReactionRepository, index$8 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$o as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$9 as PollRepository, PostContentType, index$c as PostRepository, PostStructureType, index$1 as ProductRepository, index$p as ReactionRepository, index$a as RoomPresenceRepository, index$d as RoomRepository, SearchUsersByEnum, index$7 as StoryRepository, index$b as StreamRepository, index$n as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserProfileFieldEnum, UserReportTypeEnum, UserReportTypeFilterEnum, index$r as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getContentFlagReasonKey, getContentFlagReasons, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$5 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, resolveModuleAvailability, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastMessage, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };
38976
+ export { API_REGIONS, index$6 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, ContentFlagReasonEnum as AmityContentFlagReasonType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmityLiveViewerCountMode, AmityModuleNotEntitledError, AmitySharableContentType, AnalyticsSourceTypeEnum, index$g as CategoryRepository, index$k as ChannelRepository, index$t as Client, index$f as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$h as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, index as CuratedContentRepository, DefaultCommunityPostSetting, index$2 as EventRepository, FeedDataTypeEnum, index$e as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$q as FileRepository, FileType, FollowingFeedSortByEnum, GET_WATCHER_URLS, index$4 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$3 as LiveReactionRepository, index$8 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$o as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$9 as PollRepository, PostContentType, index$c as PostRepository, PostStructureType, index$1 as ProductRepository, index$p as ReactionRepository, index$a as RoomPresenceRepository, index$d as RoomRepository, SearchUsersByEnum, index$7 as StoryRepository, index$b as StreamRepository, index$n as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserProfileFieldEnum, UserReportTypeEnum, UserReportTypeFilterEnum, index$r as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getContentFlagReasonKey, getContentFlagReasons, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$5 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, resolveModuleAvailability, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastMessage, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };