@amityco/ts-sdk-react-native 6.32.7-289cad7.0 → 6.32.7-686c44c.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 (96) hide show
  1. package/dist/@types/core/events.d.ts +16 -2
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/payload.d.ts +3 -0
  4. package/dist/@types/core/payload.d.ts.map +1 -1
  5. package/dist/@types/domains/message.d.ts +1 -0
  6. package/dist/@types/domains/message.d.ts.map +1 -1
  7. package/dist/@types/domains/pinnedPost.d.ts +1 -0
  8. package/dist/@types/domains/pinnedPost.d.ts.map +1 -1
  9. package/dist/@types/domains/reaction.d.ts +8 -2
  10. package/dist/@types/domains/reaction.d.ts.map +1 -1
  11. package/dist/@types/domains/user.d.ts +4 -0
  12. package/dist/@types/domains/user.d.ts.map +1 -1
  13. package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
  14. package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
  15. package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  16. package/dist/index.cjs.js +919 -570
  17. package/dist/index.esm.js +919 -570
  18. package/dist/index.umd.js +3 -3
  19. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts +13 -0
  20. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts.map +1 -0
  21. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostPaginationController.d.ts +13 -0
  22. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostPaginationController.d.ts.map +1 -0
  23. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.d.ts +15 -0
  24. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.d.ts.map +1 -0
  25. package/dist/postRepository/observers/getGlobalPinnedPosts.d.ts +10 -0
  26. package/dist/postRepository/observers/getGlobalPinnedPosts.d.ts.map +1 -0
  27. package/dist/postRepository/observers/index.d.ts +1 -0
  28. package/dist/postRepository/observers/index.d.ts.map +1 -1
  29. package/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
  30. package/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
  31. package/dist/reactionRepository/events/onReactorAddedLocal.d.ts +19 -0
  32. package/dist/reactionRepository/events/onReactorAddedLocal.d.ts.map +1 -0
  33. package/dist/reactionRepository/events/onReactorRemovedLocal.d.ts +19 -0
  34. package/dist/reactionRepository/events/onReactorRemovedLocal.d.ts.map +1 -0
  35. package/dist/reactionRepository/observers/getReactions/ReactionLiveCollectionController.d.ts +13 -0
  36. package/dist/reactionRepository/observers/getReactions/ReactionLiveCollectionController.d.ts.map +1 -0
  37. package/dist/reactionRepository/observers/getReactions/ReactionPaginationController.d.ts +5 -0
  38. package/dist/reactionRepository/observers/getReactions/ReactionPaginationController.d.ts.map +1 -0
  39. package/dist/reactionRepository/observers/getReactions/ReactionQueryStreamController.d.ts +14 -0
  40. package/dist/reactionRepository/observers/getReactions/ReactionQueryStreamController.d.ts.map +1 -0
  41. package/dist/reactionRepository/observers/{getReactions.d.ts → getReactions/getReactions.d.ts} +1 -1
  42. package/dist/reactionRepository/observers/getReactions/getReactions.d.ts.map +1 -0
  43. package/dist/reactionRepository/observers/getReactions/index.d.ts +2 -0
  44. package/dist/reactionRepository/observers/getReactions/index.d.ts.map +1 -0
  45. package/dist/reactionRepository/observers/index.d.ts +1 -1
  46. package/dist/reactionRepository/observers/index.d.ts.map +1 -1
  47. package/dist/storyRepository/observers/getGlobalStoryTargets/GlobalStoryLiveCollectionController.d.ts.map +1 -1
  48. package/dist/storyRepository/observers/getGlobalStoryTargets/GlobalStoryQueryStreamController.d.ts +1 -1
  49. package/dist/storyRepository/observers/getGlobalStoryTargets/GlobalStoryQueryStreamController.d.ts.map +1 -1
  50. package/dist/userRepository/constants/index.d.ts +5 -0
  51. package/dist/userRepository/constants/index.d.ts.map +1 -0
  52. package/dist/userRepository/index.d.ts +1 -0
  53. package/dist/userRepository/index.d.ts.map +1 -1
  54. package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts.map +1 -1
  55. package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts +3 -2
  56. package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts.map +1 -1
  57. package/dist/utils/linkedObject/messageLinkedObject.d.ts.map +1 -1
  58. package/package.json +1 -1
  59. package/src/@types/core/events.ts +18 -6
  60. package/src/@types/core/payload.ts +4 -0
  61. package/src/@types/domains/message.ts +1 -0
  62. package/src/@types/domains/pin.ts +1 -1
  63. package/src/@types/domains/pinnedPost.ts +2 -0
  64. package/src/@types/domains/reaction.ts +9 -3
  65. package/src/@types/domains/user.ts +6 -0
  66. package/src/communityRepository/communityMembership/events/utils.ts +4 -2
  67. package/src/communityRepository/utils/communityWithMembership.ts +15 -8
  68. package/src/feedRepository/api/queryGlobalFeed.ts +4 -1
  69. package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.ts +96 -0
  70. package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostPaginationController.ts +19 -0
  71. package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.ts +88 -0
  72. package/src/postRepository/observers/getGlobalPinnedPosts.ts +42 -0
  73. package/src/postRepository/observers/index.ts +1 -0
  74. package/src/reactionRepository/api/addReaction.ts +23 -1
  75. package/src/reactionRepository/api/removeReaction.ts +25 -2
  76. package/src/reactionRepository/events/onReactorAddedLocal.ts +95 -0
  77. package/src/reactionRepository/events/onReactorRemovedLocal.ts +94 -0
  78. package/src/reactionRepository/observers/getReactions/ReactionLiveCollectionController.ts +111 -0
  79. package/src/reactionRepository/observers/getReactions/ReactionPaginationController.ts +30 -0
  80. package/src/reactionRepository/observers/getReactions/ReactionQueryStreamController.ts +92 -0
  81. package/src/reactionRepository/observers/getReactions/getReactions.ts +57 -0
  82. package/src/reactionRepository/observers/getReactions/index.ts +1 -0
  83. package/src/reactionRepository/observers/index.ts +1 -1
  84. package/src/storyRepository/events/onStoryReactionAdded.ts +3 -3
  85. package/src/storyRepository/events/onStoryReactionRemoved.ts +3 -3
  86. package/src/storyRepository/observers/getGlobalStoryTargets/GlobalStoryLiveCollectionController.ts +5 -0
  87. package/src/storyRepository/observers/getGlobalStoryTargets/GlobalStoryQueryStreamController.ts +5 -2
  88. package/src/userRepository/constants/index.ts +4 -0
  89. package/src/userRepository/index.ts +1 -0
  90. package/src/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.ts +12 -1
  91. package/src/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.ts +13 -5
  92. package/src/userRepository/relationship/follow/observers/getFollowers/FollowerLiveCollectionController.ts +1 -1
  93. package/src/userRepository/relationship/follow/observers/getFollowings/FollowingLiveCollectionController.ts +1 -1
  94. package/src/utils/linkedObject/messageLinkedObject.ts +4 -0
  95. package/dist/reactionRepository/observers/getReactions.d.ts.map +0 -1
  96. package/src/reactionRepository/observers/getReactions.ts +0 -146
package/dist/index.esm.js CHANGED
@@ -21968,6 +21968,10 @@ const messageLinkedObject = (message) => {
21968
21968
  },
21969
21969
  get deliveredCount() {
21970
21970
  return getMessageReadCount(message).deliveredCount;
21971
+ },
21972
+ get creator() {
21973
+ var _a;
21974
+ return (_a = pullFromCache(['user', 'get', message.creatorId])) === null || _a === void 0 ? void 0 : _a.data;
21971
21975
  }, markRead: () => markReadMessage(message) });
21972
21976
  };
21973
21977
 
@@ -26321,6 +26325,18 @@ class QueryStreamController {
26321
26325
  }
26322
26326
  }
26323
26327
 
26328
+ var EnumFollowActions;
26329
+ (function (EnumFollowActions) {
26330
+ EnumFollowActions["OnRequested"] = "onRequested";
26331
+ EnumFollowActions["OnAccepted"] = "onAccepted";
26332
+ EnumFollowActions["OnDeclined"] = "onDeclined";
26333
+ EnumFollowActions["OnCanceled"] = "onCanceled";
26334
+ EnumFollowActions["OnFollowed"] = "onFollowed";
26335
+ EnumFollowActions["OnUnfollowed"] = "onUnfollowed";
26336
+ EnumFollowActions["OnDeleted"] = "onDeleted";
26337
+ EnumFollowActions["OnUserDeleted"] = "onUserDeleted";
26338
+ })(EnumFollowActions || (EnumFollowActions = {}));
26339
+
26324
26340
  class BlockedUserQueryStreamController extends QueryStreamController {
26325
26341
  constructor(query, cacheKey, notifyChange, preparePayload) {
26326
26342
  super(query, cacheKey);
@@ -26349,10 +26365,13 @@ class BlockedUserQueryStreamController extends QueryStreamController {
26349
26365
  }
26350
26366
  }
26351
26367
  reactor(action) {
26352
- return (followStatus) => {
26368
+ return (targetUser) => {
26353
26369
  var _a;
26354
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26355
- pushToCache(this.cacheKey, collection);
26370
+ if (action === EnumFollowActions.OnFollowed) {
26371
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26372
+ const updatedCollection = collection === null || collection === void 0 ? void 0 : collection.data.filter(id => id !== targetUser.userId);
26373
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: updatedCollection }));
26374
+ }
26356
26375
  this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
26357
26376
  };
26358
26377
  }
@@ -26549,560 +26568,593 @@ var EnumUserActions;
26549
26568
  EnumUserActions["OnUserFlagCleared"] = "onUserFlagCleared";
26550
26569
  })(EnumUserActions || (EnumUserActions = {}));
26551
26570
 
