@amityco/ts-sdk 7.22.1-ef6b9414.0 → 7.23.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 (108) hide show
  1. package/dist/@types/core/errors.d.ts +2 -1
  2. package/dist/@types/core/errors.d.ts.map +1 -1
  3. package/dist/@types/core/events.d.ts +5 -1
  4. package/dist/@types/core/events.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +5 -1
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/block.d.ts +5 -0
  8. package/dist/@types/domains/block.d.ts.map +1 -1
  9. package/dist/@types/domains/channel.d.ts +11 -0
  10. package/dist/@types/domains/channel.d.ts.map +1 -1
  11. package/dist/@types/domains/client.d.ts +23 -0
  12. package/dist/@types/domains/client.d.ts.map +1 -1
  13. package/dist/@types/domains/comment.d.ts +1 -0
  14. package/dist/@types/domains/comment.d.ts.map +1 -1
  15. package/dist/@types/domains/post.d.ts +1 -0
  16. package/dist/@types/domains/post.d.ts.map +1 -1
  17. package/dist/channelRepository/observers/index.d.ts +1 -0
  18. package/dist/channelRepository/observers/index.d.ts.map +1 -1
  19. package/dist/channelRepository/observers/searchChannels/SearchChannelLiveCollectionController.d.ts +14 -0
  20. package/dist/channelRepository/observers/searchChannels/SearchChannelLiveCollectionController.d.ts.map +1 -0
  21. package/dist/channelRepository/observers/searchChannels/SearchChannelPaginationController.d.ts +10 -0
  22. package/dist/channelRepository/observers/searchChannels/SearchChannelPaginationController.d.ts.map +1 -0
  23. package/dist/channelRepository/observers/searchChannels/SearchChannelQueryStreamController.d.ts +13 -0
  24. package/dist/channelRepository/observers/searchChannels/SearchChannelQueryStreamController.d.ts.map +1 -0
  25. package/dist/channelRepository/observers/searchChannels.d.ts +21 -0
  26. package/dist/channelRepository/observers/searchChannels.d.ts.map +1 -0
  27. package/dist/channelRepository/observers/tests/integrations/searchChannels.integration.test.d.ts +2 -0
  28. package/dist/channelRepository/observers/tests/integrations/searchChannels.integration.test.d.ts.map +1 -0
  29. package/dist/client/api/autoSubscription.d.ts +47 -0
  30. package/dist/client/api/autoSubscription.d.ts.map +1 -0
  31. package/dist/client/api/createClient.d.ts.map +1 -1
  32. package/dist/client/api/getCoreUserSettings.d.ts +16 -0
  33. package/dist/client/api/getCoreUserSettings.d.ts.map +1 -0
  34. package/dist/client/api/getForYouFeedSetting.d.ts +17 -0
  35. package/dist/client/api/getForYouFeedSetting.d.ts.map +1 -0
  36. package/dist/client/api/index.d.ts +3 -0
  37. package/dist/client/api/index.d.ts.map +1 -1
  38. package/dist/client/api/setupLoginSubscriptions.d.ts.map +1 -1
  39. package/dist/client/utils/autoSubscriptionManager.d.ts +21 -0
  40. package/dist/client/utils/autoSubscriptionManager.d.ts.map +1 -0
  41. package/dist/client/utils/subscribeGlobalTopic.d.ts +6 -1
  42. package/dist/client/utils/subscribeGlobalTopic.d.ts.map +1 -1
  43. package/dist/client/utils/tests/autoSubscriptionManager.test.d.ts +2 -0
  44. package/dist/client/utils/tests/autoSubscriptionManager.test.d.ts.map +1 -0
  45. package/dist/commentRepository/observers/getComments/CommentLiveCollectionController.d.ts.map +1 -1
  46. package/dist/commentRepository/observers/tests/integrations/getCommentsExcludeBlockUser.integration.test.d.ts +2 -0
  47. package/dist/commentRepository/observers/tests/integrations/getCommentsExcludeBlockUser.integration.test.d.ts.map +1 -0
  48. package/dist/core/events.d.ts +3 -3
  49. package/dist/core/events.d.ts.map +1 -1
  50. package/dist/core/query/filtering.d.ts +32 -0
  51. package/dist/core/query/filtering.d.ts.map +1 -1
  52. package/dist/feedRepository/observers/getForYouFeed/CursorController.d.ts +2 -0
  53. package/dist/feedRepository/observers/getForYouFeed/CursorController.d.ts.map +1 -1
  54. package/dist/feedRepository/observers/getForYouFeed/PaginationController.d.ts +5 -4
  55. package/dist/feedRepository/observers/getForYouFeed/PaginationController.d.ts.map +1 -1
  56. package/dist/index.cjs.js +1442 -269
  57. package/dist/index.esm.js +1440 -270
  58. package/dist/index.umd.js +3 -3
  59. package/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
  60. package/dist/postRepository/observers/tests/getPostsExcludeBlockUser.test.d.ts +2 -0
  61. package/dist/postRepository/observers/tests/getPostsExcludeBlockUser.test.d.ts.map +1 -0
  62. package/dist/userRepository/api/getAllBlockedUsers.d.ts.map +1 -1
  63. package/dist/userRepository/api/getAllBlockingUsers.d.ts +20 -0
  64. package/dist/userRepository/api/getAllBlockingUsers.d.ts.map +1 -0
  65. package/dist/userRepository/api/index.d.ts +1 -0
  66. package/dist/userRepository/api/index.d.ts.map +1 -1
  67. package/dist/userRepository/api/tests/integration/getAllBlockingUsers.integration.test.d.ts +2 -0
  68. package/dist/userRepository/api/tests/integration/getAllBlockingUsers.integration.test.d.ts.map +1 -0
  69. package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts.map +1 -1
  70. package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts +4 -3
  71. package/dist/userRepository/observers/getBlockedUsers/BlockedUserQueryStreamController.d.ts.map +1 -1
  72. package/dist/userRepository/observers/getBlockingUsers/LiveCollectionController.d.ts +13 -0
  73. package/dist/userRepository/observers/getBlockingUsers/LiveCollectionController.d.ts.map +1 -0
  74. package/dist/userRepository/observers/getBlockingUsers/PaginationController.d.ts +5 -0
  75. package/dist/userRepository/observers/getBlockingUsers/PaginationController.d.ts.map +1 -0
  76. package/dist/userRepository/observers/getBlockingUsers/QueryStreamController.d.ts +16 -0
  77. package/dist/userRepository/observers/getBlockingUsers/QueryStreamController.d.ts.map +1 -0
  78. package/dist/userRepository/observers/getBlockingUsers.d.ts +17 -0
  79. package/dist/userRepository/observers/getBlockingUsers.d.ts.map +1 -0
  80. package/dist/userRepository/observers/index.d.ts +1 -0
  81. package/dist/userRepository/observers/index.d.ts.map +1 -1
  82. package/dist/userRepository/observers/tests/integrations/getBlockingUsers.integration.test.d.ts +2 -0
  83. package/dist/userRepository/observers/tests/integrations/getBlockingUsers.integration.test.d.ts.map +1 -0
  84. package/dist/userRepository/relationship/block/enum/index.d.ts +5 -0
  85. package/dist/userRepository/relationship/block/enum/index.d.ts.map +1 -0
  86. package/dist/userRepository/relationship/block/events/index.d.ts +3 -0
  87. package/dist/userRepository/relationship/block/events/index.d.ts.map +1 -0
  88. package/dist/userRepository/relationship/block/events/onUserDidBlock.d.ts +20 -0
  89. package/dist/userRepository/relationship/block/events/onUserDidBlock.d.ts.map +1 -0
  90. package/dist/userRepository/relationship/block/events/onUserDidUnblock.d.ts +20 -0
  91. package/dist/userRepository/relationship/block/events/onUserDidUnblock.d.ts.map +1 -0
  92. package/dist/userRepository/relationship/block/index.d.ts +1 -0
  93. package/dist/userRepository/relationship/block/index.d.ts.map +1 -1
  94. package/dist/userRepository/relationship/block/utils/blockRealtimeOnLoginHandler.d.ts +12 -0
  95. package/dist/userRepository/relationship/block/utils/blockRealtimeOnLoginHandler.d.ts.map +1 -0
  96. package/dist/userRepository/relationship/block/utils/createBlockEventSubscriber.d.ts +11 -0
  97. package/dist/userRepository/relationship/block/utils/createBlockEventSubscriber.d.ts.map +1 -0
  98. package/dist/userRepository/services/BlockedUserSyncEngine/blockedUserSyncEngine.d.ts +13 -13
  99. package/dist/userRepository/services/BlockedUserSyncEngine/blockedUserSyncEngine.d.ts.map +1 -1
  100. package/dist/userRepository/services/BlockingUserSyncEngine/blockingUserSyncEngine.d.ts +56 -0
  101. package/dist/userRepository/services/BlockingUserSyncEngine/blockingUserSyncEngine.d.ts.map +1 -0
  102. package/dist/userRepository/services/BlockingUserSyncEngine/blockingUserSyncEngineOnLoginHandler.d.ts +3 -0
  103. package/dist/userRepository/services/BlockingUserSyncEngine/blockingUserSyncEngineOnLoginHandler.d.ts.map +1 -0
  104. package/dist/userRepository/utils/prepareBlockingUserPayload.d.ts +2 -0
  105. package/dist/userRepository/utils/prepareBlockingUserPayload.d.ts.map +1 -0
  106. package/dist/utils/tests/dummy/block.d.ts +16 -0
  107. package/dist/utils/tests/dummy/block.d.ts.map +1 -1
  108. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -28,6 +28,13 @@ exports.MembershipAcceptanceTypeEnum = void 0;
28
28
  MembershipAcceptanceTypeEnum["AUTOMATIC"] = "automatic";
29
29
  MembershipAcceptanceTypeEnum["INVITATION"] = "invitation";
30
30
  })(exports.MembershipAcceptanceTypeEnum || (exports.MembershipAcceptanceTypeEnum = {}));
31
+ exports.AmityAutoSubscription = void 0;
32
+ (function (AmityAutoSubscription) {
33
+ AmityAutoSubscription["CHAT"] = "chat";
34
+ AmityAutoSubscription["NETWORK"] = "network";
35
+ AmityAutoSubscription["LIVESTREAM"] = "livestream";
36
+ AmityAutoSubscription["BLOCK"] = "block";
37
+ })(exports.AmityAutoSubscription || (exports.AmityAutoSubscription = {}));
31
38
 
32
39
  exports.UserTypeEnum = void 0;