26552
- class BlockedUserLiveCollectionController extends LiveCollectionController {
26553
- constructor(query, callback) {
26554
- const queryStreamId = hash(query);
26555
- const cacheKey = ['blockedUsers', 'collection', queryStreamId];
26556
- const paginationController = new BlockedUserPaginationController(query);
26557
- super(paginationController, queryStreamId, cacheKey, callback);
26558
- this.query = query;
26559
- this.queryStreamController = new BlockedUserQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareBlockedUserPayload);
26560
- this.callback = callback.bind(this);
26561
- this.loadPage({ initial: true });
26562
- }
26563
- setup() {
26564
- var _a;
26565
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26566
- if (!collection) {
26567
- pushToCache(this.cacheKey, {
26568
- data: [],
26569
- params: {},
26570
- });
26571
+ const createFollowEventSubscriber = (event, callback) => {
26572
+ const client = getActiveClient();
26573
+ const filter = (data) => {
26574
+ const payload = prepareFollowersPayload(data);
26575
+ if (!client.cache) {
26576
+ callback(payload.follows[0]);
26571
26577
  }
26572
- }
26573
- async persistModel(queryPayload) {
26574
- await this.queryStreamController.saveToMainDB(queryPayload);
26575
- }
26576
- persistQueryStream({ response, direction, refresh, }) {
26577
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
26578
- }
26579
- startSubscription() {
26580
- return this.queryStreamController.subscribeRTE([
26581
- {
26582
- fn: onUserDeleted$2,
26583
- action: EnumUserActions.OnUserDeleted,
26584
- },
26585
- ]);
26586
- }
26587
- notifyChange({ origin, loading, error }) {
26588
- var _a, _b;
26589
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26590
- if (!collection)
26591
- return;
26592
- const data = this.applyFilter((_b = collection.data
26593
- .map(id => pullFromCache(['user', 'get', id]))
26594
- .filter(isNonNullable)
26595
- .map(({ data }) => data)
26596
- .map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
26597
- if (!this.shouldNotify(data) && origin === 'event')
26598
- return;
26599
- this.callback({
26600
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
26601
- data,
26602
- hasNextPage: !!this.paginationController.getNextToken(),
26603
- loading,
26604
- error,
26605
- });
26606
- }
26607
- // eslint-disable-next-line class-methods-use-this
26608
- applyFilter(data) {
26609
- let users = data;
26610
- users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
26611
- return users;
26612
- }
26613
- }
26578
+ else {
26579
+ ingestInCache(payload);
26580
+ callback(payload.follows[0]);
26581
+ }
26582
+ };
26583
+ return createEventSubscriber(client, event, event, filter);
26584
+ };
26585
+ const createLocalFollowEventSubscriber = (event, callback) => {
26586
+ const client = getActiveClient();
26587
+ const filter = (data) => {
26588
+ const payload = prepareFollowStatusPayload(data);
26589
+ if (!client.cache) {
26590
+ callback(payload.follows[0]);
26591
+ }
26592
+ else {
26593
+ ingestInCache(payload);
26594
+ callback(payload.follows[0]);
26595
+ }
26596
+ };
26597
+ return createEventSubscriber(client, event, event, filter);
26598
+ };
26614
26599
 
26615
- /* begin_public_function
26616
- id: user.get_blocked_users
26617
- */
26618
26600
  /**
26619
26601
  * ```js
26620
- * import { UserRepository } from '@amityco/ts-sdk-react-native'
26621
- * const unblockedUser = await UserRepository.blockUser('userId')
26602
+ * import { onUserFollowed } from '@amityco/ts-sdk-react-native'
26603
+ * const dispose = onUserFollowed(status => {
26604
+ * // ...
26605
+ * })
26622
26606
  * ```
26623
26607
  *
26624
- * Blocks a {@link Amity.InternalUser}
26608
+ * Fired when a user follows another users and confirmation is not required
26625
26609
  *
26626
- * @param params The params to get blocked {@link Amity.InternalUser}s
26627
- * @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
26628
- * @returns {@link Amity.Unsubscriber} to unsubscribe from collection
26610
+ * @param callback The function to call when the event was fired
26611
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
26629
26612
  *
26630
- * @category Post API
26631
- * @async
26613
+ * @category Follow Events
26632
26614
  */
26633
- const getBlockedUsers$1 = (params, callback, config) => {
26634
- const { log, cache } = getActiveClient();
26635
- if (!cache) {
26636
- console.log(ENABLE_CACHE_MESSAGE);
26637
- }
26638
- const timestamp = Date.now();
26639
- log(`getBlockedUsers(tmpid: ${timestamp}) > listen`);
26640
- const blockedUserLiveCollection = new BlockedUserLiveCollectionController(params, callback);
26641
- const disposers = blockedUserLiveCollection.startSubscription();
26642
- const cacheKey = blockedUserLiveCollection.getCacheKey();
26643
- disposers.push(() => dropFromCache(cacheKey));
26644
- return () => {
26645
- log(`getBlockedUsers(tmpid: ${timestamp}) > dispose`);
26646
- disposers.forEach(fn => fn());
26647
- dropFromCache(cacheKey);
26648
- };
26649
- };
26650
- /* end_public_function */
26651
-
26652
- /* eslint-disable no-use-before-define */
26653
- const getBlockedUsers = (params, callback, config) => {
26654
- console.log('Deprecation Notice: UserRepository.Relationship.getBlockedUsers will be deprecated on 9th June 2023, please use UserRepository.getBlockedUsers instead.');
26655
- return getBlockedUsers$1(params, callback);
26656
- };
26615
+ const onUserFollowed = (callback) => createFollowEventSubscriber('follow.created', callback);
26657
26616
 
26658
- /* begin_public_function
26659
- id: user.relationship.follow
26660
- */
26661
26617
  /**
26662
26618
  * ```js
26663
- * import { follow } from '@amityco/ts-sdk-react-native'
26664
- * const status = await follow('foobar')
26619
+ * import { onUserUnfollowed } from '@amityco/ts-sdk-react-native'
26620
+ * const dispose = onUserFollowed(status => {
26621
+ * // ...
26622
+ * })
26665
26623
  * ```
26666
26624
  *
26667
- * Follow the user
26625
+ * Fired when a user unfollows
26668
26626
  *
26669
- * @param userId the ID of the {@link Amity.InternalUser}
26670
- * @returns the status {@link Amity.FollowStatus}
26627
+ * @param callback The function to call when the event was fired
26628
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
26671
26629
  *
26672
- * @category Follow API
26673
- * @async
26630
+ * @category Follow Events
26674
26631
  */
26675
- const follow = async (userId) => {
26676
- const client = getActiveClient();
26677
- client.log('follow/follow', userId);
26678
- const { data } = await client.http.post(`/api/v4/me/following/${userId}`);
26679
- const cachedAt = client.cache && Date.now();
26680
- if (client.cache) {
26681
- ingestInCache(data, { cachedAt });
26682
- }
26683
- const payload = prepareFollowStatusPayload(data);
26684
- if (data.follows[0].status === 'accepted') {
26685
- fireEvent('local.follow.created', payload);
26686
- }
26687
- else {
26688
- fireEvent('local.follow.requested', payload);
26689
- }
26690
- return {
26691
- data: data.follows[0],
26692
- cachedAt,
26693
- };
26694
- };
26695
- /* end_public_function */
26632
+ const onUserUnfollowed = (callback) => createFollowEventSubscriber('follow.unfollowed', callback);
26696
26633
 
26697
- /* begin_public_function
26698
- id: user.relationship.unfollow
26699
- */
26700
26634
  /**
26701
26635
  * ```js
26702
- * import { unfollow } from '@amityco/ts-sdk-react-native'
26703
- * await unfollow('foobar')
26636
+ * import { onFollowerDeleted } from '@amityco/ts-sdk-react-native'
26637
+ * const dispose = onFollowerDeleted(status => {
26638
+ * // ...
26639
+ * })
26704
26640
  * ```
26705
26641
  *
26706
- * Cancel the follow request or unfollow the user
26642
+ * Fired when a follower has been deleted
26707
26643
  *
26708
- * @param userId the ID of the {@link Amity.InternalUser}
26709
- * @returns A success boolean if the user {@link Amity.InternalUser} was unfollowed
26644
+ * @param callback The function to call when the event was fired
26645
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
26710
26646
  *
26711
- * @category Follow API
26712
- * @async
26647
+ * @category Follow Events
26713
26648
  */
26714
- const unfollow = async (userId) => {
26715
- const client = getActiveClient();
26716
- client.log('follow/unfollow', userId);
26717
- const { data } = await client.http.delete(`/api/v4/me/following/${userId}`);
26718
- if (client.cache) {
26719
- ingestInCache(data);
26720
- }
26721
- const payload = prepareFollowStatusPayload(data);
26722
- fireEvent('local.follow.unfollowed', payload);
26723
- return true;
26724
- };
26725
- /* end_public_function */
26649
+ const onFollowerDeleted = (callback) => createFollowEventSubscriber('follow.followerDeleted', callback);
26726
26650
 
26727
26651
  /**
26728
- * @deprecated This API renamed to `acceptMyFollower`.
26729
- * Please use acceptMyFollower() instead.
26730
- *
26731
26652
  * ```js
26732
- * import { acceptFollower } from '@amityco/ts-sdk-react-native'
26733
- * await acceptFollower('foobar')
26653
+ * import { onFollowerRequested } from '@amityco/ts-sdk-react-native'
26654
+ * const dispose = onFollowerRequested(status => {
26655
+ * // ...
26656
+ * })
26734
26657
  * ```
26735
26658
  *
26736
- * Accept the follow request
26659
+ * Fired when a user follows another users and confirmation is required
26737
26660
  *
26738
- * @param userId the ID of the {@link Amity.InternalUser} follower
26739
- * @returns A success boolean if the follow request was accepted
26661
+ * @param callback The function to call when the event was fired
26662
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
26740
26663
  *
26741
- * @category Follow API
26742
- * @async
26664
+ * @category Follow Events
26743
26665
  */
26744
- const acceptFollower = async (userId) => {
26745
- const client = getActiveClient();
26746
- client.log('follow/acceptFollower', userId);
26747
- const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
26748
- if (client.cache) {
26749
- ingestInCache(data);
26750
- }
26751
- const payload = prepareFollowStatusPayload(data);
26752
- fireEvent('local.follow.accepted', payload);
26753
- return true;
26754
- };
26666
+ const onFollowerRequested = (callback) => createFollowEventSubscriber('follow.requested', callback);
26755
26667
 
26756
- /* begin_public_function
26757
- id: user.relationship.accept_follow
26758
- */
26759
26668
  /**
26760
26669
  * ```js
26761
- * import { UserRepository } from '@amityco/ts-sdk-react-native'
26762
- * await UserRepository.Relationship.acceptMyFollower('foobar')
26670
+ * import { onFollowRequestCanceled } from '@amityco/ts-sdk-react-native'
26671
+ * const dispose = onFollowRequestCanceled(status => {
26672
+ * // ...
26673
+ * })
26763
26674
  * ```
26764
26675
  *
26765
- * Accept the follow request
26676
+ * Fired when a follow request has been canceled
26766
26677
  *
26767
- * @param userId the ID of the {@link Amity.InternalUser} follower
26768
- * @returns A success boolean if the follow request was accepted
26678
+ * @param callback The function to call when the event was fired
26679
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
26769
26680
  *
26770
- * @category Follow API
26771
- * @async
26681
+ * @category Follow Events
26772
26682
  */
26773
- const acceptMyFollower = async (userId) => {
26774
- const client = getActiveClient();
26775
- client.log('follow/acceptMyFollower', userId);
26776
- const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
26777
- if (client.cache) {
26778
- ingestInCache(data);
26779
- }
26780
- const payload = prepareFollowStatusPayload(data);
26781
- fireEvent('local.follow.accepted', payload);
26782
- return true;
26783
- };
26784
- /* end_public_function */
26683
+ const onFollowRequestCanceled = (callback) => createFollowEventSubscriber('follow.requestCanceled', callback);
26785
26684
 
26786
26685
  /**
26787
- * @deprecated This API renamed to `declineMyFollower`.
26788
- * Please use declineMyFollower() instead.
26686
+ * ```js
26687
+ * import { onFollowRequestAccepted } from '@amityco/ts-sdk-react-native'
26688
+ * const dispose = onFollowRequestAccepted(status => {
26689
+ * // ...
26690
+ * })
26691
+ * ```
26692
+ *
26693
+ * Fired when a follow request has been accepted
26694
+ *
26695
+ * @param callback The function to call when the event was fired
26696
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
26789
26697
  *
26698
+ * @category Follow Events
26699
+ */
26700
+ const onFollowRequestAccepted = (callback) => createFollowEventSubscriber('follow.accepted', callback);
26701
+
26702
+ /**
26790
26703
  * ```js
26791
- * import { declineFollower } from '@amityco/ts-sdk-react-native'
26792
- * await declineFollower('foobar')
26704
+ * import { onFollowRequestDeclined } from '@amityco/ts-sdk-react-native'
26705
+ * const dispose = onFollowRequestDeclined(status => {
26706
+ * // ...
26707
+ * })
26793
26708
  * ```
26794
26709
  *
26795
- * Decline the follow request or delete the follower
26710
+ * Fired when a follow request has been declined
26796
26711
  *
26797
- * @param userId the ID of the {@link Amity.InternalUser} follower
26798
- * @returns A success boolean if the follow request was decline
26712
+ * @param callback The function to call when the event was fired
26713
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
26799
26714
  *
26800
- * @category Follow API
26801
- * @async
26715
+ * @category Follow Events
26802
26716
  */
26803
- const declineFollower = async (userId) => {
26804
- const client = getActiveClient();
26805
- client.log('follow/declineFollower', userId);
26806
- const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
26807
- if (client.cache) {
26808
- ingestInCache(data);
26809
- }
26810
- const payload = prepareFollowStatusPayload(data);
26811
- fireEvent('local.follow.requestDeclined', payload);
26812
- return true;
26813
- };
26717
+ const onFollowRequestDeclined = (callback) => createFollowEventSubscriber('follow.requestDeclined', callback);
26814
26718
 
26815
- /* begin_public_function
26816
- id: user.relationship.decline_follow
26817
- */
26818
26719
  /**
26819
26720
  * ```js
26820
- * import { UserRepository } from '@amityco/ts-sdk-react-native'
26821
- * await UserRepository.Relationship.declineMyFollower('foobar')
26721
+ * import { getFollowInfo } from '@amityco/ts-sdk-react-native'
26722
+ * const { data: followInfo } = await getFollowInfo('foobar')
26822
26723
  * ```
26823
26724
  *
26824
- * Decline the follow request or delete the follower
26725
+ * Fetches the number of followers, followings, pending requests and the follow status for current user
26825
26726
  *
26826
- * @param userId the ID of the {@link Amity.InternalUser} follower
26827
- * @returns A success boolean if the follow request was decline
26727
+ * @param userId the ID of the {@link Amity.InternalUser}
26728
+ * @returns the associated {@link Amity.FollowInfo} object
26828
26729
  *
26829
26730
  * @category Follow API
26830
26731
  * @async
26831
26732
  */
26832
- const declineMyFollower = async (userId) => {
26733
+ const getFollowInfo$1 = async (userId) => {
26734
+ var _a, _b;
26833
26735
  const client = getActiveClient();
26834
- client.log('follow/declineMyFollower', userId);
26835
- const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
26736
+ client.log('follow/getFollowInfo', userId);
26737
+ const { data } = await client.http.get(client.userId === userId ? `/api/v4/me/followInfo` : `/api/v5/users/${userId}/followInfo`);
26738
+ const cachedAt = client.cache && Date.now();
26739
+ const followInfo = 'follows' in data
26740
+ ? Object.assign(Object.assign({}, data.followCounts[0]), { status: (_b = (_a = data.follows) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.status }) : data.followCounts[0];
26836
26741
  if (client.cache) {
26837
- ingestInCache(data);
26742
+ pushToCache(['followInfo', 'get', userId], followInfo, {
26743
+ cachedAt,
26744
+ });
26838
26745
  }
26839
- const payload = prepareFollowStatusPayload(data);
26840
- fireEvent('local.follow.requestDeclined', payload);
26841
- return true;
26842
- };
26843
- /* end_public_function */
26844
-
26845
- const createFollowEventSubscriber = (event, callback) => {
26846
- const client = getActiveClient();
26847
- const filter = (data) => {
26848
- const payload = prepareFollowersPayload(data);
26849
- if (!client.cache) {
26850
- callback(payload.follows[0]);
26851
- }
26852
- else {
26853
- ingestInCache(payload);
26854
- callback(payload.follows[0]);
26855
- }
26746
+ return {
26747
+ data: followInfo,
26748
+ cachedAt,
26856
26749
  };
26857
- return createEventSubscriber(client, event, event, filter);
26858
26750
  };
26859
- const createLocalFollowEventSubscriber = (event, callback) => {
26860
- const client = getActiveClient();
26861
- const filter = (data) => {
26862
- const payload = prepareFollowStatusPayload(data);
26863
- if (!client.cache) {
26864
- callback(payload.follows[0]);
26865
- }
26866
- else {
26867
- ingestInCache(payload);
26868
- callback(payload.follows[0]);
26869
- }
26870
- };
26871
- return createEventSubscriber(client, event, event, filter);
26872
- };
26873
-
26874
26751
  /**
26875
26752
  * ```js
26876
- * import { onUserFollowed } from '@amityco/ts-sdk-react-native'
26877
- * const dispose = onUserFollowed(status => {
26878
- * // ...
26879
- * })
26753
+ * import { getFollowInfo } from '@amityco/ts-sdk-react-native'
26754
+ * const { data: followInfo } = getFollowInfo.locally('foobar')
26880
26755
  * ```
26881
26756
  *
26882
- * Fired when a user follows another users and confirmation is not required
26757
+ * Fetches the number of followers, followings, pending requests and the follow status for current user from cache
26883
26758
  *
26884
- * @param callback The function to call when the event was fired
26885
- * @returns an {@link Amity.Unsubscriber} function to stop listening
26759
+ * @param userId the ID of the {@link Amity.InternalUser}
26760
+ * @returns the associated {@link Amity.FollowInfo} object
26886
26761
  *
26887
- * @category Follow Events
26762
+ * @category Follow API
26888
26763
  */
26889
- const onUserFollowed = (callback) => createFollowEventSubscriber('follow.created', callback);
26764
+ getFollowInfo$1.locally = (userId) => {
26765
+ const client = getActiveClient();
26766
+ client.log('follow/getFollowInfo.locally', userId);
26767
+ if (!client.cache) {
26768
+ return;
26769
+ }
26770
+ const cached = pullFromCache(['followInfo', 'get', userId]);
26771
+ if (!cached) {
26772
+ return;
26773
+ }
26774
+ return {
26775
+ data: cached.data,
26776
+ cachedAt: cached.cachedAt,
26777
+ };
26778
+ };
26890
26779
 
26891
26780
  /**
26892
26781
  * ```js
26893
- * import { onUserUnfollowed } from '@amityco/ts-sdk-react-native'
26894
- * const dispose = onUserFollowed(status => {
26782
+ * import { onFollowInfoUpdated } from '@amityco/ts-sdk-react-native'
26783
+ * const dispose = onFollowInfoUpdated(followInfo => {
26895
26784
  * // ...
26896
26785
  * })
26897
26786
  * ```
26898
26787
  *
26899
- * Fired when a user unfollows
26788
+ * Fired when a {@link Amity.FollowInfo} has been updated
26900
26789
  *
26901
26790
  * @param callback The function to call when the event was fired
26902
26791
  * @returns an {@link Amity.Unsubscriber} function to stop listening
26903
26792
  *
26904
26793
  * @category Follow Events
26905
26794
  */
26906
- const onUserUnfollowed = (callback) => createFollowEventSubscriber('follow.unfollowed', callback);
26795
+ const onFollowInfoUpdated = (callback) => {
26796
+ const handler = async (payload) => {
26797
+ const [{ data: followInfoFrom }, { data: followInfoTo }] = await Promise.all([
26798
+ getFollowInfo$1(payload.from),
26799
+ getFollowInfo$1(payload.to),
26800
+ ]);
26801
+ callback(followInfoFrom);
26802
+ callback(followInfoTo);
26803
+ };
26804
+ const disposers = [
26805
+ createFollowEventSubscriber('follow.created', handler),
26806
+ createFollowEventSubscriber('follow.requested', handler),
26807
+ createFollowEventSubscriber('follow.accepted', handler),
26808
+ createFollowEventSubscriber('follow.unfollowed', handler),
26809
+ createFollowEventSubscriber('follow.requestCanceled', handler),
26810
+ createFollowEventSubscriber('follow.requestDeclined', handler),
26811
+ createFollowEventSubscriber('follow.followerDeleted', handler),
26812
+ createLocalFollowEventSubscriber('local.follow.created', handler),
26813
+ createLocalFollowEventSubscriber('local.follow.requested', handler),
26814
+ createLocalFollowEventSubscriber('local.follow.accepted', handler),
26815
+ createLocalFollowEventSubscriber('local.follow.unfollowed', handler),
26816
+ createLocalFollowEventSubscriber('local.follow.requestDeclined', handler),
26817
+ ];
26818
+ return () => {
26819
+ disposers.forEach(fn => fn());
26820
+ };
26821
+ };
26907
26822
 
26908
- /**
26909
- * ```js
26910
- * import { onFollowerDeleted } from '@amityco/ts-sdk-react-native'
26911
- * const dispose = onFollowerDeleted(status => {
26912
- * // ...
26913
- * })
26914
- * ```
26915
- *
26916
- * Fired when a follower has been deleted
26917
- *
26918
- * @param callback The function to call when the event was fired
26919
- * @returns an {@link Amity.Unsubscriber} function to stop listening
26920
- *
26921
- * @category Follow Events
26922
- */
26923
- const onFollowerDeleted = (callback) => createFollowEventSubscriber('follow.followerDeleted', callback);
26823
+ const onLocalUserFollowed = (callback) => createLocalFollowEventSubscriber('local.follow.created', callback);
26824
+
26825
+ const onLocalUserUnfollowed = (callback) => createLocalFollowEventSubscriber('local.follow.unfollowed', callback);
26826
+
26827
+ const onLocalFollowerRequested = (callback) => createLocalFollowEventSubscriber('local.follow.requested', callback);
26828
+
26829
+ const onLocalFollowRequestAccepted = (callback) => createLocalFollowEventSubscriber('local.follow.accepted', callback);
26924
26830
 
26831
+ const onLocalFollowRequestDeclined = (callback) => createLocalFollowEventSubscriber('local.follow.requestDeclined', callback);
26832
+
26833
+ const convertEventPayload = (eventHandler, sourceModelProp, destinationDomain) => (callback) => eventHandler(sourceModel => {
26834
+ var _a, _b;
26835
+ if (!sourceModel) {
26836
+ return sourceModel;
26837
+ }
26838
+ const client = getActiveClient();
26839
+ const { objectSyncMap } = client;
26840
+ /*
26841
+ * NOTE: For objects created locally (optimistic creation), the SDK stores them with their local ID as the cache key, which is used throughout the entire SDK session (in-memory) for syncing updates.
26842
+ * If the payload or response only contains the remote ID of the same object, the SDK will look up the corresponding local ID to retrieve the object.
26843
+ */
26844
+ const resolvedId = isLocalId(sourceModel[sourceModelProp])
26845
+ ? sourceModel[sourceModelProp]
26846
+ : (_a = objectSyncMap.get(sourceModel[sourceModelProp])) !== null && _a !== void 0 ? _a : sourceModel[sourceModelProp];
26847
+ const model = (_b = pullFromCache([
26848
+ destinationDomain,
26849
+ 'get',
26850
+ `${resolvedId}`,
26851
+ ])) === null || _b === void 0 ? void 0 : _b.data;
26852
+ if (!model)
26853
+ return;
26854
+ return callback(model);
26855
+ });
26856
+
26857
+ class BlockedUserLiveCollectionController extends LiveCollectionController {
26858
+ constructor(query, callback) {
26859
+ const queryStreamId = hash(query);
26860
+ const cacheKey = ['blockedUsers', 'collection', queryStreamId];
26861
+ const paginationController = new BlockedUserPaginationController(query);
26862
+ super(paginationController, queryStreamId, cacheKey, callback);
26863
+ this.query = query;
26864
+ this.queryStreamController = new BlockedUserQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareBlockedUserPayload);
26865
+ this.callback = callback.bind(this);
26866
+ this.loadPage({ initial: true });
26867
+ }
26868
+ setup() {
26869
+ var _a;
26870
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26871
+ if (!collection) {
26872
+ pushToCache(this.cacheKey, {
26873
+ data: [],
26874
+ params: {},
26875
+ });
26876
+ }
26877
+ }
26878
+ async persistModel(queryPayload) {
26879
+ await this.queryStreamController.saveToMainDB(queryPayload);
26880
+ }
26881
+ persistQueryStream({ response, direction, refresh, }) {
26882
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
26883
+ }
26884
+ startSubscription() {
26885
+ return this.queryStreamController.subscribeRTE([
26886
+ {
26887
+ fn: onUserDeleted$2,
26888
+ action: EnumUserActions.OnUserDeleted,
26889
+ },
26890
+ // In the case of unblocking a user, we need to subscribe to the follow events
26891
+ {
26892
+ fn: convertEventPayload(onLocalUserFollowed, 'to', 'user'),
26893
+ action: EnumFollowActions.OnFollowed,
26894
+ },
26895
+ {
26896
+ fn: convertEventPayload(onUserFollowed, 'to', 'user'),
26897
+ action: EnumFollowActions.OnFollowed,
26898
+ },
26899
+ ]);
26900
+ }
26901
+ notifyChange({ origin, loading, error }) {
26902
+ var _a, _b;
26903
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26904
+ if (!collection)
26905
+ return;
26906
+ const data = this.applyFilter((_b = collection.data
26907
+ .map(id => pullFromCache(['user', 'get', id]))
26908
+ .filter(isNonNullable)
26909
+ .map(({ data }) => data)
26910
+ .map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
26911
+ if (!this.shouldNotify(data) && origin === 'event')
26912
+ return;
26913
+ this.callback({
26914
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
26915
+ data,
26916
+ hasNextPage: !!this.paginationController.getNextToken(),
26917
+ loading,
26918
+ error,
26919
+ });
26920
+ }
26921
+ // eslint-disable-next-line class-methods-use-this
26922
+ applyFilter(data) {
26923
+ let users = data;
26924
+ users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
26925
+ return users;
26926
+ }
26927
+ }
26928
+
26929
+ /* begin_public_function
26930
+ id: user.get_blocked_users
26931
+ */
26925
26932
  /**
26926
26933
  * ```js
26927
- * import { onFollowerRequested } from '@amityco/ts-sdk-react-native'
26928
- * const dispose = onFollowerRequested(status => {
26929
- * // ...
26930
- * })
26934
+ * import { UserRepository } from '@amityco/ts-sdk-react-native'
26935
+ * const unblockedUser = await UserRepository.blockUser('userId')
26931
26936
  * ```
26932
26937
  *
26933
- * Fired when a user follows another users and confirmation is required
26938
+ * Blocks a {@link Amity.InternalUser}
26934
26939
  *
26935
- * @param callback The function to call when the event was fired
26936
- * @returns an {@link Amity.Unsubscriber} function to stop listening
26940
+ * @param params The params to get blocked {@link Amity.InternalUser}s
26941
+ * @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
26942
+ * @returns {@link Amity.Unsubscriber} to unsubscribe from collection
26937
26943
  *
26938
- * @category Follow Events
26944
+ * @category Post API
26945
+ * @async
26939
26946
  */
26940
- const onFollowerRequested = (callback) => createFollowEventSubscriber('follow.requested', callback);
26947
+ const getBlockedUsers$1 = (params, callback, config) => {
26948
+ const { log, cache } = getActiveClient();
26949
+ if (!cache) {
26950
+ console.log(ENABLE_CACHE_MESSAGE);
26951
+ }
26952
+ const timestamp = Date.now();
26953
+ log(`getBlockedUsers(tmpid: ${timestamp}) > listen`);
26954
+ const blockedUserLiveCollection = new BlockedUserLiveCollectionController(params, callback);
26955
+ const disposers = blockedUserLiveCollection.startSubscription();
26956
+ const cacheKey = blockedUserLiveCollection.getCacheKey();
26957
+ disposers.push(() => dropFromCache(cacheKey));
26958
+ return () => {
26959
+ log(`getBlockedUsers(tmpid: ${timestamp}) > dispose`);
26960
+ disposers.forEach(fn => fn());
26961
+ dropFromCache(cacheKey);
26962
+ };
26963
+ };
26964
+ /* end_public_function */
26965
+
26966
+ /* eslint-disable no-use-before-define */
26967
+ const getBlockedUsers = (params, callback, config) => {
26968
+ console.log('Deprecation Notice: UserRepository.Relationship.getBlockedUsers will be deprecated on 9th June 2023, please use UserRepository.getBlockedUsers instead.');
26969
+ return getBlockedUsers$1(params, callback);
26970
+ };
26941
26971
 
26972
+ /* begin_public_function
26973
+ id: user.relationship.follow
26974
+ */
26942
26975
  /**
26943
26976
  * ```js
26944
- * import { onFollowRequestCanceled } from '@amityco/ts-sdk-react-native'
26945
- * const dispose = onFollowRequestCanceled(status => {
26946
- * // ...
26947
- * })
26977
+ * import { follow } from '@amityco/ts-sdk-react-native'
26978
+ * const status = await follow('foobar')
26948
26979
  * ```
26949
26980
  *
26950
- * Fired when a follow request has been canceled
26981
+ * Follow the user
26951
26982
  *
26952
- * @param callback The function to call when the event was fired
26953
- * @returns an {@link Amity.Unsubscriber} function to stop listening
26983
+ * @param userId the ID of the {@link Amity.InternalUser}
26984
+ * @returns the status {@link Amity.FollowStatus}
26954
26985
  *
26955
- * @category Follow Events
26986
+ * @category Follow API
26987
+ * @async
26956
26988
  */
26957
- const onFollowRequestCanceled = (callback) => createFollowEventSubscriber('follow.requestCanceled', callback);
26989
+ const follow = async (userId) => {
26990
+ const client = getActiveClient();
26991
+ client.log('follow/follow', userId);
26992
+ const { data } = await client.http.post(`/api/v4/me/following/${userId}`);
26993
+ const cachedAt = client.cache && Date.now();
26994
+ if (client.cache) {
26995
+ ingestInCache(data, { cachedAt });
26996
+ }
26997
+ const payload = prepareFollowStatusPayload(data);
26998
+ if (data.follows[0].status === 'accepted') {
26999
+ fireEvent('local.follow.created', payload);
27000
+ }
27001
+ else {
27002
+ fireEvent('local.follow.requested', payload);
27003
+ }
27004
+ return {
27005
+ data: data.follows[0],
27006
+ cachedAt,
27007
+ };
27008
+ };
27009
+ /* end_public_function */
26958
27010
 
27011
+ /* begin_public_function
27012
+ id: user.relationship.unfollow
27013
+ */
26959
27014
  /**
26960
27015
  * ```js
26961
- * import { onFollowRequestAccepted } from '@amityco/ts-sdk-react-native'
26962
- * const dispose = onFollowRequestAccepted(status => {
26963
- * // ...
26964
- * })
27016
+ * import { unfollow } from '@amityco/ts-sdk-react-native'
27017
+ * await unfollow('foobar')
26965
27018
  * ```
26966
27019
  *
26967
- * Fired when a follow request has been accepted
27020
+ * Cancel the follow request or unfollow the user
26968
27021
  *
26969
- * @param callback The function to call when the event was fired
26970
- * @returns an {@link Amity.Unsubscriber} function to stop listening
27022
+ * @param userId the ID of the {@link Amity.InternalUser}
27023
+ * @returns A success boolean if the user {@link Amity.InternalUser} was unfollowed
26971
27024
  *
26972
- * @category Follow Events
27025
+ * @category Follow API
27026
+ * @async
26973
27027
  */
26974
- const onFollowRequestAccepted = (callback) => createFollowEventSubscriber('follow.accepted', callback);
27028
+ const unfollow = async (userId) => {
27029
+ const client = getActiveClient();
27030
+ client.log('follow/unfollow', userId);
27031
+ const { data } = await client.http.delete(`/api/v4/me/following/${userId}`);
27032
+ if (client.cache) {
27033
+ ingestInCache(data);
27034
+ }
27035
+ const payload = prepareFollowStatusPayload(data);
27036
+ fireEvent('local.follow.unfollowed', payload);
27037
+ return true;
27038
+ };
27039
+ /* end_public_function */
26975
27040
 
26976
27041
  /**
27042
+ * @deprecated This API renamed to `acceptMyFollower`.
27043
+ * Please use acceptMyFollower() instead.
27044
+ *
26977
27045
  * ```js
26978
- * import { onFollowRequestDeclined } from '@amityco/ts-sdk-react-native'
26979
- * const dispose = onFollowRequestDeclined(status => {
26980
- * // ...
26981
- * })
27046
+ * import { acceptFollower } from '@amityco/ts-sdk-react-native'
27047
+ * await acceptFollower('foobar')
26982
27048
  * ```
26983
27049
  *
26984
- * Fired when a follow request has been declined
27050
+ * Accept the follow request
26985
27051
  *
26986
- * @param callback The function to call when the event was fired
26987
- * @returns an {@link Amity.Unsubscriber} function to stop listening
27052
+ * @param userId the ID of the {@link Amity.InternalUser} follower
27053
+ * @returns A success boolean if the follow request was accepted
26988
27054
  *
26989
- * @category Follow Events
27055
+ * @category Follow API
27056
+ * @async
26990
27057
  */
26991
- const onFollowRequestDeclined = (callback) => createFollowEventSubscriber('follow.requestDeclined', callback);
27058
+ const acceptFollower = async (userId) => {
27059
+ const client = getActiveClient();
27060
+ client.log('follow/acceptFollower', userId);
27061
+ const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
27062
+ if (client.cache) {
27063
+ ingestInCache(data);
27064
+ }
27065
+ const payload = prepareFollowStatusPayload(data);
27066
+ fireEvent('local.follow.accepted', payload);
27067
+ return true;
27068
+ };
26992
27069
 
27070
+ /* begin_public_function
27071
+ id: user.relationship.accept_follow
27072
+ */
26993
27073
  /**
26994
27074
  * ```js
26995
- * import { getFollowInfo } from '@amityco/ts-sdk-react-native'
26996
- * const { data: followInfo } = await getFollowInfo('foobar')
27075
+ * import { UserRepository } from '@amityco/ts-sdk-react-native'
27076
+ * await UserRepository.Relationship.acceptMyFollower('foobar')
26997
27077
  * ```
26998
27078
  *
26999
- * Fetches the number of followers, followings, pending requests and the follow status for current user
27079
+ * Accept the follow request
27000
27080
  *
27001
- * @param userId the ID of the {@link Amity.InternalUser}
27002
- * @returns the associated {@link Amity.FollowInfo} object
27081
+ * @param userId the ID of the {@link Amity.InternalUser} follower
27082
+ * @returns A success boolean if the follow request was accepted
27003
27083
  *
27004
27084
  * @category Follow API
27005
27085
  * @async
27006
27086
  */
27007
- const getFollowInfo$1 = async (userId) => {
27008
- var _a, _b;
27087
+ const acceptMyFollower = async (userId) => {
27009
27088
  const client = getActiveClient();
27010
- client.log('follow/getFollowInfo', userId);
27011
- const { data } = await client.http.get(client.userId === userId ? `/api/v4/me/followInfo` : `/api/v5/users/${userId}/followInfo`);
27012
- const cachedAt = client.cache && Date.now();
27013
- const followInfo = 'follows' in data
27014
- ? Object.assign(Object.assign({}, data.followCounts[0]), { status: (_b = (_a = data.follows) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.status }) : data.followCounts[0];
27089
+ client.log('follow/acceptMyFollower', userId);
27090
+ const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
27015
27091
  if (client.cache) {
27016
- pushToCache(['followInfo', 'get', userId], followInfo, {
27017
- cachedAt,
27018
- });
27092
+ ingestInCache(data);
27019
27093
  }
27020
- return {
27021
- data: followInfo,
27022
- cachedAt,
27023
- };
27094
+ const payload = prepareFollowStatusPayload(data);
27095
+ fireEvent('local.follow.accepted', payload);
27096
+ return true;
27024
27097
  };
27098
+ /* end_public_function */
27099
+
27025
27100
  /**
27101
+ * @deprecated This API renamed to `declineMyFollower`.
27102
+ * Please use declineMyFollower() instead.
27103
+ *
27026
27104
  * ```js
27027
- * import { getFollowInfo } from '@amityco/ts-sdk-react-native'
27028
- * const { data: followInfo } = getFollowInfo.locally('foobar')
27105
+ * import { declineFollower } from '@amityco/ts-sdk-react-native'
27106
+ * await declineFollower('foobar')
27029
27107
  * ```
27030
27108
  *
27031
- * Fetches the number of followers, followings, pending requests and the follow status for current user from cache
27109
+ * Decline the follow request or delete the follower
27032
27110
  *
27033
- * @param userId the ID of the {@link Amity.InternalUser}
27034
- * @returns the associated {@link Amity.FollowInfo} object
27111
+ * @param userId the ID of the {@link Amity.InternalUser} follower
27112
+ * @returns A success boolean if the follow request was decline
27035
27113
  *
27036
27114
  * @category Follow API
27115
+ * @async
27037
27116
  */
27038
- getFollowInfo$1.locally = (userId) => {
27117
+ const declineFollower = async (userId) => {
27039
27118
  const client = getActiveClient();
27040
- client.log('follow/getFollowInfo.locally', userId);
27041
- if (!client.cache) {
27042
- return;
27043
- }
27044
- const cached = pullFromCache(['followInfo', 'get', userId]);
27045
- if (!cached) {
27046
- return;
27119
+ client.log('follow/declineFollower', userId);
27120
+ const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
27121
+ if (client.cache) {
27122
+ ingestInCache(data);
27047
27123
  }
27048
- return {
27049
- data: cached.data,
27050
- cachedAt: cached.cachedAt,
27051
- };
27124
+ const payload = prepareFollowStatusPayload(data);
27125
+ fireEvent('local.follow.requestDeclined', payload);
27126
+ return true;
27052
27127
  };
27053
27128
 
27129
+ /* begin_public_function
27130
+ id: user.relationship.decline_follow
27131
+ */
27054
27132
  /**
27055
27133
  * ```js
27056
- * import { onFollowInfoUpdated } from '@amityco/ts-sdk-react-native'
27057
- * const dispose = onFollowInfoUpdated(followInfo => {
27058
- * // ...
27059
- * })
27134
+ * import { UserRepository } from '@amityco/ts-sdk-react-native'
27135
+ * await UserRepository.Relationship.declineMyFollower('foobar')
27060
27136
  * ```
27061
27137
  *
27062
- * Fired when a {@link Amity.FollowInfo} has been updated
27138
+ * Decline the follow request or delete the follower
27063
27139
  *
27064
- * @param callback The function to call when the event was fired
27065
- * @returns an {@link Amity.Unsubscriber} function to stop listening
27140
+ * @param userId the ID of the {@link Amity.InternalUser} follower
27141
+ * @returns A success boolean if the follow request was decline
27066
27142
  *
27067
- * @category Follow Events
27143
+ * @category Follow API
27144
+ * @async
27068
27145
  */
27069
- const onFollowInfoUpdated = (callback) => {
27070
- const handler = async (payload) => {
27071
- const [{ data: followInfoFrom }, { data: followInfoTo }] = await Promise.all([
27072
- getFollowInfo$1(payload.from),
27073
- getFollowInfo$1(payload.to),
27074
- ]);
27075
- callback(followInfoFrom);
27076
- callback(followInfoTo);
27077
- };
27078
- const disposers = [
27079
- createFollowEventSubscriber('follow.created', handler),
27080
- createFollowEventSubscriber('follow.requested', handler),
27081
- createFollowEventSubscriber('follow.accepted', handler),
27082
- createFollowEventSubscriber('follow.unfollowed', handler),
27083
- createFollowEventSubscriber('follow.requestCanceled', handler),
27084
- createFollowEventSubscriber('follow.requestDeclined', handler),
27085
- createFollowEventSubscriber('follow.followerDeleted', handler),
27086
- createLocalFollowEventSubscriber('local.follow.created', handler),
27087
- createLocalFollowEventSubscriber('local.follow.requested', handler),
27088
- createLocalFollowEventSubscriber('local.follow.accepted', handler),
27089
- createLocalFollowEventSubscriber('local.follow.unfollowed', handler),
27090
- createLocalFollowEventSubscriber('local.follow.requestDeclined', handler),
27091
- ];
27092
- return () => {
27093
- disposers.forEach(fn => fn());
27094
- };
27095
- };
27096
-
27097
- const onLocalUserFollowed = (callback) => createLocalFollowEventSubscriber('local.follow.created', callback);
27098
-
27099
- const onLocalUserUnfollowed = (callback) => createLocalFollowEventSubscriber('local.follow.unfollowed', callback);
27100
-
27101
- const onLocalFollowerRequested = (callback) => createLocalFollowEventSubscriber('local.follow.requested', callback);
27102
-
27103
- const onLocalFollowRequestAccepted = (callback) => createLocalFollowEventSubscriber('local.follow.accepted', callback);
27104
-
27105
- const onLocalFollowRequestDeclined = (callback) => createLocalFollowEventSubscriber('local.follow.requestDeclined', callback);
27146
+ const declineMyFollower = async (userId) => {
27147
+ const client = getActiveClient();
27148
+ client.log('follow/declineMyFollower', userId);
27149
+ const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
27150
+ if (client.cache) {
27151
+ ingestInCache(data);
27152
+ }
27153
+ const payload = prepareFollowStatusPayload(data);
27154
+ fireEvent('local.follow.requestDeclined', payload);
27155
+ return true;
27156
+ };
27157
+ /* end_public_function */
27106
27158
 
27107
27159
  /**
27108
27160
  * ```js
@@ -27232,18 +27284,6 @@ class FollowerPaginationController extends PaginationController {
27232
27284
  }
27233
27285
  }
27234
27286
 
27235
- var EnumFollowActions;
27236
- (function (EnumFollowActions) {
27237
- EnumFollowActions["OnRequested"] = "onRequested";
27238
- EnumFollowActions["OnAccepted"] = "onAccepted";
27239
- EnumFollowActions["OnDeclined"] = "onDeclined";
27240
- EnumFollowActions["OnCanceled"] = "onCanceled";
27241
- EnumFollowActions["OnFollowed"] = "onFollowed";
27242
- EnumFollowActions["OnUnfollowed"] = "onUnfollowed";
27243
- EnumFollowActions["OnDeleted"] = "onDeleted";
27244
- EnumFollowActions["OnUserDeleted"] = "onUserDeleted";
27245
- })(EnumFollowActions || (EnumFollowActions = {}));
27246
-
27247
27287
  class FollowerQueryStreamController extends QueryStreamController {
27248
27288
  constructor(query, cacheKey, notifyChange, preparePayload) {
27249
27289
  super(query, cacheKey);
@@ -27321,7 +27361,7 @@ const onFollowerUserDeleted = ({ userId }) => (callback) => {
27321
27361
 
27322
27362
  class FollowerLiveCollectionController extends LiveCollectionController {
27323
27363
  constructor(query, callback) {
27324
- const queryStreamId = hash(query);
27364
+ const queryStreamId = hash(Object.assign(Object.assign({}, query), { type: 'follower' }));
27325
27365
  const cacheKey = ['follow', 'collection', queryStreamId];
27326
27366
  const paginationController = new FollowerPaginationController(query);
27327
27367
  super(paginationController, queryStreamId, cacheKey, callback);
@@ -27526,7 +27566,7 @@ const onFollowingUserDeleted = ({ userId }) => (callback) => {
27526
27566
 
27527
27567
  class FollowingLiveCollectionController extends LiveCollectionController {
27528
27568
  constructor(query, callback) {
27529
- const queryStreamId = hash(query);
27569
+ const queryStreamId = hash(Object.assign(Object.assign({}, query), { type: 'following' }));
27530
27570
  const cacheKey = ['follow', 'collection', queryStreamId];
27531
27571
  const paginationController = new FollowingPaginationController(query);
27532
27572
  super(paginationController, queryStreamId, cacheKey, callback);
@@ -28616,6 +28656,12 @@ const getReachedUsers = (params, callback) => {
28616
28656
  };
28617
28657
  };
28618
28658
 
28659
+ var AmityUserSearchMatchType;
28660
+ (function (AmityUserSearchMatchType) {
28661
+ AmityUserSearchMatchType["DEFAULT"] = "default";
28662
+ AmityUserSearchMatchType["PARTIAL"] = "partial";
28663
+ })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
28664
+
28619
28665
  var index$j = /*#__PURE__*/Object.freeze({
28620
28666
  __proto__: null,
28621
28667
  Relationship: index$k,
@@ -28635,7 +28681,8 @@ var index$j = /*#__PURE__*/Object.freeze({
28635
28681
  getBlockedUsers: getBlockedUsers$1,
28636
28682
  searchUserByDisplayName: searchUserByDisplayName,
28637
28683
  getViewedUsers: getViewedUsers,
28638
- getReachedUsers: getReachedUsers
28684
+ getReachedUsers: getReachedUsers,
28685
+ get AmityUserSearchMatchType () { return AmityUserSearchMatchType; }
28639
28686
  });
28640
28687
 
28641
28688
  /* begin_public_function
@@ -29432,16 +29479,19 @@ function isCurrentUserPartOfCommunity(c, m) {
29432
29479
  }
29433
29480
  /*
29434
29481
  * For mqtt events server will not send user specific data as it's broadcasted
29435
- * to multiple users. Althought this can be calculated, it's not scalable. Hence
29436
- * the client SDK needs to calculate this info
29482
+ * to multiple users and it also does not include communityUser
29483
+ *
29484
+ * Client SDK needs to check for the existing isJoined field in cache data before calculating.
29485
+ * Althought this can be calculated, it's not scalable.
29437
29486
  */
29438
29487
  function updateMembershipStatus(communities, communityUsers) {
29439
29488
  return communities.map(c => {
29440
- if (c.isJoined == null) {
29441
- const isJoined = communityUsers.some(m => isCurrentUserPartOfCommunity(c, m) && isMember(m.communityMembership));
29442
- return Object.assign(Object.assign({}, c), { isJoined });
29489
+ const cachedCommunity = pullFromCache(['community', 'get', c.communityId]);
29490
+ if ((cachedCommunity === null || cachedCommunity === void 0 ? void 0 : cachedCommunity.data) && (cachedCommunity === null || cachedCommunity === void 0 ? void 0 : cachedCommunity.data.hasOwnProperty('isJoined'))) {
29491
+ return Object.assign(Object.assign({}, cachedCommunity.data), c);
29443
29492
  }
29444
- return c;
29493
+ const isJoined = communityUsers.some(m => isCurrentUserPartOfCommunity(c, m) && isMember(m.communityMembership));
29494
+ return Object.assign(Object.assign({}, c), { isJoined });
29445
29495
  });
29446
29496
  }
29447
29497
 
@@ -29542,7 +29592,7 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
29542
29592
  referenceType,
29543
29593
  reactionName,
29544
29594
  });
29545
- await client.http.post('/api/v2/reactions', {
29595
+ const { data } = await client.http.post('/api/v2/reactions', {
29546
29596
  referenceId,
29547
29597
  referenceType,
29548
29598
  reactionName,
@@ -29560,12 +29610,33 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
29560
29610
  if (referenceType === 'comment') {
29561
29611
  fireEvent('local.comment.addReaction', {
29562
29612
  comment: updatedModel,
29613
+ reactor: {
29614
+ userId: client.userId,
29615
+ reactionName,
29616
+ reactionId: data.addedId,
29617
+ },
29563
29618
  });
29564
29619
  return true;
29565
29620
  }
29566
29621
  if (referenceType === 'post') {
29567
29622
  fireEvent('local.post.addReaction', {
29568
29623
  post: updatedModel,
29624
+ reactor: {
29625
+ userId: client.userId,
29626
+ reactionName,
29627
+ reactionId: data.addedId,
29628
+ },
29629
+ });
29630
+ return true;
29631
+ }
29632
+ if (referenceType === 'story') {
29633
+ fireEvent('local.story.reactionAdded', {
29634
+ story: updatedModel,
29635
+ reactor: {
29636
+ userId: client.userId,
29637
+ reactionName,
29638
+ reactionId: data.addedId,
29639
+ },
29569
29640
  });
29570
29641
  return true;
29571
29642
  }
@@ -29640,7 +29711,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
29640
29711
  referenceType,
29641
29712
  reactionName,
29642
29713
  });
29643
- await client.http.delete(`/api/v2/reactions`, {
29714
+ const { data } = await client.http.delete(`/api/v2/reactions`, {
29644
29715
  data: {
29645
29716
  referenceId,
29646
29717
  referenceType,
@@ -29660,12 +29731,33 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
29660
29731
  if (referenceType === 'comment') {
29661
29732
  fireEvent('local.comment.removeReaction', {
29662
29733
  comment: updatedModel,
29734
+ reactor: {
29735
+ reactionId: data.removedId,
29736
+ reactionName,
29737
+ userId: client.userId,
29738
+ },
29663
29739
  });
29664
29740
  return true;
29665
29741
  }
29666
29742
  if (referenceType === 'post') {
29667
29743
  fireEvent('local.post.removeReaction', {
29668
29744
  post: updatedModel,
29745
+ reactor: {
29746
+ reactionId: data.removedId,
29747
+ reactionName,
29748
+ userId: client.userId,
29749
+ },
29750
+ });
29751
+ return true;
29752
+ }
29753
+ if (referenceType === 'story') {
29754
+ fireEvent('local.story.reactionAdded', {
29755
+ story: updatedModel,
29756
+ reactor: {
29757
+ userId: client.userId,
29758
+ reactionName,
29759
+ reactionId: data.removedId,
29760
+ },
29669
29761
  });
29670
29762
  return true;
29671
29763
  }
@@ -29689,7 +29781,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
29689
29781
  * @category Reaction API
29690
29782
  * */
29691
29783
  removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
29692
- var _a, _b, _c, _d, _e;
29784
+ var _a, _b, _c, _d;
29693
29785
  const client = getActiveClient();
29694
29786
  client.log('reaction/removeReaction.optimistically', {
29695
29787
  referenceId,
@@ -29710,7 +29802,7 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
29710
29802
  cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
29711
29803
  });
29712
29804
  dispatchReactable(referenceType, reaction);
29713
- return (_e = !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName))) !== null && _e !== void 0 ? _e : false;
29805
+ return !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName));
29714
29806
  };
29715
29807
 
29716
29808
  const getMatchPostSetting = (value) => {
@@ -30532,73 +30624,262 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
30532
30624
 
30533
30625
  const REFERENCE_API_V5 = 5;
30534
30626
 
30627
+ class ReactionPaginationController extends PaginationController {
30628
+ async getRequest(queryParams, token) {
30629
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
30630
+ const options = token ? { token } : { limit };
30631
+ const client = getActiveClient();
30632
+ client.log('reaction/queryReactions', queryParams);
30633
+ const path = '/api/v3/reactions';
30634
+ const { data: queryResponse } = await this.http.get(path, {
30635
+ params: Object.assign(Object.assign({}, params), { referenceVersion: REFERENCE_API_V5, // Need to put this param to make it can query reaction for message in sub-channel
30636
+ options }),
30637
+ });
30638
+ return queryResponse;
30639
+ }
30640
+ }
30641
+
30642
+ class ReactionQueryStreamController extends QueryStreamController {
30643
+ constructor(query, cacheKey, notifyChange, preparePayload) {
30644
+ super(query, cacheKey);
30645
+ this.notifyChange = notifyChange;
30646
+ this.preparePayload = preparePayload;
30647
+ }
30648
+ async saveToMainDB(response) {
30649
+ var _a;
30650
+ const processedPayload = await this.preparePayload(response);
30651
+ const client = getActiveClient();
30652
+ const cachedAt = client.cache && Date.now();
30653
+ if (client.cache) {
30654
+ const { reactions } = processedPayload, restPayload = __rest(processedPayload, ["reactions"]);
30655
+ ingestInCache(Object.assign(Object.assign({}, restPayload), { reactions, reactors: (_a = reactions[0]) === null || _a === void 0 ? void 0 : _a.reactors }), { cachedAt });
30656
+ }
30657
+ }
30658
+ appendToQueryStream(response, direction, refresh = false) {
30659
+ var _a, _b, _c, _d;
30660
+ const reactors = (_b = (_a = response.reactions[0]) === null || _a === void 0 ? void 0 : _a.reactors) !== null && _b !== void 0 ? _b : [];
30661
+ if (refresh) {
30662
+ pushToCache(this.cacheKey, {
30663
+ data: reactors.map(getResolver('reactor')),
30664
+ });
30665
+ }
30666
+ else {
30667
+ const collection = (_c = pullFromCache(this.cacheKey)) === null || _c === void 0 ? void 0 : _c.data;
30668
+ const reactions = (_d = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _d !== void 0 ? _d : [];
30669
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...reactions, ...reactors.map(getResolver('reactor'))])] }));
30670
+ }
30671
+ }
30672
+ reactor(action) {
30673
+ return (reaction) => {
30674
+ var _a;
30675
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30676
+ if (!collection)
30677
+ return;
30678
+ if (action === "onAdded" /* Amity.ReactionActionTypeEnum.OnAdded */) {
30679
+ collection.data = [...new Set([reaction.reactionId, ...collection.data])];
30680
+ }
30681
+ else if (action === "onRemoved" /* Amity.ReactionActionTypeEnum.OnRemoved */) {
30682
+ collection.data = collection.data.filter(p => p !== reaction.reactionId);
30683
+ }
30684
+ pushToCache(this.cacheKey, collection);
30685
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
30686
+ };
30687
+ }
30688
+ subscribeRTE(createSubscriber) {
30689
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
30690
+ }
30691
+ }
30692
+
30535
30693
  /**
30536
30694
  * ```js
30537
- * import { queryReactions } from '@amityco/ts-sdk-react-native'
30538
- * const { data: reactions, prevPage, nextPage } = await queryReactions({
30539
- * referenceId: 'postId',
30540
- * referenceType: 'post',
30695
+ * import { onReactorRemovedLocal } from '@amityco/ts-sdk'
30696
+ * const dispose = onReactorRemoved('post', postId, reactor => {
30697
+ * // ...
30541
30698
  * })
30542
30699
  * ```
30543
30700
  *
30544
- * Queries a paginable list of {@link Amity.Reaction} objects
30701
+ * Fired when an {@link Amity.InternalReactor} has been removed
30545
30702
  *
30546
- * @param query The query parameters
30547
- * @returns A page of {@link Amity.Reaction} objects
30703
+ * @param {@link Amity.ReactableType} referenceType
30704
+ * @param {string} referenceId
30705
+ * @param callback The function to call when the event was fired
30706
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30548
30707
  *
30549
- * @reaction Reaction API
30550
- * @async
30708
+ * @category Events
30551
30709
  * */
30552
- const queryReactions = async (query) => {
30710
+ const onReactorRemovedLocal = (referenceType, referenceId, callback) => {
30553
30711
  const client = getActiveClient();
30554
- client.log('reaction/queryReactions', query);
30555
- const _a = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 } } = _a, params = __rest(_a, ["page"]);
30556
- const { data } = await client.http.get(`/api/v3/reactions`, {
30557
- params: Object.assign(Object.assign({}, params), { referenceVersion: REFERENCE_API_V5, options: {
30558
- token: toToken(page, 'afterbeforeraw'),
30559
- } }),
30560
- });
30561
- const { paging } = data, payload = __rest(data, ["paging"]);
30562
- const { reactions } = payload;
30563
- // FIXME: correct reactions type in model
30564
- // @ts-ignore
30565
- ingestInCache(Object.assign(Object.assign({}, payload), { reactions })); // Save reaction response into cache
30566
- ingestInCache(Object.assign(Object.assign({}, payload), { reactors: reactions[0].reactors })); // Save reactors data into cache for support reaction query
30567
- const nextPage = toPageRaw(paging.next);
30568
- const prevPage = toPageRaw(paging.previous);
30569
- return { data: reactions, prevPage, nextPage };
30712
+ const callbackWrapper = (referenceType_, referenceId_, reaction) => {
30713
+ if (referenceType_ === referenceType && referenceId_ === referenceId) {
30714
+ callback(reaction);
30715
+ }
30716
+ };
30717
+ if (referenceType === 'message') {
30718
+ const filter = async (rawPayload) => {
30719
+ const payload = await prepareMessagePayload(rawPayload);
30720
+ if (!payload.reactions[0])
30721
+ return;
30722
+ ingestInCache(payload);
30723
+ callbackWrapper('message', payload.messages[0].messageId, payload.reactions[0]);
30724
+ };
30725
+ return createEventSubscriber(client, 'reaction/onReactorRemoved', 'message.reactionRemoved', filter);
30726
+ }
30727
+ if (referenceType === 'post') {
30728
+ const filter = (payload) => {
30729
+ callbackWrapper('post', payload.post.postId, payload.reactor);
30730
+ };
30731
+ return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
30732
+ }
30733
+ if (referenceType === 'story') {
30734
+ const filter = (payload) => {
30735
+ const { reactions } = payload, rest = __rest(payload, ["reactions"]);
30736
+ ingestInCache(rest);
30737
+ ingestInCache({ reactors: reactions });
30738
+ if (payload.stories.length === 0 || payload.reactions.length === 0)
30739
+ return;
30740
+ callbackWrapper('story', payload.stories[0].storyId, payload.reactions[0]);
30741
+ };
30742
+ return createEventSubscriber(client, 'story.reactionRemoved', 'story.reactionRemoved', filter);
30743
+ }
30744
+ const filter = (payload) => {
30745
+ callbackWrapper('comment', payload.comment.commentId, payload.reactor);
30746
+ };
30747
+ return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
30570
30748
  };
30571
30749
 
30572
30750
  /**
30573
30751
  * ```js
30574
- * import { queryReactor } from '@amityco/ts-sdk-react-native'
30575
- * const { data: reactions, prevPage, nextPage } = await queryReactor({
30576
- * referenceId: 'postId',
30577
- * referenceType: 'post',
30752
+ * import { onReactorAddedLocal } from '@amityco/ts-sdk'
30753
+ * const dispose = onReactorAdded('post', postId, reactor => {
30754
+ * // ...
30578
30755
  * })
30579
30756
  * ```
30580
30757
  *
30581
- * Queries a paginable list of {@link Amity.InternalReactor} objects
30758
+ * Fired when an {@link Amity.InternalReactor} has been added
30582
30759
  *
30583
- * @param query The query parameters
30584
- * @returns A page of {@link Amity.InternalReactor} objects
30760
+ * @param {@link Amity.ReactableType} referenceType
30761
+ * @param {string} referenceId
30762
+ * @param callback The function to call when the event was fired
30763
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30585
30764
  *
30586
- * @reaction Reaction API
30587
- * @async
30765
+ * @category Events
30588
30766
  * */
30589
- const queryReactor = async (query) => {
30767
+ const onReactorAddedLocal = (referenceType, referenceId, callback) => {
30590
30768
  const client = getActiveClient();
30591
- client.log('reaction/queryReactor', query);
30592
- const _a = await queryReactions(query), { data } = _a, response = __rest(_a, ["data"]);
30593
- return Object.assign(Object.assign({}, response), { data: data[0].reactors });
30769
+ const callbackWrapper = (referenceType_, referenceId_, reaction) => {
30770
+ if (referenceType_ === referenceType && referenceId_ === referenceId) {
30771
+ callback(reaction);
30772
+ }
30773
+ };
30774
+ if (referenceType === 'message') {
30775
+ const filter = async (rawPayload) => {
30776
+ const payload = await prepareMessagePayload(rawPayload);
30777
+ if (!payload.reactions[0])
30778
+ return;
30779
+ ingestInCache(payload);
30780
+ ingestInCache({ reactors: payload.reactions });
30781
+ callbackWrapper('message', payload.messages[0].messageId, payload.reactions[0]);
30782
+ };
30783
+ return createEventSubscriber(client, 'reaction/onReactorAdded', 'message.reactionAdded', filter);
30784
+ }
30785
+ if (referenceType === 'post') {
30786
+ const filter = (payload) => {
30787
+ callbackWrapper('post', payload.post.postId, payload.reactor);
30788
+ };
30789
+ return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
30790
+ }
30791
+ if (referenceType === 'story') {
30792
+ const filter = (payload) => {
30793
+ const { reactions } = payload, rest = __rest(payload, ["reactions"]);
30794
+ ingestInCache(rest);
30795
+ ingestInCache({ reactors: reactions });
30796
+ if (payload.stories.length === 0 || payload.reactions.length === 0)
30797
+ return;
30798
+ callbackWrapper('story', payload.stories[0].storyId, payload.reactions[0]);
30799
+ };
30800
+ return createEventSubscriber(client, 'story.reactionAdded', 'story.reactionAdded', filter);
30801
+ }
30802
+ const filter = (payload) => {
30803
+ callbackWrapper('comment', payload.comment.commentId, payload.reactor);
30804
+ };
30805
+ return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
30594
30806
  };
30595
30807
 
30808
+ class ReactionLiveCollectionController extends LiveCollectionController {
30809
+ constructor(query, callback) {
30810
+ const queryStreamId = hash(query);
30811
+ const cacheKey = ['reaction', 'collection', queryStreamId];
30812
+ const paginationController = new ReactionPaginationController(query);
30813
+ super(paginationController, queryStreamId, cacheKey, callback);
30814
+ this.query = query;
30815
+ this.queryStreamController = new ReactionQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), payload => payload);
30816
+ this.callback = callback.bind(this);
30817
+ this.loadPage({ initial: true });
30818
+ }
30819
+ setup() {
30820
+ var _a;
30821
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30822
+ if (!collection) {
30823
+ pushToCache(this.cacheKey, {
30824
+ data: [],
30825
+ params: {},
30826
+ });
30827
+ }
30828
+ }
30829
+ async persistModel(queryPayload) {
30830
+ await this.queryStreamController.saveToMainDB(queryPayload);
30831
+ }
30832
+ persistQueryStream({ response, direction, refresh, }) {
30833
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
30834
+ }
30835
+ startSubscription() {
30836
+ return this.queryStreamController.subscribeRTE([
30837
+ {
30838
+ fn: callback => onReactorAdded(this.query.referenceType, this.query.referenceId, callback),
30839
+ action: "onAdded" /* Amity.ReactionActionTypeEnum.OnAdded */,
30840
+ },
30841
+ {
30842
+ fn: callback => onReactorRemoved(this.query.referenceType, this.query.referenceId, callback),
30843
+ action: "onRemoved" /* Amity.ReactionActionTypeEnum.OnRemoved */,
30844
+ },
30845
+ {
30846
+ fn: callback => onReactorRemovedLocal(this.query.referenceType, this.query.referenceId, callback),
30847
+ action: "onRemoved" /* Amity.ReactionActionTypeEnum.OnRemoved */,
30848
+ },
30849
+ {
30850
+ fn: callback => onReactorAddedLocal(this.query.referenceType, this.query.referenceId, callback),
30851
+ action: "onRemoved" /* Amity.ReactionActionTypeEnum.OnRemoved */,
30852
+ },
30853
+ ]);
30854
+ }
30855
+ notifyChange({ origin, loading, error }) {
30856
+ var _a, _b;
30857
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30858
+ if (!collection)
30859
+ return;
30860
+ const data = (_b = collection.data
30861
+ .map(reactorId => pullFromCache(['reactor', 'get', reactorId]))
30862
+ .filter(Boolean)
30863
+ .map(({ data }) => LinkedObject.reactor(data))) !== null && _b !== void 0 ? _b : [];
30864
+ if (!this.shouldNotify(data) && origin === 'event')
30865
+ return;
30866
+ this.callback({
30867
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
30868
+ data,
30869
+ hasNextPage: !!this.paginationController.getNextToken(),
30870
+ loading,
30871
+ error,
30872
+ });
30873
+ }
30874
+ }
30875
+
30876
+ /* eslint-disable no-use-before-define */
30596
30877
  /* begin_public_function
30597
30878
  id: reaction.query
30598
30879
  */
30599
30880
  /**
30600
30881
  * ```js
30601
- * import { getReactions } from '@amityco/ts-sdk-react-native'
30882
+ * import { getReactions } from '@amityco/ts-sdk'
30602
30883
  *
30603
30884
  * let reactions = []
30604
30885
  * const unsub = liveReactions({
@@ -30618,73 +30899,19 @@ const queryReactor = async (query) => {
30618
30899
  */
30619
30900
  const getReactions = (params, callback, config) => {
30620
30901
  const { log, cache } = getActiveClient();
30621
- if (!cache) {
30622
- console.log('For using Live Collection feature you need to enable Cache!');
30623
- }
30902
+ // if (!cache) {
30903
+ // console.log('For using Live Collection feature you need to enable Cache!');
30904
+ // }
30624
30905
  const timestamp = Date.now();
30625
- log(`liveReactions(tmpid: ${timestamp}) > listen`);
30626
- const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
30627
- const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
30628
- const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
30629
- const disposers = [];
30630
- const cacheKey = [
30631
- 'reaction',
30632
- 'collection',
30633
- { referenceId: params.referenceId, referenceType: params.referenceType },
30634
- ];
30635
- const responder = (data) => {
30636
- var _a, _b;
30637
- const reactions = (_a = data.data
30638
- .map(reactorId => pullFromCache(['reactor', 'get', reactorId]))
30639
- .filter(Boolean)
30640
- .map(({ data }) => LinkedObject.reactor(data))) !== null && _a !== void 0 ? _a : [];
30641
- callback({
30642
- onNextPage: onFetch,
30643
- data: reactions,
30644
- hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
30645
- loading: data.loading,
30646
- error: data.error,
30647
- });
30648
- };
30649
- const realtimeRouter = (action) => (reaction) => {
30650
- var _a;
30651
- const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30652
- if (!collection)
30653
- return;
30654
- if (action === 'onAdded') {
30655
- collection.data = [...new Set([reaction.reactionId, ...collection.data])];
30656
- }
30657
- else if (action === 'onRemoved') {
30658
- collection.data = collection.data.filter(p => p !== reaction.reactionId);
30659
- }
30660
- pushToCache(cacheKey, collection);
30661
- responder(collection);
30662
- };
30663
- const onFetch = (initial = false) => {
30664
- var _a, _b, _c, _d;
30665
- const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30666
- const reactions = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
30667
- if (!initial && reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
30668
- return;
30669
- const query = createQuery(queryReactor, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
30670
- runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
30671
- const data = {
30672
- loading,
30673
- error,
30674
- params: { page },
30675
- data: reactions,
30676
- };
30677
- if (result) {
30678
- data.data = [...new Set([...reactions, ...result.map(getResolver('reactor'))])];
30679
- }
30680
- pushToCache(cacheKey, data);
30681
- responder(data);
30682
- }, queryOptions(policy));
30683
- };
30684
- disposers.push(onReactorAdded(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onAdded')), onReactorRemoved(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onRemoved')));
30685
- onFetch(true);
30906
+ log(`getReactions(tmpid: ${timestamp}) > listen`);
30907
+ const reactionLiveCollection = new ReactionLiveCollectionController(params, callback);
30908
+ const disposers = reactionLiveCollection.startSubscription();
30909
+ const cacheKey = reactionLiveCollection.getCacheKey();
30910
+ disposers.push(() => {
30911
+ dropFromCache(cacheKey);
30912
+ });
30686
30913
  return () => {
30687
- log(`liveReactions(tmpid: ${timestamp}) > dispose`);
30914
+ log(`getReactions(tmpid: ${timestamp}) > dispose`);
30688
30915
  disposers.forEach(fn => fn());
30689
30916
  };
30690
30917
  };
@@ -31190,30 +31417,6 @@ const unmuteChannel = async (channelId) => {
31190
31417
  };
31191
31418
  /* end_public_function */
31192
31419
 
31193
- const convertEventPayload = (eventHandler, sourceModelProp, destinationDomain) => (callback) => eventHandler(sourceModel => {
31194
- var _a, _b;
31195
- if (!sourceModel) {
31196
- return sourceModel;
31197
- }
31198
- const client = getActiveClient();
31199
- const { objectSyncMap } = client;
31200
- /*
31201
- * NOTE: For objects created locally (optimistic creation), the SDK stores them with their local ID as the cache key, which is used throughout the entire SDK session (in-memory) for syncing updates.
31202
- * If the payload or response only contains the remote ID of the same object, the SDK will look up the corresponding local ID to retrieve the object.
31203
- */
31204
- const resolvedId = isLocalId(sourceModel[sourceModelProp])
31205
- ? sourceModel[sourceModelProp]
31206
- : (_a = objectSyncMap.get(sourceModel[sourceModelProp])) !== null && _a !== void 0 ? _a : sourceModel[sourceModelProp];
31207
- const model = (_b = pullFromCache([
31208
- destinationDomain,
31209
- 'get',
31210
- `${resolvedId}`,
31211
- ])) === null || _b === void 0 ? void 0 : _b.data;
31212
- if (!model)
31213
- return;
31214
- return callback(model);
31215
- });
31216
-
31217
31420
  /**
31218
31421
  * ```js
31219
31422
  * import { observeChannel } from '@amityco/ts-sdk-react-native'
@@ -35363,7 +35566,8 @@ const createCommunityMemberEventSubscriber = (event, callback) => {
35363
35566
  callback(preparedPayload.communities[0], getEventRelatedMember(event, preparedPayload));
35364
35567
  }
35365
35568
  else {
35366
- ingestInCache(preparedPayload);
35569
+ // NOTE: The event payload should be merge with existing cache data
35570
+ ingestInCache(preparedPayload, undefined, false);
35367
35571
  const community = pullFromCache([
35368
35572
  'community',
35369
35573
  'get',
@@ -35400,7 +35604,8 @@ const createLocalCommunityMemberEventSubscriber = (event, callback) => {
35400
35604
  callback(preparedPayload.communities[0], getEventRelatedMember(event, preparedPayload));
35401
35605
  }
35402
35606
  else {
35403
- ingestInCache(preparedPayload);
35607
+ // NOTE: The event payload should be merge with existing cache data
35608
+ ingestInCache(preparedPayload, undefined, false);
35404
35609
  const community = pullFromCache([
35405
35610
  'community',
35406
35611
  'get',
@@ -37490,9 +37695,10 @@ const queryGlobalFeed = async (query) => {
37490
37695
  const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
37491
37696
  const data = prepareMembershipPayload(payload, 'communityUsers');
37492
37697
  const { posts } = data;
37698
+ const { communities: processedCommunity } = prepareCommunityPayload(data);
37493
37699
  const cachedAt = client.cache && Date.now();
37494
37700
  if (client.cache) {
37495
- ingestInCache(data);
37701
+ ingestInCache(Object.assign(Object.assign({}, data), { communitis: processedCommunity }));
37496
37702
  const cacheKey = [
37497
37703
  'globalFeed',
37498
37704
  'query',
@@ -39807,6 +40013,145 @@ const getPinnedPosts = (params, callback, config) => {
39807
40013
  };
39808
40014
  };
39809
40015
 
40016
+ class GlobalPinnedPostPaginationController extends PaginationController {
40017
+ async getRequest(queryParams, token) {
40018
+ __rest(queryParams, ["limit"]);
40019
+ const path = '/api/v1/pinned-posts/global';
40020
+ const { data: queryResponse } = await this.http.get(path);
40021
+ return queryResponse;
40022
+ }
40023
+ }
40024
+
40025
+ class GlobalPinnedPostQueryStreamController extends QueryStreamController {
40026
+ constructor(query, cacheKey, notifyChange, preparePayload) {
40027
+ super(query, cacheKey);
40028
+ this.notifyChange = notifyChange;
40029
+ this.preparePayload = preparePayload;
40030
+ }
40031
+ // eslint-disable-next-line class-methods-use-this
40032
+ async saveToMainDB(response) {
40033
+ const client = getActiveClient();
40034
+ const cachedAt = client.cache && Date.now();
40035
+ if (client.cache) {
40036
+ ingestInCache(response, { cachedAt });
40037
+ }
40038
+ }
40039
+ appendToQueryStream(response, direction, refresh = false) {
40040
+ var _a, _b;
40041
+ if (refresh) {
40042
+ pushToCache(this.cacheKey, {
40043
+ data: response.pins.map(getResolver('pin')),
40044
+ });
40045
+ }
40046
+ else {
40047
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
40048
+ const pinnedPosts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
40049
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...pinnedPosts, ...response.pins.map(getResolver('pin'))])] }));
40050
+ this.notifyChange({
40051
+ origin: "server" /* Amity.LiveDataOrigin.SERVER */,
40052
+ loading: false,
40053
+ });
40054
+ }
40055
+ }
40056
+ reactor(action) {
40057
+ return (post) => {
40058
+ var _a;
40059
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
40060
+ if (!collection)
40061
+ return;
40062
+ if (action === EnumPostActions.OnPostDeleted) {
40063
+ collection.data = collection.data.filter(referenceId => referenceId !== `global#${post.postId}`);
40064
+ }
40065
+ pushToCache(this.cacheKey, collection);
40066
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
40067
+ };
40068
+ }
40069
+ subscribeRTE(createSubscriber) {
40070
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
40071
+ }
40072
+ }
40073
+
40074
+ class GlobalPinnedPostLiveCollectionController extends LiveCollectionController {
40075
+ constructor(query, callback) {
40076
+ const queryStreamId = hash(query);
40077
+ const cacheKey = ['pinnedPosts', 'collection', queryStreamId];
40078
+ const paginationController = new GlobalPinnedPostPaginationController(query);
40079
+ super(paginationController, queryStreamId, cacheKey, callback);
40080
+ this.query = query;
40081
+ this.queryStreamController = new GlobalPinnedPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
40082
+ this.callback = callback.bind(this);
40083
+ this.loadPage({ initial: true });
40084
+ }
40085
+ setup() {
40086
+ var _a;
40087
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
40088
+ if (!collection) {
40089
+ pushToCache(this.cacheKey, {
40090
+ data: [],
40091
+ params: {},
40092
+ });
40093
+ }
40094
+ }
40095
+ async persistModel(queryPayload) {
40096
+ await this.queryStreamController.saveToMainDB(queryPayload);
40097
+ }
40098
+ persistQueryStream({ response, direction, refresh, }) {
40099
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
40100
+ }
40101
+ // eslint-disable-next-line class-methods-use-this
40102
+ startSubscription() {
40103
+ return this.queryStreamController.subscribeRTE([
40104
+ { fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
40105
+ {
40106
+ fn: onPostDeleted,
40107
+ action: EnumPostActions.OnPostDeleted,
40108
+ },
40109
+ ]);
40110
+ }
40111
+ notifyChange({ origin, loading, error }) {
40112
+ var _a, _b;
40113
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
40114
+ if (!collection)
40115
+ return;
40116
+ const data = ((_b = collection.data
40117
+ .map(id => pullFromCache(['pin', 'get', id]))
40118
+ .filter(isNonNullable)
40119
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.pinnedPost);
40120
+ if (!this.shouldNotify(data) && origin === 'event')
40121
+ return;
40122
+ this.callback({
40123
+ data,
40124
+ loading,
40125
+ error,
40126
+ });
40127
+ }
40128
+ }
40129
+
40130
+ /**
40131
+ * Get global pinned posts
40132
+ *
40133
+ * @returns the global pinned post(s)
40134
+ *
40135
+ * @category Pined Posts Live Collection
40136
+ *
40137
+ */
40138
+ const getGlobalPinnedPosts = (params, callback, config) => {
40139
+ const { log, cache } = getActiveClient();
40140
+ // if (!cache) {
40141
+ // console.log(ENABLE_CACHE_MESSAGE);
40142
+ // }
40143
+ const timestamp = Date.now();
40144
+ log(`getGlobalPinnedPosts(tmpid: ${timestamp}) > listen`);
40145
+ const globalPinnedPostLiveCollection = new GlobalPinnedPostLiveCollectionController(params, callback);
40146
+ const disposers = globalPinnedPostLiveCollection.startSubscription();
40147
+ const cacheKey = globalPinnedPostLiveCollection.getCacheKey();
40148
+ disposers.push(() => dropFromCache(cacheKey));
40149
+ return () => {
40150
+ log(`getGlobalPinnedPosts(tmpid: ${timestamp}) > dispose`);
40151
+ disposers.forEach(fn => fn());
40152
+ };
40153
+ };
40154
+
39810
40155
  class SemanticSearchPostPaginationController extends PaginationController {
39811
40156
  async getRequest(queryParams, token) {
39812
40157
  const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
@@ -40068,6 +40413,7 @@ var index$5 = /*#__PURE__*/Object.freeze({
40068
40413
  getPost: getPost$1,
40069
40414
  getPosts: getPosts,
40070
40415
  getPinnedPosts: getPinnedPosts,
40416
+ getGlobalPinnedPosts: getGlobalPinnedPosts,
40071
40417
  semanticSearchPosts: semanticSearchPosts
40072
40418
  });
40073
40419
 
@@ -41612,8 +41958,8 @@ const onStoryReactionAdded = (callback) => {
41612
41958
  const onStoryReactionAddedLocal = (callback) => {
41613
41959
  const client = getActiveClient();
41614
41960
  const filter = async (payload) => {
41615
- ingestInCache(payload);
41616
- callback(payload.stories);
41961
+ ingestInCache({ stories: [payload.story] });
41962
+ callback([payload.story]);
41617
41963
  };
41618
41964
  const disposers = [
41619
41965
  createEventSubscriber(client, 'onStoryReactionAdded', 'local.story.reactionAdded', filter),
@@ -41642,8 +41988,8 @@ const onStoryReactionRemoved = (callback) => {
41642
41988
  const onStoryReactionRemovedLocal = (callback) => {
41643
41989
  const client = getActiveClient();
41644
41990
  const filter = async (payload) => {
41645
- ingestInCache(payload);
41646
- callback(payload.stories);
41991
+ ingestInCache({ stories: [payload.story] });
41992
+ callback([payload.story]);
41647
41993
  };
41648
41994
  const disposers = [
41649
41995
  createEventSubscriber(client, 'onStoryReactionRemoved', 'local.story.reactionRemoved', filter),
@@ -42183,12 +42529,12 @@ const updateLocalList = (cacheKey, targetIds) => {
42183
42529
  pushToCache(cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...storyTargets, ...targetIds])] }));
42184
42530
  };
42185
42531
  class GlobalStoryQueryStreamController extends QueryStreamController {
42186
- constructor(query, cacheKey, notifyChange, paginationController) {
42532
+ constructor(query, cacheKey, notifyChange, paginationController, preparePayload) {
42187
42533
  super(query, cacheKey);
42188
42534
  this.notifyChange = notifyChange;
42189
42535
  this.paginationController = paginationController;
42190
42536
  // Fix ESLint, "Expected 'this' to be used by class method"
42191
- this.preparePayload = payload => payload;
42537
+ this.preparePayload = preparePayload;
42192
42538
  }
42193
42539
  saveToMainDB(response) {
42194
42540
  const client = getActiveClient();
@@ -42280,7 +42626,10 @@ class GlobalStoryLiveCollectionController extends LiveCollectionController {
42280
42626
  const paginationController = new GlobalStoryPageController(query);
42281
42627
  super(paginationController, queryStreamId, cacheKey, callback);
42282
42628
  this.query = query;
42283
- this.queryStreamController = new GlobalStoryQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), paginationController);
42629
+ this.queryStreamController = new GlobalStoryQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), paginationController, (data) => {
42630
+ const _a = prepareCommunityPayload(Object.assign(Object.assign({}, data), { feeds: [] })), rest = __rest(_a, ["feeds"]);
42631
+ return Object.assign(Object.assign({}, data), rest);
42632
+ });
42284
42633
  this.paginationController = paginationController;
42285
42634
  this.callback = callback.bind(this);
42286
42635
  this.loadPage({ initial: true });