33
40
  (function (UserTypeEnum) {
@@ -306,8 +313,8 @@ exports.NotificationRolesFilterTypeEnum = void 0;
306
313
 
307
314
  function getVersion() {
308
315
  try {
309
- // the string ''v7.22.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
310
- return 'v7.22.0-cjs';
316
+ // the string ''v7.23.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
317
+ return 'v7.23.0-cjs';
311
318
  }
312
319
  catch (error) {
313
320
  return '__dev__';
@@ -712,6 +719,95 @@ function createSnapshot(data, options) {
712
719
  return Object.assign(Object.assign({}, options), { data });
713
720
  }
714
721
 
722
+ /* eslint-disable max-classes-per-file */
723
+ /**
724
+ * Generic ASC error
725
+ * @category Errors
726
+ */
727
+ class ASCError extends Error {
728
+ /**
729
+ * @param message A custom error message
730
+ * @param code A normalized error code
731
+ * @param level A normalized failure level descriptor
732
+ */
733
+ constructor(message, code, level) {
734
+ super(`Amity SDK (${code}): ${message}`);
735
+ this.code = code;
736
+ this.level = level;
737
+ this.type = 'ASC';
738
+ this.timestamp = Date.now();
739
+ if (Error.captureStackTrace)
740
+ Error.captureStackTrace(this, ASCError);
741
+ }
742
+ }
743
+ /**
744
+ * API level error
745
+ * @category Errors
746
+ */
747
+ class ASCApiError extends ASCError {
748
+ /**
749
+ * @param code A normalized error code
750
+ * @param level A normalized failure level descriptor
751
+ */
752
+ // eslint-disable-next-line no-useless-constructor
753
+ constructor(message, code, level) {
754
+ super(message, code, level);
755
+ }
756
+ }
757
+ /**
758
+ * Unexpected error
759
+ * @category Errors
760
+ */
761
+ class ASCUnknownError extends ASCError {
762
+ /**
763
+ * @param code A normalized error code
764
+ * @param level A normalized failure level descriptor
765
+ */
766
+ constructor(code = 800000 /* Amity.ClientError.UNKNOWN_ERROR */, level = "fatal" /* Amity.ErrorLevel.FATAL */) {
767
+ super('Unexpected error', code, level);
768
+ }
769
+ }
770
+ /**
771
+ * Network related error
772
+ * @category Errors
773
+ */
774
+ class ASCConnectionError extends ASCError {
775
+ /**
776
+ * @param message A custom error message
777
+ */
778
+ constructor(event, message = 'SDK client is having connection issues') {
779
+ super(`${message} (${event})`, event === 'disconnected'
780
+ ? 800211 /* Amity.ClientError.DISCONNECTED */
781
+ : 800210 /* Amity.ClientError.CONNECTION_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
782
+ this.event = event;
783
+ }
784
+ }
785
+
786
+ let activeClient = null;
787
+ /**
788
+ * Get the active client
789
+ *
790
+ * @returns the active client instance
791
+ *
792
+ * @hidden
793
+ */
794
+ const getActiveClient = () => {
795
+ if (!activeClient) {
796
+ throw new ASCError('There is no active client', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
797
+ }
798
+ return activeClient;
799
+ };
800
+ /**
801
+ * Sets the active client
802
+ *
803
+ * @param client the client to assume as currently active client
804
+ *
805
+ * @hidden
806
+ */
807
+ const setActiveClient = (client) => {
808
+ activeClient = client;
809
+ };
810
+
715
811
  /** @hidden */
716
812
  const idResolvers = {
717
813
  user: ({ userId }) => userId,
@@ -839,95 +935,6 @@ function getFutureDate(date = new Date().toISOString()) {
839
935
  return new Date(new Date(date).getTime() + 1).toISOString();
840
936
  }
841
937
 
842
- /* eslint-disable max-classes-per-file */
843
- /**
844
- * Generic ASC error
845
- * @category Errors
846
- */
847
- class ASCError extends Error {
848
- /**
849
- * @param message A custom error message
850
- * @param code A normalized error code
851
- * @param level A normalized failure level descriptor
852
- */
853
- constructor(message, code, level) {
854
- super(`Amity SDK (${code}): ${message}`);
855
- this.code = code;
856
- this.level = level;
857
- this.type = 'ASC';
858
- this.timestamp = Date.now();
859
- if (Error.captureStackTrace)
860
- Error.captureStackTrace(this, ASCError);
861
- }
862
- }
863
- /**
864
- * API level error
865
- * @category Errors
866
- */
867
- class ASCApiError extends ASCError {
868
- /**
869
- * @param code A normalized error code
870
- * @param level A normalized failure level descriptor
871
- */
872
- // eslint-disable-next-line no-useless-constructor
873
- constructor(message, code, level) {
874
- super(message, code, level);
875
- }
876
- }
877
- /**
878
- * Unexpected error
879
- * @category Errors
880
- */
881
- class ASCUnknownError extends ASCError {
882
- /**
883
- * @param code A normalized error code
884
- * @param level A normalized failure level descriptor
885
- */
886
- constructor(code = 800000 /* Amity.ClientError.UNKNOWN_ERROR */, level = "fatal" /* Amity.ErrorLevel.FATAL */) {
887
- super('Unexpected error', code, level);
888
- }
889
- }
890
- /**
891
- * Network related error
892
- * @category Errors
893
- */
894
- class ASCConnectionError extends ASCError {
895
- /**
896
- * @param message A custom error message
897
- */
898
- constructor(event, message = 'SDK client is having connection issues') {
899
- super(`${message} (${event})`, event === 'disconnected'
900
- ? 800211 /* Amity.ClientError.DISCONNECTED */
901
- : 800210 /* Amity.ClientError.CONNECTION_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
902
- this.event = event;
903
- }
904
- }
905
-
906
- let activeClient = null;
907
- /**
908
- * Get the active client
909
- *
910
- * @returns the active client instance
911
- *
912
- * @hidden
913
- */
914
- const getActiveClient = () => {
915
- if (!activeClient) {
916
- throw new ASCError('There is no active client', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
917
- }
918
- return activeClient;
919
- };
920
- /**
921
- * Sets the active client
922
- *
923
- * @param client the client to assume as currently active client
924
- *
925
- * @hidden
926
- */
927
- const setActiveClient = (client) => {
928
- activeClient = client;
929
- };
930
-
931
938
  /**
932
939
  * ```js
933
940
  * import { enableCache } from '@amityco/ts-sdk'
@@ -1435,6 +1442,65 @@ const filterBySearchTerm = (collection, searchTerm) => {
1435
1442
  return m.user && ((_a = m.user.displayName) === null || _a === void 0 ? void 0 : _a.match(containsMatcher));
1436
1443
  });
1437
1444
  };
1445
+ /**
1446
+ * The ids of users in a block relationship with the current user — in BOTH
1447
+ * directions — derived synchronously from the local follow cache. For every
1448
+ * `status === 'blocked'` row that involves the current user, the OTHER party
1449
+ * is collected: `from === me` (users I blocked, outgoing) contributes `to`;
1450
+ * `to === me` (users who blocked me, incoming) contributes `from`.
1451
+ *
1452
+ * @returns a set of block-related user ids (both directions)
1453
+ *
1454
+ * @hidden
1455
+ */
1456
+ const getBlockUsersId = () => {
1457
+ var _a;
1458
+ const { userId } = getActiveClient();
1459
+ const ids = new Set();
1460
+ ((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
1461
+ .map(entry => entry.data)
1462
+ .filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'blocked' && (follow.from === userId || follow.to === userId))
1463
+ .forEach(follow => {
1464
+ ids.add(follow.from === userId ? follow.to : follow.from);
1465
+ });
1466
+ return ids;
1467
+ };
1468
+ /**
1469
+ * Filter out posts whose author or any mentionee is in a block relationship
1470
+ * with the current user, in either direction (see {@link getBlockUsersId}).
1471
+ *
1472
+ * @param collection the post collection to filter
1473
+ * @returns a filtered collection excluding posts involving block-related users
1474
+ *
1475
+ * @hidden
1476
+ */
1477
+ const filterPostsByBlockUsers = (collection) => {
1478
+ const blockUsersId = getBlockUsersId();
1479
+ if (blockUsersId.size === 0)
1480
+ return collection;
1481
+ return collection.filter(post => {
1482
+ var _a, _b;
1483
+ if (blockUsersId.has(post.postedUserId))
1484
+ return false;
1485
+ const mentionedUserIds = (_b = (_a = post.mentionees) === null || _a === void 0 ? void 0 : _a.flatMap(mention => (mention.type === 'user' ? mention.userIds : []))) !== null && _b !== void 0 ? _b : [];
1486
+ return !mentionedUserIds.some(id => blockUsersId.has(id));
1487
+ });
1488
+ };
1489
+ /**
1490
+ * Filter out comments whose creator is in a block relationship with the
1491
+ * current user, in either direction (see {@link getBlockUsersId}).
1492
+ *
1493
+ * @param collection the comment collection to filter
1494
+ * @returns a filtered collection excluding comments from block-related users
1495
+ *
1496
+ * @hidden
1497
+ */
1498
+ const filterCommentsByBlockUsers = (collection) => {
1499
+ const blockUsersId = getBlockUsersId();
1500
+ if (blockUsersId.size === 0)
1501
+ return collection;
1502
+ return collection.filter(comment => !blockUsersId.has(comment.userId));
1503
+ };
1438
1504
 
1439
1505
  // Note:
1440
1506
  // this file should contain a suite of sorting utilities to help the
@@ -1905,13 +1971,13 @@ class NetworkActivitiesWatcher {
1905
1971
  this._listener.clear();
1906
1972
  }
1907
1973
  }
1908
- let instance$9;
1974
+ let instance$b;
1909
1975
  var NetworkActivitiesWatcher$1 = {
1910
1976
  getInstance: () => {
1911
- if (!instance$9) {
1912
- instance$9 = new NetworkActivitiesWatcher();
1977
+ if (!instance$b) {
1978
+ instance$b = new NetworkActivitiesWatcher();
1913
1979
  }
1914
- return instance$9;
1980
+ return instance$b;
1915
1981
  },
1916
1982
  };
1917
1983
 
@@ -4659,18 +4725,149 @@ walker=walker.next;}if(i===n&&walker!==null){return walker.value;}};Yallist.prot
4659
4725
  walker=walker.prev;}if(i===n&&walker!==null){return walker.value;}};Yallist.prototype.map=function(fn,thisp){thisp=thisp||this;var res=new Yallist();for(var walker=this.head;walker!==null;){res.push(fn.call(thisp,walker.value,this));walker=walker.next;}return res;};Yallist.prototype.mapReverse=function(fn,thisp){thisp=thisp||this;var res=new Yallist();for(var walker=this.tail;walker!==null;){res.push(fn.call(thisp,walker.value,this));walker=walker.prev;}return res;};Yallist.prototype.reduce=function(fn,initial){var acc;var walker=this.head;if(arguments.length>1){acc=initial;}else if(this.head){walker=this.head.next;acc=this.head.value;}else {throw new TypeError('Reduce of empty list with no initial value');}for(var i=0;walker!==null;i++){acc=fn(acc,walker.value,i);walker=walker.next;}return acc;};Yallist.prototype.reduceReverse=function(fn,initial){var acc;var walker=this.tail;if(arguments.length>1){acc=initial;}else if(this.tail){walker=this.tail.prev;acc=this.tail.value;}else {throw new TypeError('Reduce of empty list with no initial value');}for(var i=this.length-1;walker!==null;i--){acc=fn(acc,walker.value,i);walker=walker.prev;}return acc;};Yallist.prototype.toArray=function(){var arr=new Array(this.length);for(var i=0,walker=this.head;walker!==null;i++){arr[i]=walker.value;walker=walker.next;}return arr;};Yallist.prototype.toArrayReverse=function(){var arr=new Array(this.length);for(var i=0,walker=this.tail;walker!==null;i++){arr[i]=walker.value;walker=walker.prev;}return arr;};Yallist.prototype.slice=function(from,to){to=to||this.length;if(to<0){to+=this.length;}from=from||0;if(from<0){from+=this.length;}var ret=new Yallist();if(to<from||to<0){return ret;}if(from<0){from=0;}if(to>this.length){to=this.length;}for(var i=0,walker=this.head;walker!==null&&i<from;i++){walker=walker.next;}for(;walker!==null&&i<to;i++,walker=walker.next){ret.push(walker.value);}return ret;};Yallist.prototype.sliceReverse=function(from,to){to=to||this.length;if(to<0){to+=this.length;}from=from||0;if(from<0){from+=this.length;}var ret=new Yallist();if(to<from||to<0){return ret;}if(from<0){from=0;}if(to>this.length){to=this.length;}for(var i=this.length,walker=this.tail;walker!==null&&i>to;i--){walker=walker.prev;}for(;walker!==null&&i>from;i--,walker=walker.prev){ret.push(walker.value);}return ret;};Yallist.prototype.splice=function(start,deleteCount){if(start>this.length){start=this.length-1;}if(start<0){start=this.length+start;}for(var i=0,walker=this.head;walker!==null&&i<start;i++){walker=walker.next;}var ret=[];for(var i=0;walker&&i<deleteCount;i++){ret.push(walker.value);walker=this.removeNode(walker);}if(walker===null){walker=this.tail;}if(walker!==this.head&&walker!==this.tail){walker=walker.prev;}for(var i=0;i<(arguments.length<=2?0:arguments.length-2);i++){walker=insert(this,walker,i+2<2||arguments.length<=i+2?undefined:arguments[i+2]);}return ret;};Yallist.prototype.reverse=function(){var head=this.head;var tail=this.tail;for(var walker=head;walker!==null;walker=walker.prev){var p=walker.prev;walker.prev=walker.next;walker.next=p;}this.head=tail;this.tail=head;return this;};function insert(self,node,value){var inserted=node===self.head?new Node(value,null,node,self):new Node(value,node,node.next,self);if(inserted.next===null){self.tail=inserted;}if(inserted.prev===null){self.head=inserted;}self.length++;return inserted;}function push(self,item){self.tail=new Node(item,self.tail,null,self);if(!self.head){self.head=self.tail;}self.length++;}function unshift(self,item){self.head=new Node(item,null,self.head,self);if(!self.tail){self.tail=self.head;}self.length++;}function Node(value,prev,next,list){if(!(this instanceof Node)){return new Node(value,prev,next,list);}this.list=list;this.value=value;if(prev){prev.next=this;this.prev=prev;}else {this.prev=null;}if(next){next.prev=this;this.next=next;}else {this.next=null;}}try{// add if support for Symbol.iterator is present
4660
4726
  require('./iterator.js')(Yallist);}catch(er){}},{"./iterator.js":82}]},{},[12])(12);});})(mqtt$1);var mqtt = /*@__PURE__*/getDefaultExportFromCjs(mqtt$1.exports);
4661
4727
 
4728
+ class SessionWatcher {
4729
+ constructor() {
4730
+ this._sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
4731
+ this._listener = new Map();
4732
+ }
4733
+ onSessionStateChange(callback) {
4734
+ this._listener.set(callback, callback);
4735
+ return () => {
4736
+ this._listener.delete(callback);
4737
+ };
4738
+ }
4739
+ setSessionState(state, reason) {
4740
+ if (this._sessionState === state)
4741
+ return;
4742
+ this._sessionState = state;
4743
+ this._listener.forEach(cb => cb(state, reason));
4744
+ }
4745
+ destroy() {
4746
+ this._listener.clear();
4747
+ }
4748
+ }
4749
+ let instance$a;
4750
+ var SessionWatcher$1 = {
4751
+ getInstance: () => {
4752
+ if (!instance$a) {
4753
+ instance$a = new SessionWatcher();
4754
+ }
4755
+ return instance$a;
4756
+ },
4757
+ };
4758
+
4759
+ /**
4760
+ * ```js
4761
+ * import { onSessionStateChange } from '@amityco/ts-sdk'
4762
+ * const dispose = onSessionStateChange((state: Amity.SessionStates) => {
4763
+ * // ...
4764
+ * })
4765
+ * ```
4766
+ *
4767
+ * Fired when any {@link Amity.Client} has a session state change
4768
+ *
4769
+ * @param callback The function to call when the event was fired
4770
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
4771
+ *
4772
+ * @category Client Events
4773
+ */
4774
+ const onSessionStateChange = (callback) => SessionWatcher$1.getInstance().onSessionStateChange(callback);
4775
+
4776
+ const TOPICS = {
4777
+ [exports.AmityAutoSubscription.NETWORK]: [getNetworkTopic],
4778
+ [exports.AmityAutoSubscription.CHAT]: [
4779
+ getSmartFeedChannelTopic,
4780
+ getSmartFeedSubChannelTopic,
4781
+ getSmartFeedMessageTopic,
4782
+ ],
4783
+ [exports.AmityAutoSubscription.LIVESTREAM]: [getLiveStreamTopic],
4784
+ [exports.AmityAutoSubscription.BLOCK]: [getMyFollowersTopic, getMyFollowingsTopic],
4785
+ };
4786
+ const DEFAULT_TOPICS = [
4787
+ exports.AmityAutoSubscription.CHAT,
4788
+ exports.AmityAutoSubscription.NETWORK,
4789
+ exports.AmityAutoSubscription.LIVESTREAM,
4790
+ exports.AmityAutoSubscription.BLOCK,
4791
+ ];
4792
+ const ALL_FEATURES = Object.values(exports.AmityAutoSubscription);
4793
+ /** Ref-counted, reconnect-resilient registry of the managed auto-subscriptions. */
4794
+ class AutoSubscriptionManager {
4795
+ constructor() {
4796
+ this.refCountByFeature = new Map();
4797
+ this.disposers = new Map();
4798
+ this.seed();
4799
+ }
4800
+ seed() {
4801
+ this.refCountByFeature.clear();
4802
+ DEFAULT_TOPICS.forEach(feature => this.refCountByFeature.set(feature, 1));
4803
+ }
4804
+ isActive(feature) {
4805
+ var _a;
4806
+ return ((_a = this.refCountByFeature.get(feature)) !== null && _a !== void 0 ? _a : 0) > 0;
4807
+ }
4808
+ subscribeTopics(feature) {
4809
+ this.unsubscribeTopics(feature);
4810
+ this.disposers.set(feature, TOPICS[feature].map(buildTopic => subscribeTopic(buildTopic())));
4811
+ }
4812
+ unsubscribeTopics(feature) {
4813
+ var _a;
4814
+ ((_a = this.disposers.get(feature)) !== null && _a !== void 0 ? _a : []).forEach(dispose => dispose());
4815
+ this.disposers.delete(feature);
4816
+ }
4817
+ /** Subscribe every enabled handle's topics, converging the broker to the registry. Called on each (re)connect. */
4818
+ initialize() {
4819
+ ALL_FEATURES.forEach(feature => {
4820
+ if (this.isActive(feature))
4821
+ this.subscribeTopics(feature);
4822
+ });
4823
+ }
4824
+ subscribe(feature) {
4825
+ var _a;
4826
+ const next = ((_a = this.refCountByFeature.get(feature)) !== null && _a !== void 0 ? _a : 0) + 1;
4827
+ this.refCountByFeature.set(feature, next);
4828
+ if (next === 1)
4829
+ this.subscribeTopics(feature);
4830
+ }
4831
+ unsubscribe(feature) {
4832
+ var _a;
4833
+ const next = Math.max(0, ((_a = this.refCountByFeature.get(feature)) !== null && _a !== void 0 ? _a : 0) - 1);
4834
+ this.refCountByFeature.set(feature, next);
4835
+ if (next === 0)
4836
+ this.unsubscribeTopics(feature);
4837
+ }
4838
+ subscriptions() {
4839
+ return ALL_FEATURES.map(feature => ({
4840
+ feature,
4841
+ isActive: this.isActive(feature),
4842
+ isSystem: true,
4843
+ topicCount: TOPICS[feature].length,
4844
+ }));
4845
+ }
4846
+ reset() {
4847
+ ALL_FEATURES.forEach(feature => this.unsubscribeTopics(feature));
4848
+ this.disposers.clear();
4849
+ this.seed();
4850
+ }
4851
+ }
4852
+ let instance$9 = null;
4853
+ const getAutoSubscriptionManager = () => {
4854
+ if (!instance$9)
4855
+ instance$9 = new AutoSubscriptionManager();
4856
+ return instance$9;
4857
+ };
4858
+ /** Resets the registry to its default baseline when the session ends. */
4859
+ const resetAutoSubscriptionsOnLogout = () => onSessionStateChange(state => {
4860
+ if (state !== "established" /* Amity.SessionStates.ESTABLISHED */)
4861
+ getAutoSubscriptionManager().reset();
4862
+ });
4863
+
4864
+ /**
4865
+ * (Re)subscribes the managed auto-subscription registry on every (re)connect.
4866
+ * The hardcoded topic list was promoted to the toggleable, ref-counted registry
4867
+ * in {@link getAutoSubscriptionManager} — see `client.manageAutoSubscriptions`.
4868
+ */
4662
4869
  const subscribeGlobalTopic = () => {
4663
- const disposers = [
4664
- subscribeTopic(getNetworkTopic()),
4665
- subscribeTopic(getSmartFeedChannelTopic()),
4666
- subscribeTopic(getSmartFeedSubChannelTopic()),
4667
- subscribeTopic(getSmartFeedMessageTopic()),
4668
- // subscribing to user topic is necessary to handle ban event
4669
- subscribeTopic(getUserTopic(getActiveUser())),
4670
- subscribeTopic(getMarkerUserFeedTopic()),
4671
- subscribeTopic(getLiveStreamTopic()),
4672
- ];
4673
- return () => disposers.forEach(fn => fn());
4870
+ getAutoSubscriptionManager().initialize();
4674
4871
  };
4675
4872
 
4676
4873
  class OnMemoryStorage {
@@ -5864,7 +6061,7 @@ getSubChannel$1.locally = (subChannelId) => {
5864
6061
  };
5865
6062
  };
5866
6063
 
5867
- const getMessagePreviewSetting$1 = async () => {
6064
+ const getMessagePreviewSetting$2 = async () => {
5868
6065
  const client = getActiveClient();
5869
6066
  return client.getMessagePreviewSetting(false);
5870
6067
  };
@@ -5899,7 +6096,7 @@ const isLastestMessageOnChannel = (message) => {
5899
6096
  convertDateStringToTimestamp(cache.createdAt) <= convertDateStringToTimestamp(message.createdAt));
5900
6097
  };
5901
6098
  const handleMessageCreatedOnSubChannel = async (message) => {
5902
- const messagePreviewSetting = await getMessagePreviewSetting$1();
6099
+ const messagePreviewSetting = await getMessagePreviewSetting$2();
5903
6100
  const { channelId, messageId: messagePreviewId, creatorId, createdAt, updatedAt, data, dataType, subChannelId, channelSegment: segment, isDeleted, } = message;
5904
6101
  // 1. get subChannel from cache, if not exist fetch from server
5905
6102
  const subChannelCache = await getSubChannelCache(subChannelId);
@@ -7079,54 +7276,6 @@ getChannelByIds$1.locally = (channelIds) => {
7079
7276
  };
7080
7277
  };
7081
7278
 
7082
- class SessionWatcher {
7083
- constructor() {
7084
- this._sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
7085
- this._listener = new Map();
7086
- }
7087
- onSessionStateChange(callback) {
7088
- this._listener.set(callback, callback);
7089
- return () => {
7090
- this._listener.delete(callback);
7091
- };
7092
- }
7093
- setSessionState(state, reason) {
7094
- if (this._sessionState === state)
7095
- return;
7096
- this._sessionState = state;
7097
- this._listener.forEach(cb => cb(state, reason));
7098
- }
7099
- destroy() {
7100
- this._listener.clear();
7101
- }
7102
- }
7103
- let instance$8;
7104
- var SessionWatcher$1 = {
7105
- getInstance: () => {
7106
- if (!instance$8) {
7107
- instance$8 = new SessionWatcher();
7108
- }
7109
- return instance$8;
7110
- },
7111
- };
7112
-
7113
- /**
7114
- * ```js
7115
- * import { onSessionStateChange } from '@amityco/ts-sdk'
7116
- * const dispose = onSessionStateChange((state: Amity.SessionStates) => {
7117
- * // ...
7118
- * })
7119
- * ```
7120
- *
7121
- * Fired when any {@link Amity.Client} has a session state change
7122
- *
7123
- * @param callback The function to call when the event was fired
7124
- * @returns an {@link Amity.Unsubscriber} function to stop listening
7125
- *
7126
- * @category Client Events
7127
- */
7128
- const onSessionStateChange = (callback) => SessionWatcher$1.getInstance().onSessionStateChange(callback);
7129
-
7130
7279
  const setIntervalTask = (handler, timeout) => {
7131
7280
  const timer = setInterval(handler, timeout);
7132
7281
  return () => clearInterval(timer);
@@ -7298,7 +7447,7 @@ const convertMessagePreviewSetting = (chatSetting) => {
7298
7447
  * @category private
7299
7448
  * @async
7300
7449
  */
7301
- const getMessagePreviewSetting = async (refresh = true) => {
7450
+ const getMessagePreviewSetting$1 = async (refresh = true) => {
7302
7451
  var _a;
7303
7452
  const messagePreviewSetting = (_a = pullFromCache([
7304
7453
  'MessagePreviewSetting',
@@ -7319,7 +7468,7 @@ const getMessagePreviewSetting = async (refresh = true) => {
7319
7468
  */
7320
7469
  const initializeMessagePreviewSetting = async () => {
7321
7470
  var _a;
7322
- const newMessagePreviewSetting = await getMessagePreviewSetting();
7471
+ const newMessagePreviewSetting = await getMessagePreviewSetting$1();
7323
7472
  const messagePreviewSetting = (_a = pullFromCache([
7324
7473
  'MessagePreviewSetting',
7325
7474
  ])) === null || _a === void 0 ? void 0 : _a.data;
@@ -7390,6 +7539,26 @@ const getSocialSettings = async () => {
7390
7539
  return data.socialNetworkSetting;
7391
7540
  };
7392
7541
 
7542
+ /**
7543
+ * ```js
7544
+ * import { createClient } from '@amityco/ts-sdk'
7545
+ * const client = createClient(apiKey, apiRegion)
7546
+ * const userSettings = await client.getCoreUserSettings()
7547
+ * ```
7548
+ *
7549
+ * Fetches a {@link Amity.CoreUserSettings} object
7550
+ *
7551
+ * @returns A Promise of {@link Amity.CoreUserSettings} object
7552
+ *
7553
+ * @category Client API
7554
+ * @async
7555
+ */
7556
+ const getCoreUserSettings = async () => {
7557
+ const client = getActiveClient();
7558
+ const { data } = await client.http.get(`/api/v3/network-settings/users`);
7559
+ return data;
7560
+ };
7561
+
7393
7562
  /* begin_public_function
7394
7563
  id: client.getProductCatalogueSetting
7395
7564
  */
@@ -7413,6 +7582,33 @@ const getProductCatalogueSetting = async () => {
7413
7582
  };
7414
7583
  /* end_public_function */
7415
7584
 
7585
+ /* begin_public_function
7586
+ id: client.getForYouFeedSetting
7587
+ */
7588
+ /**
7589
+ * ```js
7590
+ * import { Client } from '@amityco/ts-sdk'
7591
+ * const forYouFeedSetting = await Client.getForYouFeedSetting()
7592
+ * ```
7593
+ *
7594
+ * Fetches the network-level {@link Amity.ForYouFeedSetting} — whether the For You
7595
+ * feed feature is enabled for the current network. Use `forYouFeed.enabled` as a
7596
+ * feature gate before querying {@link getForYouFeed}.
7597
+ *
7598
+ * @returns A Promise of {@link Amity.ForYouFeedSetting} object
7599
+ *
7600
+ * @category Client API
7601
+ * @async
7602
+ */
7603
+ const getForYouFeedSetting = async () => {
7604
+ var _a, _b;
7605
+ const client = getActiveClient();
7606
+ const { data } = await client.http.get(`/api/v3/network-settings/for-you-feed`);
7607
+ // Surface only `enabled`; ignore server-side ranking config (scoringConfig, etc.)
7608
+ return { forYouFeed: { enabled: (_b = (_a = data.forYouFeed) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false } };
7609
+ };
7610
+ /* end_public_function */
7611
+
7416
7612
  const checkUserPermission = (userId, permission) => {
7417
7613
  var _a;
7418
7614
  const user = (_a = pullFromCache(['user', 'get', userId])) === null || _a === void 0 ? void 0 : _a.data;
@@ -8200,13 +8396,13 @@ class AnalyticsEngine {
8200
8396
  this._eventCapturer.resetAllBuckets();
8201
8397
  }
8202
8398
  }
8203
- let instance$7;
8399
+ let instance$8;
8204
8400
  var AnalyticsEngine$1 = {
8205
8401
  getInstance: () => {
8206
- if (!instance$7) {
8207
- instance$7 = new AnalyticsEngine();
8402
+ if (!instance$8) {
8403
+ instance$8 = new AnalyticsEngine();
8208
8404
  }
8209
- return instance$7;
8405
+ return instance$8;
8210
8406
  },
8211
8407
  };
8212
8408
 
@@ -8433,12 +8629,12 @@ class MessageReadReceiptSyncEngine {
8433
8629
  }
8434
8630
  }
8435
8631
  }
8436
- let instance$6 = null;
8632
+ let instance$7 = null;
8437
8633
  var ReadReceiptSyncEngine = {
8438
8634
  getInstance: () => {
8439
- if (!instance$6)
8440
- instance$6 = new MessageReadReceiptSyncEngine();
8441
- return instance$6;
8635
+ if (!instance$7)
8636
+ instance$7 = new MessageReadReceiptSyncEngine();
8637
+ return instance$7;
8442
8638
  },
8443
8639
  };
8444
8640
 
@@ -8692,12 +8888,12 @@ class LegacyMessageReadReceiptSyncEngine {
8692
8888
  }
8693
8889
  }
8694
8890
  }
8695
- let instance$5 = null;
8891
+ let instance$6 = null;
8696
8892
  var LegacyReadReceiptSyncEngine = {
8697
8893
  getInstance: () => {
8698
- if (!instance$5)
8699
- instance$5 = new LegacyMessageReadReceiptSyncEngine();
8700
- return instance$5;
8894
+ if (!instance$6)
8895
+ instance$6 = new LegacyMessageReadReceiptSyncEngine();
8896
+ return instance$6;
8701
8897
  },
8702
8898
  };
8703
8899
 
@@ -8943,12 +9139,12 @@ class ObjectResolverEngine {
8943
9139
  this.stopResolver();
8944
9140
  }
8945
9141
  }
8946
- let instance$4 = null;
9142
+ let instance$5 = null;
8947
9143
  var ObjectResolverEngine$1 = {
8948
9144
  getInstance: () => {
8949
- if (!instance$4)
8950
- instance$4 = new ObjectResolverEngine();
8951
- return instance$4;
9145
+ if (!instance$5)
9146
+ instance$5 = new ObjectResolverEngine();
9147
+ return instance$5;
8952
9148
  },
8953
9149
  };
8954
9150
 
@@ -9098,13 +9294,13 @@ class LiveReactionSyncEngine {
9098
9294
  this.stopReactionsSync();
9099
9295
  }
9100
9296
  }
9101
- let instance$3;
9297
+ let instance$4;
9102
9298
  var ReactionSyncEngine = {
9103
9299
  getInstance: () => {
9104
- if (!instance$3) {
9105
- instance$3 = new LiveReactionSyncEngine();
9300
+ if (!instance$4) {
9301
+ instance$4 = new LiveReactionSyncEngine();
9106
9302
  }
9107
- return instance$3;
9303
+ return instance$4;
9108
9304
  },
9109
9305
  };
9110
9306
 
@@ -9134,19 +9330,20 @@ function prepareBlockedUserPayload(response) {
9134
9330
  }), users: users.map(convertRawUserToInternalUser) });
9135
9331
  }
9136
9332
 
9137
- const BLOCK_LIST_LIMIT = 100;
9138
- const TTL_MS = 5 * 60 * 1000; // 5 minutes
9333
+ const BLOCK_LIST_LIMIT$1 = 100;
9334
+ const TTL_MS$1 = 5 * 60 * 1000; // 5 minutes
9139
9335
  /**
9140
9336
  * Session-scoped singleton engine that manages TTL-based fetching and caching
9141
9337
  * of blocked users. Provides a lazy `ensureFetched()` gate for the
9142
9338
  * `getAllBlockedUsers()` API.
9143
9339
  *
9144
9340
  * Key behaviours:
9145
- * - `establish()` is a no-op — fetch is lazy, triggered only by consumer call
9146
- * - `destroy()` resets `lastFetchedAt` to null (ensures fresh fetch on next session)
9341
+ * - `onSessionEstablished()` is a no-op — fetch is lazy, triggered only by consumer call
9342
+ * - `onSessionDestroyed()` resets `lastFetchedAt` to null (ensures fresh fetch on next session)
9147
9343
  * - `ensureFetched()` fetches from server only when cache is expired or never fetched
9148
9344
  * - `lastFetchedAt` is only updated on successful fetch
9149
- * - `blockedUserIds` is kept in sync with each successful fetch
9345
+ * - reads query the follow cache live, so block/unblock changes are reflected
9346
+ * even within the TTL window
9150
9347
  *
9151
9348
  * @internal
9152
9349
  */
@@ -9154,12 +9351,7 @@ class BlockedUserSyncEngine {
9154
9351
  constructor() {
9155
9352
  /** Epoch ms of last successful fetch. null = never fetched in this session. */
9156
9353
  this.lastFetchedAt = null;
9157
- /** Ordered list of userId strings from the most recent successful fetch. */
9158
- this.blockedUserIds = [];
9159
9354
  }
9160
- // ---------------------------------------------------------------------------
9161
- // SessionComponent lifecycle
9162
- // ---------------------------------------------------------------------------
9163
9355
  /** No-op — fetch is lazy, triggered by consumer calling getAllBlockedUsers(). */
9164
9356
  // eslint-disable-next-line class-methods-use-this
9165
9357
  onSessionEstablished() {
@@ -9168,24 +9360,17 @@ class BlockedUserSyncEngine {
9168
9360
  /** Resets state so the next session starts with a cold cache. */
9169
9361
  onSessionDestroyed() {
9170
9362
  this.lastFetchedAt = null;
9171
- this.blockedUserIds = [];
9172
9363
  }
9173
9364
  /** No-op for this engine. */
9174
9365
  // eslint-disable-next-line class-methods-use-this
9175
9366
  onTokenExpired() {
9176
9367
  // intentionally empty
9177
9368
  }
9178
- // ---------------------------------------------------------------------------
9179
- // Cache helpers
9180
- // ---------------------------------------------------------------------------
9181
9369
  isCacheExpired() {
9182
9370
  if (this.lastFetchedAt === null)
9183
9371
  return true;
9184
- return Date.now() - this.lastFetchedAt > TTL_MS;
9372
+ return Date.now() - this.lastFetchedAt > TTL_MS$1;
9185
9373
  }
9186
- // ---------------------------------------------------------------------------
9187
- // Core fetch gate
9188
- // ---------------------------------------------------------------------------
9189
9374
  /**
9190
9375
  * Ensures the local store is populated with fresh blocked-user data.
9191
9376
  *
@@ -9201,52 +9386,50 @@ class BlockedUserSyncEngine {
9201
9386
  if (!this.isCacheExpired())
9202
9387
  return;
9203
9388
  const client = getActiveClient();
9204
- const { data } = await client.http.get('/api/v4/me/user-blocks', { params: { options: { limit: BLOCK_LIST_LIMIT }, isDeleted: false } });
9389
+ const { data } = await client.http.get('/api/v4/me/user-blocks', { params: { options: { limit: BLOCK_LIST_LIMIT$1 }, isDeleted: false } });
9205
9390
  const cachedAt = client.cache && Date.now();
9206
9391
  const payload = prepareBlockedUserPayload(data);
9207
9392
  if (client.cache) {
9208
9393
  ingestInCache(payload, { cachedAt });
9209
9394
  }
9210
- // Keep the ordered list of blocked user IDs for getCachedUsers()
9211
- this.blockedUserIds = payload.users.map(u => u.userId);
9212
9395
  // Only update timestamp on success — failure leaves it unchanged so the
9213
9396
  // next call retries.
9214
9397
  this.lastFetchedAt = Date.now();
9215
9398
  }
9216
- // ---------------------------------------------------------------------------
9217
- // Local store read
9218
- // ---------------------------------------------------------------------------
9219
9399
  /**
9220
- * Returns blocked {@link Amity.InternalUser} objects from the in-memory cache.
9221
- *
9222
- * Applies the spec-mandated filter:
9223
- * - Only users whose `isDeleted` is false or null
9224
- * - Hard limit of 100 results
9400
+ * Returns the blocked users by querying the follow cache live — the outgoing
9401
+ * direction (`from === me`, `status === 'blocked'`). Reading the cache (not a
9402
+ * fetched snapshot) means `blockUser()` / `unblockUser()` changes are reflected
9403
+ * even within the TTL window.
9225
9404
  *
9226
- * This always reads the latest local state, so changes made by `blockUser()`
9227
- * and `unblockUser()` are reflected even within the TTL window.
9405
+ * Applies the spec-mandated query:
9406
+ * - filter `from === currentUserId`, `status === 'blocked'`, blocked user not deleted
9407
+ * - sort by `updatedAt` DESC
9408
+ * - hard limit of 100 results
9228
9409
  */
9410
+ // eslint-disable-next-line class-methods-use-this
9229
9411
  getCachedUsers() {
9412
+ var _a;
9230
9413
  const client = getActiveClient();
9231
- if (!client.cache) {
9232
- // No cache available — fall back to the in-memory list from the last fetch
9414
+ if (!client.cache)
9233
9415
  return [];
9234
- }
9235
- return this.blockedUserIds
9236
- .map(id => { var _a; return (_a = pullFromCache(['user', 'get', id])) === null || _a === void 0 ? void 0 : _a.data; })
9416
+ const { userId } = client;
9417
+ return ((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
9418
+ .map(entry => entry.data)
9419
+ .filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'blocked' && follow.from === userId)
9420
+ .sort((a, b) => { var _a, _b; return (((_a = a.updatedAt) !== null && _a !== void 0 ? _a : '') < ((_b = b.updatedAt) !== null && _b !== void 0 ? _b : '') ? 1 : -1); })
9421
+ .map(follow => { var _a; return (_a = pullFromCache(['user', 'get', follow.to])) === null || _a === void 0 ? void 0 : _a.data; })
9237
9422
  .filter((user) => user != null && user.isDeleted !== true)
9238
- .slice(0, BLOCK_LIST_LIMIT);
9423
+ .slice(0, BLOCK_LIST_LIMIT$1)
9424
+ .map(userLinkedObject);
9239
9425
  }
9240
9426
  }
9241
- // ---------------------------------------------------------------------------
9242
- // Module-level singleton
9243
- // ---------------------------------------------------------------------------
9244
- let instance$2 = null;
9427
+ let instance$3 = null;
9245
9428
  var BlockedUserSyncEngine$1 = {
9246
9429
  getInstance: () => {
9247
- if (!instance$2)
9248
- instance$2 = new BlockedUserSyncEngine();
9249
- return instance$2;
9430
+ if (!instance$3)
9431
+ instance$3 = new BlockedUserSyncEngine();
9432
+ return instance$3;
9250
9433
  },
9251
9434
  };
9252
9435
 
@@ -9268,6 +9451,224 @@ var blockedUserSyncEngineOnLoginHandler = () => {
9268
9451
  };
9269
9452
  };
9270
9453
 
9454
+ function prepareBlockingUserPayload(response) {
9455
+ const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
9456
+ return Object.assign(Object.assign({}, rest), { follows: follows.map(follow => {
9457
+ const followUser = users.find(user => user.userId === follow.from);
9458
+ return Object.assign(Object.assign({}, follow), { user: convertRawUserToInternalUser(followUser) });
9459
+ }), users: users.map(convertRawUserToInternalUser) });
9460
+ }
9461
+
9462
+ const BLOCK_LIST_LIMIT = 100;
9463
+ const TTL_MS = 5 * 60 * 1000; // 5 minutes
9464
+ /**
9465
+ * Session-scoped singleton engine that manages TTL-based fetching and caching
9466
+ * of blocking users (the "blocked-by" list — users who blocked the current
9467
+ * user). Provides a lazy `ensureFetched()` gate for the `getAllBlockingUsers()`
9468
+ * API. Directional inverse of {@link BlockedUserSyncEngine}.
9469
+ *
9470
+ * Key behaviours:
9471
+ * - `onSessionEstablished()` is a no-op — fetch is lazy, triggered only by consumer call
9472
+ * - `onSessionDestroyed()` resets `lastFetchedAt` to null (ensures fresh fetch on next session)
9473
+ * - `ensureFetched()` fetches from server only when cache is expired or never fetched
9474
+ * - `lastFetchedAt` is only updated on successful fetch
9475
+ * - reads query the follow cache live, so block/unblock changes are reflected
9476
+ * even within the TTL window
9477
+ *
9478
+ * @internal
9479
+ */
9480
+ class BlockingUserSyncEngine {
9481
+ constructor() {
9482
+ /** Epoch ms of last successful fetch. null = never fetched in this session. */
9483
+ this.lastFetchedAt = null;
9484
+ }
9485
+ /** No-op — fetch is lazy, triggered by consumer calling getAllBlockingUsers(). */
9486
+ // eslint-disable-next-line class-methods-use-this
9487
+ onSessionEstablished() {
9488
+ // intentionally empty
9489
+ }
9490
+ /** Resets state so the next session starts with a cold cache. */
9491
+ onSessionDestroyed() {
9492
+ this.lastFetchedAt = null;
9493
+ }
9494
+ /** No-op for this engine. */
9495
+ // eslint-disable-next-line class-methods-use-this
9496
+ onTokenExpired() {
9497
+ // intentionally empty
9498
+ }
9499
+ isCacheExpired() {
9500
+ if (this.lastFetchedAt === null)
9501
+ return true;
9502
+ return Date.now() - this.lastFetchedAt > TTL_MS;
9503
+ }
9504
+ /**
9505
+ * Ensures the local store is populated with fresh blocking-user data.
9506
+ *
9507
+ * - If the cache is still within the 5-minute TTL window: resolves immediately
9508
+ * (no server call).
9509
+ * - If the cache is expired (or never fetched): fetches from the server,
9510
+ * persists the payload to the cache, and updates `lastFetchedAt`.
9511
+ *
9512
+ * On failure the error propagates to the caller and `lastFetchedAt` is NOT
9513
+ * updated, so the next call will retry.
9514
+ */
9515
+ async ensureFetched() {
9516
+ if (!this.isCacheExpired())
9517
+ return;
9518
+ const client = getActiveClient();
9519
+ const { data } = await client.http.get('/api/v4/me/blockers', { params: { options: { limit: BLOCK_LIST_LIMIT }, isDeleted: false } });
9520
+ const cachedAt = client.cache && Date.now();
9521
+ const payload = prepareBlockingUserPayload(data);
9522
+ if (client.cache) {
9523
+ ingestInCache(payload, { cachedAt });
9524
+ }
9525
+ // Only update timestamp on success — failure leaves it unchanged so the
9526
+ // next call retries.
9527
+ this.lastFetchedAt = Date.now();
9528
+ }
9529
+ /**
9530
+ * Returns the "blocked-by" users by querying the follow cache live — the
9531
+ * incoming direction (`to === me`, `status === 'blocked'`). Reading the cache
9532
+ * (not a fetched snapshot) means RTE `user.didBlock` / `user.didUnblock`
9533
+ * changes are reflected even within the TTL window.
9534
+ *
9535
+ * Applies the spec-mandated query (REQ-012/013/014):
9536
+ * - filter `to === currentUserId`, `status === 'blocked'`, blocker not deleted
9537
+ * - sort by `updatedAt` DESC
9538
+ * - hard limit of 100 results
9539
+ */
9540
+ // eslint-disable-next-line class-methods-use-this
9541
+ getCachedUsers() {
9542
+ var _a;
9543
+ const client = getActiveClient();
9544
+ if (!client.cache)
9545
+ return [];
9546
+ const { userId } = client;
9547
+ return ((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
9548
+ .map(entry => entry.data)
9549
+ .filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'blocked' && follow.to === userId)
9550
+ .sort((a, b) => { var _a, _b; return (((_a = a.updatedAt) !== null && _a !== void 0 ? _a : '') < ((_b = b.updatedAt) !== null && _b !== void 0 ? _b : '') ? 1 : -1); })
9551
+ .map(follow => { var _a; return (_a = pullFromCache(['user', 'get', follow.from])) === null || _a === void 0 ? void 0 : _a.data; })
9552
+ .filter((user) => user != null && user.isDeleted !== true)
9553
+ .slice(0, BLOCK_LIST_LIMIT)
9554
+ .map(userLinkedObject);
9555
+ }
9556
+ }
9557
+ let instance$2 = null;
9558
+ var BlockingUserSyncEngine$1 = {
9559
+ getInstance: () => {
9560
+ if (!instance$2)
9561
+ instance$2 = new BlockingUserSyncEngine();
9562
+ return instance$2;
9563
+ },
9564
+ };
9565
+
9566
+ var blockingUserSyncEngineOnLoginHandler = () => {
9567
+ const blockingUserSyncEngine = BlockingUserSyncEngine$1.getInstance();
9568
+ onSessionStateChange(state => {
9569
+ if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
9570
+ blockingUserSyncEngine.onSessionEstablished();
9571
+ }
9572
+ else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
9573
+ blockingUserSyncEngine.onTokenExpired();
9574
+ }
9575
+ else {
9576
+ blockingUserSyncEngine.onSessionDestroyed();
9577
+ }
9578
+ });
9579
+ return () => {
9580
+ blockingUserSyncEngine.onSessionDestroyed();
9581
+ };
9582
+ };
9583
+
9584
+ function prepareFollowersPayload(response) {
9585
+ const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
9586
+ return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
9587
+ }
9588
+ function prepareFollowingsPayload(response) {
9589
+ const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
9590
+ return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
9591
+ }
9592
+ function prepareFollowStatusPayload(response) {
9593
+ const { follows } = response, rest = __rest(response, ["follows"]);
9594
+ return Object.assign(Object.assign({}, rest), { follows });
9595
+ }
9596
+
9597
+ /**
9598
+ * Subscribes to a block MQTT event (`user.didBlock` / `user.didUnblock`),
9599
+ * ingests the carried `FollowersPayload` (follows + users) into the cache so
9600
+ * the block-relationship rows (`['follow', 'get', from#to]`) and user rows are
9601
+ * kept current, then forwards the affected {@link Amity.FollowStatus} to the
9602
+ * caller.
9603
+ *
9604
+ * @hidden
9605
+ */
9606
+ const createBlockEventSubscriber = (event, callback) => {
9607
+ const client = getActiveClient();
9608
+ const filter = (data) => {
9609
+ const payload = prepareFollowersPayload(data);
9610
+ if (client.cache) {
9611
+ ingestInCache(payload);
9612
+ }
9613
+ callback(payload.follows[0]);
9614
+ };
9615
+ return createEventSubscriber(client, event, event, filter);
9616
+ };
9617
+
9618
+ /**
9619
+ * ```js
9620
+ * import { onUserDidBlock } from '@amityco/ts-sdk'
9621
+ * const dispose = onUserDidBlock(status => {
9622
+ * // ...
9623
+ * })
9624
+ * ```
9625
+ *
9626
+ * Fired when a block relationship is created in real time — either a user
9627
+ * blocks the current user (incoming) or the current user blocks someone on
9628
+ * another device (outgoing). The local block-relationship store is updated
9629
+ * before the callback runs.
9630
+ *
9631
+ * @param callback The function to call when the event was fired
9632
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
9633
+ *
9634
+ * @category Block Events
9635
+ */
9636
+ const onUserDidBlock = (callback) => createBlockEventSubscriber('user.didBlock', callback);
9637
+
9638
+ /**
9639
+ * ```js
9640
+ * import { onUserDidUnblock } from '@amityco/ts-sdk'
9641
+ * const dispose = onUserDidUnblock(status => {
9642
+ * // ...
9643
+ * })
9644
+ * ```
9645
+ *
9646
+ * Fired when a block relationship is removed in real time — either a user
9647
+ * unblocks the current user (incoming) or the current user unblocks someone on
9648
+ * another device (outgoing). The local block-relationship store is updated
9649
+ * before the callback runs.
9650
+ *
9651
+ * @param callback The function to call when the event was fired
9652
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
9653
+ *
9654
+ * @category Block Events
9655
+ */
9656
+ const onUserDidUnblock = (callback) => createBlockEventSubscriber('user.didUnblock', callback);
9657
+
9658
+ /**
9659
+ * Keeps the follow cache current for incoming/outgoing block changes for the
9660
+ * whole session — the ingest happens as a side effect inside
9661
+ * createBlockEventSubscriber, so the one-shot `getAllBlockedUsers()` /
9662
+ * `getAllBlockingUsers()` reflect RTE block/unblock within the TTL window.
9663
+ *
9664
+ * Registered via `setupLoginSubscriptions`; the returned unsubscriber is torn
9665
+ * down on logout.
9666
+ */
9667
+ var blockRealtimeOnLoginHandler = () => {
9668
+ const disposers = [onUserDidBlock(() => { }), onUserDidUnblock(() => { })];
9669
+ return () => disposers.forEach(dispose => dispose());
9670
+ };
9671
+
9271
9672
  class CursorController {
9272
9673
  constructor(networkId, userId) {
9273
9674
  this.networkId = networkId;
@@ -9307,7 +9708,11 @@ class CursorController {
9307
9708
  const parsed = JSON.parse(raw);
9308
9709
  if (typeof (parsed === null || parsed === void 0 ? void 0 : parsed.cursor) !== 'string' || typeof (parsed === null || parsed === void 0 ? void 0 : parsed.expiredAt) !== 'number')
9309
9710
  return null;
9310
- return { cursor: parsed.cursor, expiredAt: parsed.expiredAt };
9711
+ return {
9712
+ cursor: parsed.cursor,
9713
+ expiredAt: parsed.expiredAt,
9714
+ reachedEndOfFeed: parsed.reachedEndOfFeed === true,
9715
+ };
9311
9716
  }
9312
9717
  catch (_a) {
9313
9718
  return null;
@@ -9316,6 +9721,15 @@ class CursorController {
9316
9721
  async set(value) {
9317
9722
  await setItem(this.key, JSON.stringify(value));
9318
9723
  }
9724
+ async markReachedEndOfFeed(expiredAt) {
9725
+ var _a;
9726
+ const stored = await this.get();
9727
+ await this.set({
9728
+ cursor: (_a = stored === null || stored === void 0 ? void 0 : stored.cursor) !== null && _a !== void 0 ? _a : '',
9729
+ expiredAt,
9730
+ reachedEndOfFeed: true,
9731
+ });
9732
+ }
9319
9733
  async clear() {
9320
9734
  await setItem(this.key, '');
9321
9735
  }
@@ -9510,7 +9924,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
9510
9924
  // NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
9511
9925
  // the channel because currently backend can't handle this, so every time a user is banned from
9512
9926
  // a channel or the channel is deleted the channel's unread count will not be reset to zero
9513
- onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), CursorController.clearOnLogout());
9927
+ onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout());
9514
9928
  if (client.useLegacyUnreadCount) {
9515
9929
  subscriptions.push(readReceiptSyncEngineOnLoginHandler());
9516
9930
  }
@@ -10591,14 +11005,17 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
10591
11005
  validateUrls,
10592
11006
  validateTexts,
10593
11007
  getFeedSettings,
11008
+ getCoreUserSettings,
10594
11009
  getSocialSettings,
11010
+ getChatSettings,
10595
11011
  getVisitorDeviceId: getDeviceId,
10596
- getMessagePreviewSetting,
11012
+ getMessagePreviewSetting: getMessagePreviewSetting$1,
10597
11013
  use: () => setActiveClient(client),
10598
11014
  isUnreadCountEnabled,
10599
11015
  useLegacyUnreadCount,
10600
11016
  getMarkerSyncConsistentMode,
10601
11017
  getProductCatalogueSetting,
11018
+ getForYouFeedSetting,
10602
11019
  /**
10603
11020
  * Prefix for the deviceId key in the local storage or async storage.
10604
11021
  * This is allow user to have multiple SDK client and Mqtt client within the same app.
@@ -11235,6 +11652,71 @@ class Notifications {
11235
11652
  }
11236
11653
  const notifications = () => new Notifications();
11237
11654
 
11655
+ /* begin_public_function
11656
+ id: client.enable_auto_subscriptions
11657
+ */
11658
+ /**
11659
+ * ```js
11660
+ * import { Client, AmityAutoSubscription } from '@amityco/ts-sdk'
11661
+ * Client.enableAutoSubscriptions([AmityAutoSubscription.BLOCK])
11662
+ * ```
11663
+ *
11664
+ * Enables one or more managed auto-subscription handles. Managed handles are
11665
+ * re-applied on every (re)connect and ref-counted. All handles are on by
11666
+ * default; use this to re-enable handles previously turned off via
11667
+ * {@link disableAutoSubscriptions}. Synchronous fire-and-forget — the registry
11668
+ * updates immediately and the broker subscribe is retried on reconnect.
11669
+ *
11670
+ * @param features the {@link AmityAutoSubscription} handles to enable
11671
+ *
11672
+ * @category Client API
11673
+ */
11674
+ const enableAutoSubscriptions = (features) => {
11675
+ const manager = getAutoSubscriptionManager();
11676
+ features.forEach(feature => manager.subscribe(feature));
11677
+ };
11678
+ /* end_public_function */
11679
+ /* begin_public_function
11680
+ id: client.disable_auto_subscriptions
11681
+ */
11682
+ /**
11683
+ * ```js
11684
+ * import { Client, AmityAutoSubscription } from '@amityco/ts-sdk'
11685
+ * Client.disableAutoSubscriptions([AmityAutoSubscription.LIVESTREAM])
11686
+ * ```
11687
+ *
11688
+ * Disables one or more managed auto-subscription handles. The change persists
11689
+ * across reconnect (it is not silently re-enabled) until
11690
+ * {@link enableAutoSubscriptions} is called again. Synchronous fire-and-forget.
11691
+ *
11692
+ * @param features the {@link AmityAutoSubscription} handles to disable
11693
+ *
11694
+ * @category Client API
11695
+ */
11696
+ const disableAutoSubscriptions = (features) => {
11697
+ const manager = getAutoSubscriptionManager();
11698
+ features.forEach(feature => manager.unsubscribe(feature));
11699
+ };
11700
+ /* end_public_function */
11701
+ /* begin_public_function
11702
+ id: client.auto_subscriptions
11703
+ */
11704
+ /**
11705
+ * ```js
11706
+ * import { Client } from '@amityco/ts-sdk'
11707
+ * Client.autoSubscriptions().forEach(s => console.log(s.feature, s.isActive, s.topicCount))
11708
+ * ```
11709
+ *
11710
+ * Inspects the managed auto-subscription registry — each handle's `isActive`,
11711
+ * `isSystem`, and `topicCount`.
11712
+ *
11713
+ * @returns a snapshot of the managed subscription registry
11714
+ *
11715
+ * @category Client API
11716
+ */
11717
+ const autoSubscriptions = () => getAutoSubscriptionManager().subscriptions();
11718
+ /* end_public_function */
11719
+
11238
11720
  /**
11239
11721
  * ```js
11240
11722
  * import { onChannelMarkerFetched } from '@amityco/ts-sdk'
@@ -11609,6 +12091,7 @@ var index$s = /*#__PURE__*/Object.freeze({
11609
12091
  getSocialSettings: getSocialSettings,
11610
12092
  getShareableLinkConfiguration: getShareableLinkConfiguration,
11611
12093
  getProductCatalogueSetting: getProductCatalogueSetting,
12094
+ getForYouFeedSetting: getForYouFeedSetting,
11612
12095
  loginAsVisitor: loginAsVisitor,
11613
12096
  loginAsBot: loginAsBot,
11614
12097
  getCurrentUser: getCurrentUser,
@@ -11616,7 +12099,11 @@ var index$s = /*#__PURE__*/Object.freeze({
11616
12099
  setCurrentUserType: setCurrentUserType,
11617
12100
  setAccessTokenHandler: setAccessTokenHandler,
11618
12101
  getChatSettings: getChatSettings,
12102
+ getCoreUserSettings: getCoreUserSettings,
11619
12103
  notifications: notifications,
12104
+ enableAutoSubscriptions: enableAutoSubscriptions,
12105
+ disableAutoSubscriptions: disableAutoSubscriptions,
12106
+ autoSubscriptions: autoSubscriptions,
11620
12107
  onConnectionError: onConnectionError,
11621
12108
  onClientDisconnected: onClientDisconnected,
11622
12109
  onClientBanned: onClientBanned,
@@ -11634,19 +12121,6 @@ var index$s = /*#__PURE__*/Object.freeze({
11634
12121
  getMarkerSyncConsistentMode: getMarkerSyncConsistentMode
11635
12122
  });
11636
12123
 
11637
- function prepareFollowersPayload(response) {
11638
- const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
11639
- return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
11640
- }
11641
- function prepareFollowingsPayload(response) {
11642
- const { users, follows } = response, rest = __rest(response, ["users", "follows"]);
11643
- return Object.assign(Object.assign({}, rest), { follows, users: users.map(convertRawUserToInternalUser) });
11644
- }
11645
- function prepareFollowStatusPayload(response) {
11646
- const { follows } = response, rest = __rest(response, ["follows"]);
11647
- return Object.assign(Object.assign({}, rest), { follows });
11648
- }
11649
-
11650
12124
  /* begin_public_function
11651
12125
  id: user.relationship.block
11652
12126
  */
@@ -12824,6 +13298,8 @@ var index$r = /*#__PURE__*/Object.freeze({
12824
13298
  __proto__: null,
12825
13299
  blockUser: blockUser,
12826
13300
  unBlockUser: unBlockUser,
13301
+ onUserDidBlock: onUserDidBlock,
13302
+ onUserDidUnblock: onUserDidUnblock,
12827
13303
  follow: follow,
12828
13304
  unfollow: unfollow,
12829
13305
  acceptMyFollower: acceptMyFollower,
@@ -13653,7 +14129,7 @@ const getWatchSessionStorage = () => {
13653
14129
  return storageInstance;
13654
14130
  };
13655
14131
 
13656
- const privateKey = "MIIEpQIBAAKCAQEAwAEc/oZgYIvKSUG/C3mONYLR4ZPgAjMEX4bJ+xqqakUDRtqlNO+eZs2blQ1Ko0DBkqPExyQezvjibH5W2UZBV5RaBTlTcNVKTToMBEGesAfaEcM3qUyQHxdbFYZv6P4sb14dcwxTQ8usmaV8ooiR1Fcaso5ZWYcZ8Hb46FbQ7OoVumsBtPWwfZ4f003o5VCl6AIM6lcLv9UDLlFVYhE+PeXpRHtfWlGqxMvqC9oinlwhL6nWv6VjQXW4nhcib72dPBzfHT7k/PMKto2SxALYdb68ENiAGuJLWi3AUHSyYCJK2w7wIlWfJUAI0v26ub10IpExr6D5QuW2577jjP93iwIDAQABAoIBAFWfqXhwIIatkFY+9Z1+ZcbDQimgsmMIsUiQaX6Lk7e0cxOj6czDlxYtVtaPiNtow2pLkjNkjkCqiP7tEHnwdK9DvylZOTa2R15NJpK3WLcTqVIGhsn/FL5owfvFah6zSsmXZParZm5zY9NZE03ALZhOB9/cz0e3kf/EbpfeL2mW7MApyiUt5i09ycchroOpcWp73ipIxvgigtZyUGFmsQicWhUs28F0D7w4Qfk76yG3nqXeb+BAMhCaIaa/k/aAxhiZG/ygEQWQrcC8gfe+jyicMAQPDEVS9YuUMGsLjIjKuVLZzp2xirQnhc2i2zVNEIvG6soprPOBEMQugzrtX5ECgYEA3b7KAbBIbDl1e4ZSCWhHdHkiWVZHaopsR/LhqDDNhXjWjq3AesgV6k0j9EdziMn/HmmOso0bz99GTV3JZf4A9ztTLumJlkHbdVtlgOqSjrFLj12rH9KXTheyIhWSpUmm8+WB1xasFbqpvJaGo7F3pd2Fqj1XR4mp5BO7c/t7LJ0CgYEA3aouEzXQ9THRKYocdfY69EI1Il1t/d/RSqqd9BxEjxBgxkM13ZiYIn/R4WW/nCUrlmhxG44Aa2Gob4Ahfsui2xKTg/g/3Zk/rAxAEGkfOLGoenaJMD41fH4wUq3FRYwkvnaMb9Hd6f/TlBHslIRa2NN58bSBGJCyBP2b59+2+EcCgYEAixDVRXvV37GlYUOa/XVdosk5Zoe6oDGRuQm0xbNdoUBoZvDHDvme7ONWEiQha/8qtVsD+CyQ7awcPfb8kK9c0bBt+bTS6d4BkTcxkEkMgtrkBVR8Nqfu5jXsLH4VCv4G61zbMhZw8+ut+az5YX2yCN7Frj9sFlxapMRPQmzMEe0CgYEAumsAzM8ZqNv4mAK65Mnr0rhLj1cbxcKRdUYACOgtEFQpzxN/HZnTeFAe5nx3pI3uFlRHq3DFEYnT6dHMWaJQmAULYpVIwMi9L6gtyJ9fzoI6uqMtxRDMUqKdaSsTGOY/kJ6KhQ/unXi1K3XXjR+yd1+C0q+HUm1+CYxvrZYLfskCgYEArsEy+IQOiqniJ0NE2vVUF+UK/IRZaic9YKcpov5Ot7Vvzm/MnnW4N1ljVskocETBWMmPUvNSExVjPebi+rxd8fa5kY8BJScPTzMFbunZn/wjtGdcM10qdlVQ9doG61A/9P3ezFKCfS4AvF/H/59LcSx2Bh28fp3/efiVIOpVd4Y=";
14132
+ 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-----";
13657
14133
  /*
13658
14134
  * The crypto algorithm used for importing key and signing string
13659
14135
  */
@@ -15538,7 +16014,7 @@ const createEventResponseSubscriber = (event, callback) => {
15538
16014
  const eventResponse = pullFromCache([
15539
16015
  'eventResponse',
15540
16016
  'get',
15541
- payload.eventResponses[0].eventId,
16017
+ unpackedPayload.eventResponses[0].userId,
15542
16018
  ]);
15543
16019
  callback(eventResponse.data);
15544
16020
  }
@@ -16202,7 +16678,38 @@ const getAllBlockedUsers = async () => {
16202
16678
  const engine = BlockedUserSyncEngine$1.getInstance();
16203
16679
  // Ensure data is fetched (no-op if cache is fresh)
16204
16680
  await engine.ensureFetched();
16205
- // Read from the engine's bounded ID list — O(blocked users) not O(cache size)
16681
+ return engine.getCachedUsers();
16682
+ };
16683
+ /* end_public_function */
16684
+
16685
+ /* begin_public_function
16686
+ id: user.get_all_blocking_users
16687
+ */
16688
+ /**
16689
+ * ```js
16690
+ * import { UserRepository } from '@amityco/ts-sdk'
16691
+ * const blockingUsers = await UserRepository.getAllBlockingUsers()
16692
+ * ```
16693
+ *
16694
+ * Returns all users who have blocked the current user
16695
+ * non-paginated list (limit 100) with TTL-based caching (5-minute window). Within the
16696
+ * TTL window, subsequent calls resolve instantly from the local store without any
16697
+ * server call. After the TTL expires, the next call triggers a fresh server fetch.
16698
+ *
16699
+ * The directional inverse of {@link getAllBlockedUsers}.
16700
+ *
16701
+ * @returns A promise that resolves to an array of blocking {@link Amity.User} objects
16702
+ *
16703
+ * @category Block API
16704
+ * @async
16705
+ */
16706
+ const getAllBlockingUsers = async () => {
16707
+ const client = getActiveClient();
16708
+ client.log('user/getAllBlockingUsers');
16709
+ const engine = BlockingUserSyncEngine$1.getInstance();
16710
+ // Ensure data is fetched (no-op if cache is fresh)
16711
+ await engine.ensureFetched();
16712
+ // Read from the engine's bounded ID list — O(blocking users) not O(cache size)
16206
16713
  return engine.getCachedUsers();
16207
16714
  };
16208
16715
  /* end_public_function */
@@ -16585,6 +17092,12 @@ class BlockedUserPaginationController extends PaginationController {
16585
17092
  }
16586
17093
  }
16587
17094
 
17095
+ var EnumBlockActions;
17096
+ (function (EnumBlockActions) {
17097
+ EnumBlockActions["OnBlocked"] = "onBlocked";
17098
+ EnumBlockActions["OnUnblocked"] = "onUnblocked";
17099
+ })(EnumBlockActions || (EnumBlockActions = {}));
17100
+
16588
17101
  class BlockedUserQueryStreamController extends QueryStreamController {
16589
17102
  constructor(query, cacheKey, notifyChange, preparePayload) {
16590
17103
  super(query, cacheKey);
@@ -16614,11 +17127,16 @@ class BlockedUserQueryStreamController extends QueryStreamController {
16614
17127
  }
16615
17128
  reactor(action) {
16616
17129
  return (targetUser) => {
16617
- var _a;
16618
- if (action === EnumFollowActions.OnFollowed) {
17130
+ var _a, _b;
17131
+ const isRemoval = action === EnumFollowActions.OnFollowed || action === EnumBlockActions.OnUnblocked;
17132
+ const isAddition = action === EnumBlockActions.OnBlocked;
17133
+ if (isRemoval || isAddition) {
16619
17134
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
16620
- const updatedCollection = collection === null || collection === void 0 ? void 0 : collection.data.filter(id => id !== targetUser.userId);
16621
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: updatedCollection }));
17135
+ const ids = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
17136
+ const data = isAddition
17137
+ ? [...new Set([...ids, targetUser.userId])]
17138
+ : ids.filter(id => id !== targetUser.userId);
17139
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data }));
16622
17140
  }
16623
17141
  this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
16624
17142
  };
@@ -16673,7 +17191,6 @@ class BlockedUserLiveCollectionController extends LiveCollectionController {
16673
17191
  fn: onUserDeleted$2,
16674
17192
  action: EnumUserActions.OnUserDeleted,
16675
17193
  },
16676
- // In the case of unblocking a user, we need to subscribe to the follow events
16677
17194
  {
16678
17195
  fn: convertEventPayload(onLocalUserFollowed, 'to', 'user'),
16679
17196
  action: EnumFollowActions.OnFollowed,
@@ -16682,6 +17199,28 @@ class BlockedUserLiveCollectionController extends LiveCollectionController {
16682
17199
  fn: convertEventPayload(onUserFollowed, 'to', 'user'),
16683
17200
  action: EnumFollowActions.OnFollowed,
16684
17201
  },
17202
+ {
17203
+ fn: (reactor) => onUserDidBlock(status => {
17204
+ var _a;
17205
+ if (status.from !== getActiveClient().userId)
17206
+ return;
17207
+ const blocked = (_a = pullFromCache(['user', 'get', status.to])) === null || _a === void 0 ? void 0 : _a.data;
17208
+ if (blocked)
17209
+ reactor(blocked);
17210
+ }),
17211
+ action: EnumBlockActions.OnBlocked,
17212
+ },
17213
+ {
17214
+ fn: (reactor) => onUserDidUnblock(status => {
17215
+ var _a;
17216
+ if (status.from !== getActiveClient().userId)
17217
+ return;
17218
+ const blocked = (_a = pullFromCache(['user', 'get', status.to])) === null || _a === void 0 ? void 0 : _a.data;
17219
+ if (blocked)
17220
+ reactor(blocked);
17221
+ }),
17222
+ action: EnumBlockActions.OnUnblocked,
17223
+ },
16685
17224
  ]);
16686
17225
  }
16687
17226
  notifyChange({ origin, loading, error }) {
@@ -16749,6 +17288,184 @@ const getBlockedUsers = (params, callback, config) => {
16749
17288
  };
16750
17289
  /* end_public_function */
16751
17290
 
17291
+ class BlockingUserQueryStreamController extends QueryStreamController {
17292
+ constructor(query, cacheKey, notifyChange, preparePayload) {
17293
+ super(query, cacheKey);
17294
+ this.notifyChange = notifyChange;
17295
+ this.preparePayload = preparePayload;
17296
+ }
17297
+ async saveToMainDB(response) {
17298
+ const processedPayload = await this.preparePayload(response);
17299
+ const client = getActiveClient();
17300
+ const cachedAt = client.cache && Date.now();
17301
+ if (client.cache) {
17302
+ ingestInCache(processedPayload, { cachedAt });
17303
+ }
17304
+ }
17305
+ appendToQueryStream(response, direction, refresh = false) {
17306
+ var _a, _b;
17307
+ if (refresh) {
17308
+ pushToCache(this.cacheKey, {
17309
+ data: response.users.map(getResolver('user')),
17310
+ });
17311
+ }
17312
+ else {
17313
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
17314
+ const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
17315
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...users, ...response.users.map(getResolver('user'))])] }));
17316
+ }
17317
+ }
17318
+ reactor(action) {
17319
+ return (user) => {
17320
+ var _a, _b;
17321
+ if (user &&
17322
+ (action === EnumBlockActions.OnBlocked || action === EnumBlockActions.OnUnblocked)) {
17323
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
17324
+ const ids = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
17325
+ const data = action === EnumBlockActions.OnBlocked
17326
+ ? [...new Set([...ids, user.userId])]
17327
+ : ids.filter(id => id !== user.userId);
17328
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data }));
17329
+ }
17330
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
17331
+ };
17332
+ }
17333
+ subscribeRTE(createSubscriber) {
17334
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
17335
+ }
17336
+ }
17337
+
17338
+ class BlockingUserPaginationController extends PaginationController {
17339
+ async getRequest(queryParams, token) {
17340
+ const { limit = COLLECTION_DEFAULT_PAGINATION_SIZE } = queryParams, params = __rest(queryParams, ["limit"]);
17341
+ const options = token ? { token } : { limit };
17342
+ const { data: queryResponse } = await this.http.get('/api/v4/me/blockers', {
17343
+ params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
17344
+ });
17345
+ return queryResponse;
17346
+ }
17347
+ }
17348
+
17349
+ class BlockingUserLiveCollectionController extends LiveCollectionController {
17350
+ constructor(callback) {
17351
+ const queryStreamId = `blocking-users-${getActiveClient().userId}`;
17352
+ const query = {};
17353
+ const cacheKey = ['blockingUsers', 'collection', queryStreamId];
17354
+ const paginationController = new BlockingUserPaginationController(query);
17355
+ super(paginationController, queryStreamId, cacheKey, callback);
17356
+ this.queryStreamController = new BlockingUserQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this), prepareBlockingUserPayload);
17357
+ this.callback = callback.bind(this);
17358
+ this.loadPage({ initial: true });
17359
+ }
17360
+ setup() {
17361
+ var _a;
17362
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
17363
+ if (!collection) {
17364
+ pushToCache(this.cacheKey, {
17365
+ data: [],
17366
+ params: {},
17367
+ });
17368
+ }
17369
+ }
17370
+ async persistModel(queryPayload) {
17371
+ await this.queryStreamController.saveToMainDB(queryPayload);
17372
+ }
17373
+ persistQueryStream({ response, direction, refresh, }) {
17374
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
17375
+ }
17376
+ startSubscription() {
17377
+ return this.queryStreamController.subscribeRTE([
17378
+ {
17379
+ fn: onUserDeleted$2,
17380
+ action: EnumUserActions.OnUserDeleted,
17381
+ },
17382
+ {
17383
+ fn: (reactor) => onUserDidBlock(status => {
17384
+ var _a;
17385
+ if (status.to !== getActiveClient().userId)
17386
+ return;
17387
+ const blocker = (_a = pullFromCache(['user', 'get', status.from])) === null || _a === void 0 ? void 0 : _a.data;
17388
+ if (blocker)
17389
+ reactor(blocker);
17390
+ }),
17391
+ action: EnumBlockActions.OnBlocked,
17392
+ },
17393
+ {
17394
+ fn: (reactor) => onUserDidUnblock(status => {
17395
+ var _a;
17396
+ if (status.to !== getActiveClient().userId)
17397
+ return;
17398
+ const blocker = (_a = pullFromCache(['user', 'get', status.from])) === null || _a === void 0 ? void 0 : _a.data;
17399
+ if (blocker)
17400
+ reactor(blocker);
17401
+ }),
17402
+ action: EnumBlockActions.OnUnblocked,
17403
+ },
17404
+ ]);
17405
+ }
17406
+ notifyChange({ origin, loading, error }) {
17407
+ var _a, _b;
17408
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
17409
+ if (!collection)
17410
+ return;
17411
+ const data = this.applyFilter((_b = collection.data
17412
+ .map(id => pullFromCache(['user', 'get', id]))
17413
+ .filter(isNonNullable)
17414
+ .map(({ data }) => data)
17415
+ .map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
17416
+ if (!this.shouldNotify(data) && origin === 'event')
17417
+ return;
17418
+ this.callback({
17419
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
17420
+ data,
17421
+ hasNextPage: !!this.paginationController.getNextToken(),
17422
+ loading,
17423
+ error,
17424
+ });
17425
+ }
17426
+ applyFilter(data) {
17427
+ let users = data;
17428
+ users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
17429
+ return users;
17430
+ }
17431
+ }
17432
+
17433
+ /* begin_public_function
17434
+ id: user.get_blocking_users
17435
+ */
17436
+ /**
17437
+ * ```js
17438
+ * import { UserRepository } from '@amityco/ts-sdk'
17439
+ * const unsubscribe = UserRepository.getBlockingUsers(({ data: users }) => {
17440
+ * console.log(users)
17441
+ * })
17442
+ * ```
17443
+ *
17444
+ * Observe the {@link Amity.User}s who have blocked the current user
17445
+ *
17446
+ * @param callback to receive updates on the blocking {@link Amity.User}s
17447
+ * @returns {@link Amity.Unsubscriber} to unsubscribe from collection
17448
+ *
17449
+ * @category User API
17450
+ */
17451
+ const getBlockingUsers = (callback) => {
17452
+ const { log, cache } = getActiveClient();
17453
+ if (!cache)
17454
+ console.log(ENABLE_CACHE_MESSAGE);
17455
+ const timestamp = Date.now();
17456
+ log(`getBlockingUsers(tmpid: ${timestamp}) > listen`);
17457
+ const blockingUserLiveCollection = new BlockingUserLiveCollectionController(callback);
17458
+ const disposers = blockingUserLiveCollection.startSubscription();
17459
+ const cacheKey = blockingUserLiveCollection.getCacheKey();
17460
+ disposers.push(() => dropFromCache(cacheKey));
17461
+ return () => {
17462
+ log(`getBlockingUsers(tmpid: ${timestamp}) > dispose`);
17463
+ disposers.forEach(fn => fn());
17464
+ dropFromCache(cacheKey);
17465
+ };
17466
+ };
17467
+ /* end_public_function */
17468
+
16752
17469
  class SearchUserPaginationController extends PaginationController {
16753
17470
  async getRequest(queryParams, token) {
16754
17471
  const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, displayName } = queryParams, params = __rest(queryParams, ["limit", "displayName"]);
@@ -17015,6 +17732,7 @@ var index$q = /*#__PURE__*/Object.freeze({
17015
17732
  unflagUser: unflagUser,
17016
17733
  isUserFlaggedByMe: isUserFlaggedByMe,
17017
17734
  getAllBlockedUsers: getAllBlockedUsers,
17735
+ getAllBlockingUsers: getAllBlockingUsers,
17018
17736
  onUserUpdated: onUserUpdated,
17019
17737
  onUserDeleted: onUserDeleted$2,
17020
17738
  onUserFlagged: onUserFlagged,
@@ -17023,6 +17741,7 @@ var index$q = /*#__PURE__*/Object.freeze({
17023
17741
  getUser: getUser,
17024
17742
  getUsers: getUsers,
17025
17743
  getBlockedUsers: getBlockedUsers,
17744
+ getBlockingUsers: getBlockingUsers,
17026
17745
  searchUserByDisplayName: searchUserByDisplayName,
17027
17746
  getReachedUsers: getReachedUsers,
17028
17747
  get AmityUserSearchMatchType () { return AmityUserSearchMatchType; }
@@ -23123,6 +23842,405 @@ const getArchivedChannels = (params, callback) => {
23123
23842
  };
23124
23843
  /* end_public_function */
23125
23844
 
23845
+ class SearchChannelPaginationController extends PaginationController {
23846
+ async getRequest(queryParams, token) {
23847
+ const { query, exactMatch, isMemberOnly, types, tags, sortBy, orderBy, limit = COLLECTION_DEFAULT_PAGINATION_SIZE, } = queryParams;
23848
+ const options = token ? { token } : { limit: Math.min(100, Math.max(1, limit)) };
23849
+ const { data: queryResponse } = await this.http.get(`/api/v2/search/channels`, {
23850
+ params: {
23851
+ query,
23852
+ exactMatch,
23853
+ isMemberOnly,
23854
+ types,
23855
+ tags,
23856
+ sortBy,
23857
+ orderBy,
23858
+ options,
23859
+ },
23860
+ });
23861
+ return queryResponse;
23862
+ }
23863
+ }
23864
+
23865
+ class SearchChannelQueryStreamController extends QueryStreamController {
23866
+ constructor(query, cacheKey, notifyChange) {
23867
+ super(query, cacheKey);
23868
+ this.notifyChange = notifyChange;
23869
+ }
23870
+ async saveToMainDB(response) {
23871
+ const processedPayload = await prepareChannelPayload(response);
23872
+ const client = getActiveClient();
23873
+ const cachedAt = client.cache && Date.now();
23874
+ if (client.cache) {
23875
+ ingestInCache(processedPayload, { cachedAt });
23876
+ }
23877
+ }
23878
+ appendToQueryStream(response, direction, refresh = false) {
23879
+ var _a, _b;
23880
+ if (refresh) {
23881
+ pushToCache(this.cacheKey, {
23882
+ data: response.channels.map(getResolver('channel')),
23883
+ });
23884
+ return;
23885
+ }
23886
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23887
+ const existing = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
23888
+ const incoming = response.channels.map(getResolver('channel'));
23889
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === "prev" /* Amity.LiveCollectionPageDirection.PREV */
23890
+ ? [...new Set([...incoming, ...existing])]
23891
+ : [...new Set([...existing, ...incoming])] }));
23892
+ }
23893
+ reactor() {
23894
+ return () => this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
23895
+ }
23896
+ subscribeRTE(createSubscriber) {
23897
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor()));
23898
+ }
23899
+ }
23900
+
23901
+ /* eslint-disable no-use-before-define */
23902
+ const getMessagePreviewSetting = () => {
23903
+ const client = getActiveClient();
23904
+ return client.getMessagePreviewSetting(false);
23905
+ };
23906
+ class SearchChannelLiveCollectionController extends LiveCollectionController {
23907
+ constructor(query, callback) {
23908
+ const queryStreamId = hash__default["default"](query);
23909
+ const cacheKey = ['channel', 'search', queryStreamId];
23910
+ const paginationController = new SearchChannelPaginationController(query);
23911
+ super(paginationController, queryStreamId, cacheKey, callback);
23912
+ this.queryStreamController = new SearchChannelQueryStreamController(query, this.cacheKey, this.notifyChange.bind(this));
23913
+ this.callback = callback.bind(this);
23914
+ this.loadPage({ initial: true });
23915
+ }
23916
+ startSubscription() {
23917
+ return this.queryStreamController.subscribeRTE(this.getSubscriptions());
23918
+ }
23919
+ notifyChange({ origin, loading, error }) {
23920
+ var _a, _b;
23921
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23922
+ if (!collection)
23923
+ return;
23924
+ const data = (_b = collection.data
23925
+ .map(channelId => pullFromCache(['channel', 'get', channelId]))
23926
+ .filter(Boolean)
23927
+ .map(cached => constructChannelObject(cached.data))) !== null && _b !== void 0 ? _b : [];
23928
+ if (!this.shouldNotify(data) && origin === 'event')
23929
+ return;
23930
+ this.callback({
23931
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
23932
+ data,
23933
+ hasNextPage: !!this.paginationController.getNextToken(),
23934
+ loading,
23935
+ error,
23936
+ });
23937
+ }
23938
+ setup() {
23939
+ var _a;
23940
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23941
+ if (!collection) {
23942
+ pushToCache(this.cacheKey, {
23943
+ data: [],
23944
+ params: {},
23945
+ });
23946
+ }
23947
+ }
23948
+ async persistModel(response) {
23949
+ await this.queryStreamController.saveToMainDB(response);
23950
+ }
23951
+ persistQueryStream({ response, direction, refresh, }) {
23952
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
23953
+ }
23954
+ shouldAbort(targetChannelId) {
23955
+ var _a;
23956
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23957
+ if (!collection)
23958
+ return true;
23959
+ return !collection.data.find(channelId => channelId === targetChannelId);
23960
+ }
23961
+ getSubscriptions() {
23962
+ return [
23963
+ {
23964
+ fn: convertEventPayload((callback) => {
23965
+ return onMessageCreatedMqtt(message => {
23966
+ var _a;
23967
+ const cacheData = (_a = pullFromCache([
23968
+ 'channel',
23969
+ 'get',
23970
+ message.channelId,
23971
+ ])) === null || _a === void 0 ? void 0 : _a.data;
23972
+ if (!cacheData)
23973
+ return;
23974
+ updateChannelCache(cacheData, {
23975
+ lastActivity: message.createdAt,
23976
+ });
23977
+ callback(message);
23978
+ });
23979
+ }, 'channelId', 'channel'),
23980
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
23981
+ },
23982
+ {
23983
+ fn: convertEventPayload((callback) => {
23984
+ return onMessageCreatedLocal(message => {
23985
+ var _a;
23986
+ const cacheData = (_a = pullFromCache([
23987
+ 'channel',
23988
+ 'get',
23989
+ message.channelId,
23990
+ ])) === null || _a === void 0 ? void 0 : _a.data;
23991
+ if (!cacheData)
23992
+ return;
23993
+ updateChannelCache(cacheData, {
23994
+ lastActivity: message.createdAt,
23995
+ });
23996
+ callback(message);
23997
+ });
23998
+ }, 'channelId', 'channel'),
23999
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24000
+ },
24001
+ { fn: onChannelDeleted, action: "onDelete" /* Amity.ChannelActionType.OnDelete */ },
24002
+ { fn: onChannelUpdated, action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */ },
24003
+ { fn: onChannelSetMuted, action: "onMute" /* Amity.ChannelActionType.OnMute */ },
24004
+ {
24005
+ fn: (reactor) => onChannelArchived(payload => {
24006
+ const channels = payload.archives
24007
+ .map(archive => {
24008
+ var _a;
24009
+ return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
24010
+ })
24011
+ .filter((c) => Boolean(c));
24012
+ if (channels.length > 0)
24013
+ reactor(channels);
24014
+ }),
24015
+ action: "onArchived" /* Amity.ChannelActionType.OnArchived */,
24016
+ },
24017
+ {
24018
+ fn: (reactor) => onChannelUnarchived(payload => {
24019
+ const channels = payload.archives
24020
+ .map(archive => {
24021
+ var _a;
24022
+ return (_a = pullFromCache(['channel', 'get', archive.channelId])) === null || _a === void 0 ? void 0 : _a.data;
24023
+ })
24024
+ .filter((c) => Boolean(c));
24025
+ if (channels.length > 0)
24026
+ reactor(channels);
24027
+ }),
24028
+ action: "onUnarchived" /* Amity.ChannelActionType.OnUnarchived */,
24029
+ },
24030
+ {
24031
+ fn: convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
24032
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24033
+ },
24034
+ {
24035
+ fn: convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel'),
24036
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24037
+ },
24038
+ {
24039
+ fn: convertEventPayload((callback) => {
24040
+ const updateMessagePreview = async (message) => {
24041
+ var _a;
24042
+ const messagePreviewSetting = await getMessagePreviewSetting();
24043
+ if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
24044
+ return;
24045
+ handleMessageCreated(message);
24046
+ if (this.shouldAbort(message.channelId))
24047
+ return;
24048
+ const channel = (_a = pullFromCache([
24049
+ 'channel',
24050
+ 'get',
24051
+ message.channelId,
24052
+ ])) === null || _a === void 0 ? void 0 : _a.data;
24053
+ if (!channel)
24054
+ return;
24055
+ updateChannelCache(channel, {
24056
+ messagePreviewId: message.messageId,
24057
+ });
24058
+ callback(message);
24059
+ };
24060
+ return onMessageCreatedMqtt(updateMessagePreview);
24061
+ }, 'channelId', 'channel'),
24062
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24063
+ },
24064
+ {
24065
+ fn: convertEventPayload((callback) => {
24066
+ const updateMessagePreview = async (message) => {
24067
+ var _a;
24068
+ const messagePreviewSetting = await getMessagePreviewSetting();
24069
+ if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
24070
+ return;
24071
+ handleMessageCreated(message);
24072
+ if (this.shouldAbort(message.channelId))
24073
+ return;
24074
+ const channel = (_a = pullFromCache([
24075
+ 'channel',
24076
+ 'get',
24077
+ message.channelId,
24078
+ ])) === null || _a === void 0 ? void 0 : _a.data;
24079
+ if (!channel)
24080
+ return;
24081
+ updateChannelCache(channel, {
24082
+ messagePreviewId: message.messageId,
24083
+ });
24084
+ callback(message);
24085
+ };
24086
+ return onMessageCreatedLocal(updateMessagePreview);
24087
+ }, 'channelId', 'channel'),
24088
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24089
+ },
24090
+ {
24091
+ fn: convertEventPayload((callback) => {
24092
+ const updateMessagePreview = async (message) => {
24093
+ const messagePreviewSetting = await getMessagePreviewSetting();
24094
+ if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
24095
+ return;
24096
+ handleMessageUpdated(message);
24097
+ if (this.shouldAbort(message.channelId))
24098
+ return;
24099
+ callback(message);
24100
+ };
24101
+ return onMessageUpdated(updateMessagePreview);
24102
+ }, 'channelId', 'channel'),
24103
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24104
+ },
24105
+ {
24106
+ fn: convertEventPayload((callback) => {
24107
+ const updateMessagePreview = async (message) => {
24108
+ const messagePreviewSetting = await getMessagePreviewSetting();
24109
+ if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
24110
+ return;
24111
+ if (messagePreviewSetting ===
24112
+ "message-preview-include-deleted" /* Amity.MessagePreviewSetting.MESSAGE_PREVIEW_INCLUDE_DELETED */)
24113
+ await handleMessageUpdated(message);
24114
+ if (this.shouldAbort(message.channelId))
24115
+ return;
24116
+ if (messagePreviewSetting ===
24117
+ "message-preview-not-include-deleted" /* Amity.MessagePreviewSetting.MESSAGE_PREVIEW_NOT_INCLUDE_DELETED */) {
24118
+ await getChannel$1(message.channelId);
24119
+ }
24120
+ callback(message);
24121
+ };
24122
+ return onMessageDeleted(updateMessagePreview);
24123
+ }, 'channelId', 'channel'),
24124
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24125
+ },
24126
+ {
24127
+ fn: convertEventPayload((callback) => {
24128
+ const updateMessagePreview = async (subChannel) => {
24129
+ var _a;
24130
+ const collections = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24131
+ if (!collections)
24132
+ return;
24133
+ const channelId = collections.data.find(channel => {
24134
+ const messagePreviewCache = getChannelMessagePreview(channel);
24135
+ return (messagePreviewCache === null || messagePreviewCache === void 0 ? void 0 : messagePreviewCache.subChannelId) === subChannel.subChannelId;
24136
+ });
24137
+ if (!channelId)
24138
+ return;
24139
+ await getChannel$1(subChannel.channelId);
24140
+ callback(subChannel);
24141
+ };
24142
+ return onSubChannelDeleted(updateMessagePreview);
24143
+ }, 'channelId', 'channel'),
24144
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24145
+ },
24146
+ {
24147
+ fn: convertEventPayload((callback) => {
24148
+ const updateMessagePreview = async (subChannel) => {
24149
+ var _a;
24150
+ const messagePreviewSetting = await getMessagePreviewSetting();
24151
+ if (messagePreviewSetting === "no-message-preview" /* Amity.MessagePreviewSetting.NO_MESSAGE_PREVIEW */)
24152
+ return;
24153
+ const collections = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24154
+ if (!collections)
24155
+ return;
24156
+ await handleSubChannelUpdated(subChannel);
24157
+ if (this.shouldAbort(subChannel.channelId))
24158
+ return;
24159
+ callback(subChannel);
24160
+ };
24161
+ return onSubChannelUpdated(updateMessagePreview);
24162
+ }, 'channelId', 'channel'),
24163
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24164
+ },
24165
+ {
24166
+ fn: (callback) => {
24167
+ const handleUserFeedMarkerResolved = async (marker) => {
24168
+ if (marker.feedMarkers) {
24169
+ const channels = marker.feedMarkers
24170
+ .map(feedMarker => {
24171
+ var _a;
24172
+ return (_a = pullFromCache([
24173
+ 'channel',
24174
+ 'get',
24175
+ feedMarker.entityId,
24176
+ ])) === null || _a === void 0 ? void 0 : _a.data;
24177
+ })
24178
+ .filter(Boolean);
24179
+ callback(channels);
24180
+ }
24181
+ };
24182
+ return onUserMessageFeedMarkerResolved(handleUserFeedMarkerResolved);
24183
+ },
24184
+ action: "OnResolveUnread" /* Amity.ChannelActionType.OnResolveUnread */,
24185
+ },
24186
+ {
24187
+ fn: convertEventPayload(onChannelUnreadInfoUpdatedLocal, 'channelId', 'channel'),
24188
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24189
+ },
24190
+ {
24191
+ fn: convertEventPayload((callback) => {
24192
+ const processPayload = (payloads) => {
24193
+ payloads.forEach(callback);
24194
+ };
24195
+ return onChannelUnreadUpdatedLocal(processPayload);
24196
+ }, 'channelId', 'channel'),
24197
+ action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
24198
+ },
24199
+ ];
24200
+ }
24201
+ }
24202
+
24203
+ /* begin_public_function
24204
+ id: channel.search
24205
+ */
24206
+ /**
24207
+ * ```js
24208
+ * import { ChannelRepository } from '@amityco/ts-sdk';
24209
+ *
24210
+ * const unsubscribe = ChannelRepository.searchChannels(
24211
+ * { query: 'hello' },
24212
+ * response => response.data,
24213
+ * );
24214
+ * ```
24215
+ *
24216
+ * Live collection of {@link Amity.Channel}s matching the search query. Backed by
24217
+ * `GET /api/v2/search/channels`.
24218
+ *
24219
+ * @param params Search parameters.
24220
+ * @param callback Called whenever new data are available.
24221
+ * @returns An {@link Amity.Unsubscriber} function to stop observing.
24222
+ *
24223
+ * @category Channel Live Collection
24224
+ */
24225
+ const searchChannels = (params, callback) => {
24226
+ const { log, cache } = getActiveClient();
24227
+ if (!cache)
24228
+ console.log(ENABLE_CACHE_MESSAGE);
24229
+ const timestamp = Date.now();
24230
+ log(`searchChannels(tmpid: ${timestamp}) > listen`);
24231
+ const searchChannelLiveCollection = new SearchChannelLiveCollectionController(params, callback);
24232
+ const disposers = searchChannelLiveCollection.startSubscription();
24233
+ const cacheKey = searchChannelLiveCollection.getCacheKey();
24234
+ disposers.push(() => {
24235
+ dropFromCache(cacheKey);
24236
+ });
24237
+ return () => {
24238
+ log(`searchChannels(tmpid: ${timestamp}) > dispose`);
24239
+ disposers.forEach(fn => fn());
24240
+ };
24241
+ };
24242
+ /* end_public_function */
24243
+
23126
24244
  /* begin_public_function
23127
24245
  id: channel.member.add
23128
24246
  */
@@ -23756,6 +24874,7 @@ var index$j = /*#__PURE__*/Object.freeze({
23756
24874
  getChannels: getChannels,
23757
24875
  getTotalChannelsUnread: getTotalChannelsUnread,
23758
24876
  getArchivedChannels: getArchivedChannels,
24877
+ searchChannels: searchChannels,
23759
24878
  MARKER_INCLUDED_CHANNEL_TYPE: MARKER_INCLUDED_CHANNEL_TYPE,
23760
24879
  isUnreadCountSupport: isUnreadCountSupport,
23761
24880
  convertFromRaw: convertFromRaw,
@@ -27651,7 +28770,7 @@ class CommentLiveCollectionController extends LiveCollectionController {
27651
28770
  this.queryStreamController.appendToQueryStream(response, direction, refresh);
27652
28771
  }
27653
28772
  startSubscription() {
27654
- return this.queryStreamController.subscribeRTE([
28773
+ const disposers = this.queryStreamController.subscribeRTE([
27655
28774
  { fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
27656
28775
  { fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
27657
28776
  { fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
@@ -27664,6 +28783,11 @@ class CommentLiveCollectionController extends LiveCollectionController {
27664
28783
  { fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
27665
28784
  { fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
27666
28785
  ]);
28786
+ if (this.query.excludeBlockUserComments) {
28787
+ const refresh = () => this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
28788
+ disposers.push(onUserDidBlock(refresh), onUserDidUnblock(refresh));
28789
+ }
28790
+ return disposers;
27667
28791
  }
27668
28792
  notifyChange({ origin, loading, error }) {
27669
28793
  var _a, _b;
@@ -27716,6 +28840,9 @@ class CommentLiveCollectionController extends LiveCollectionController {
27716
28840
  comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
27717
28841
  }
27718
28842
  }
28843
+ if (this.query.excludeBlockUserComments) {
28844
+ comments = filterCommentsByBlockUsers(comments);
28845
+ }
27719
28846
  switch (this.query.sortBy) {
27720
28847
  case 'firstCreated':
27721
28848
  comments = comments.sort(sortByFirstCreated);
@@ -28819,45 +29946,80 @@ class ForYouFeedPaginationController extends PaginationController {
28819
29946
  constructor(query) {
28820
29947
  super(query);
28821
29948
  this.checkedDisk = false;
29949
+ this.hasDeliveredPost = false;
28822
29950
  this.cursor = CursorController.current();
28823
29951
  }
28824
29952
  async getRequest(_queryParams, token) {
28825
- let effectiveToken = token;
28826
- if (!effectiveToken && !this.checkedDisk && this.cursor) {
29953
+ var _a, _b, _c, _d, _e;
29954
+ const isFirstPage = token === undefined;
29955
+ let stored = null;
29956
+ // On the first page of a fresh collection, load the saved cursor from disk once.
29957
+ // Drop it if the snapshot has already expired so we start fresh.
29958
+ if (isFirstPage && !this.checkedDisk && this.cursor) {
28827
29959
  this.checkedDisk = true;
28828
- const stored = await this.cursor.get();
28829
- if (stored && !CursorController.isExpired(stored.expiredAt)) {
28830
- effectiveToken = stored.cursor;
28831
- }
28832
- else if (stored) {
29960
+ stored = await this.cursor.get();
29961
+ if (stored && CursorController.isExpired(stored.expiredAt)) {
28833
29962
  await this.cursor.clear();
29963
+ stored = null;
28834
29964
  }
28835
29965
  }
28836
- const options = {
28837
- limit: COLLECTION_DEFAULT_PAGINATION_SIZE,
28838
- };
28839
- if (effectiveToken)
28840
- options.token = effectiveToken;
28841
- let queryResponse;
29966
+ // Already paged to the end before. Ask the BE fresh (no cursor) and check if it's
29967
+ // still the same snapshot the user finished.
29968
+ if (isFirstPage && (stored === null || stored === void 0 ? void 0 : stored.reachedEndOfFeed)) {
29969
+ const fresh = await this.fetch();
29970
+ const freshExpiredAt = Date.parse((_b = (_a = fresh.paging) === null || _a === void 0 ? void 0 : _a.expiredAt) !== null && _b !== void 0 ? _b : '');
29971
+ const rolledOver = !Number.isNaN(freshExpiredAt) && freshExpiredAt !== stored.expiredAt;
29972
+ // New snapshot → serve it. Same snapshot → user has seen it all, show empty.
29973
+ if (rolledOver) {
29974
+ await this.persistCursor(fresh);
29975
+ if (fresh.posts.length > 0)
29976
+ this.hasDeliveredPost = true;
29977
+ return fresh;
29978
+ }
29979
+ return Object.assign(Object.assign({}, fresh), { posts: [], paging: {} });
29980
+ }
29981
+ // Resume from the saved cursor on re-entry; otherwise use the live-collection token.
29982
+ const effectiveToken = isFirstPage && stored ? stored.cursor : token;
29983
+ const response = await this.fetch(effectiveToken);
29984
+ if (response.posts.length > 0)
29985
+ this.hasDeliveredPost = true;
29986
+ if ((_c = response.paging) === null || _c === void 0 ? void 0 : _c.next) {
29987
+ // More pages left → advance the saved cursor.
29988
+ await this.persistCursor(response);
29989
+ }
29990
+ else if (this.hasDeliveredPost && this.cursor) {
29991
+ // Reached the end and mark end of feed
29992
+ const expiredAt = Date.parse((_e = (_d = response.paging) === null || _d === void 0 ? void 0 : _d.expiredAt) !== null && _e !== void 0 ? _e : '');
29993
+ if (!Number.isNaN(expiredAt))
29994
+ await this.cursor.markReachedEndOfFeed(expiredAt);
29995
+ }
29996
+ return response;
29997
+ }
29998
+ async fetch(token) {
29999
+ const options = { limit: COLLECTION_DEFAULT_PAGINATION_SIZE };
30000
+ if (token)
30001
+ options.token = token;
28842
30002
  try {
28843
- ({ data: queryResponse } = await this.http.get(API_ENDPOINTS.forYouFeed, { params: { options } }));
30003
+ const { data } = await this.http.get(API_ENDPOINTS.forYouFeed, {
30004
+ params: { options },
30005
+ });
30006
+ return data;
28844
30007
  }
28845
30008
  catch (error) {
28846
30009
  if (error instanceof ASCApiError && error.code === 400300 /* Amity.ServerError.FORBIDDEN */) {
28847
30010
  throw new AmityForYouFeedDisabledError();
28848
30011
  }
28849
30012
  const recoverable = error instanceof ASCApiError && error.code === 400322 /* Amity.ServerError.FEED_SNAPSHOT_EXPIRED */;
28850
- if (recoverable && effectiveToken !== undefined) {
30013
+ if (recoverable && token !== undefined) {
28851
30014
  if (this.cursor)
28852
30015
  await this.cursor.clear();
28853
- ({ data: queryResponse } = await this.http.get(API_ENDPOINTS.forYouFeed, { params: { options: { limit: COLLECTION_DEFAULT_PAGINATION_SIZE } } }));
28854
- }
28855
- else {
28856
- throw error;
30016
+ const { data } = await this.http.get(API_ENDPOINTS.forYouFeed, {
30017
+ params: { options: { limit: COLLECTION_DEFAULT_PAGINATION_SIZE } },
30018
+ });
30019
+ return data;
28857
30020
  }
30021
+ throw error;
28858
30022
  }
28859
- await this.persistCursor(queryResponse);
28860
- return queryResponse;
28861
30023
  }
28862
30024
  async persistCursor(response) {
28863
30025
  var _a, _b;
@@ -30025,7 +31187,12 @@ class PostLiveCollectionController extends LiveCollectionController {
30025
31187
  this.queryStreamController.appendToQueryStream(response, direction, refresh);
30026
31188
  }
30027
31189
  startSubscription() {
30028
- return this.queryStreamController.subscribeRTE(getPostSubscription(this.cacheKey));
31190
+ const disposers = this.queryStreamController.subscribeRTE(getPostSubscription(this.cacheKey));
31191
+ if (this.query.excludeBlockUserPosts) {
31192
+ const refresh = () => this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
31193
+ disposers.push(onUserDidBlock(refresh), onUserDidUnblock(refresh));
31194
+ }
31195
+ return disposers;
30029
31196
  }
30030
31197
  notifyChange({ origin, loading, error }) {
30031
31198
  var _a, _b;
@@ -30071,6 +31238,9 @@ class PostLiveCollectionController extends LiveCollectionController {
30071
31238
  const sortBy = this.query.sortBy || 'lastCreated';
30072
31239
  posts = posts.filter(post => !exceedsUntilAtBoundary(post.createdAt, validatedUntilAt, sortBy));
30073
31240
  }
31241
+ if (this.query.excludeBlockUserPosts) {
31242
+ posts = filterPostsByBlockUsers(posts);
31243
+ }
30074
31244
  switch (this.query.sortBy) {
30075
31245
  case 'firstCreated':
30076
31246
  posts = posts.sort(sortByFirstCreated);
@@ -36793,6 +37963,9 @@ exports.filterByPropIntersection = filterByPropIntersection;
36793
37963
  exports.filterBySearchTerm = filterBySearchTerm;
36794
37964
  exports.filterByStringComparePartially = filterByStringComparePartially;
36795
37965
  exports.filterByUntilAt = filterByUntilAt;
37966
+ exports.filterCommentsByBlockUsers = filterCommentsByBlockUsers;
37967
+ exports.filterPostsByBlockUsers = filterPostsByBlockUsers;
37968
+ exports.getBlockUsersId = getBlockUsersId;
36796
37969
  exports.getChannelTopic = getChannelTopic;
36797
37970
  exports.getCommentTopic = getCommentTopic;
36798
37971
  exports.getCommunityStoriesTopic = getCommunityStoriesTopic;