@amityco/ts-sdk-react-native 6.30.4-48268a5.0 → 6.30.4

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 (78) hide show
  1. package/.env +26 -26
  2. package/dist/@types/core/events.d.ts +2 -0
  3. package/dist/@types/core/events.d.ts.map +1 -1
  4. package/dist/@types/core/payload.d.ts +2 -0
  5. package/dist/@types/core/payload.d.ts.map +1 -1
  6. package/dist/@types/domains/community.d.ts +8 -0
  7. package/dist/@types/domains/community.d.ts.map +1 -1
  8. package/dist/client/api/index.d.ts +2 -0
  9. package/dist/client/api/index.d.ts.map +1 -1
  10. package/dist/communityRepository/communityMembership/events/index.d.ts +2 -0
  11. package/dist/communityRepository/communityMembership/events/index.d.ts.map +1 -1
  12. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +2 -0
  13. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -0
  14. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +2 -0
  15. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -0
  16. package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
  17. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.d.ts.map +1 -1
  18. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersLiveCollectionController.d.ts.map +1 -1
  19. package/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
  20. package/dist/communityRepository/observers/getCommunity.d.ts.map +1 -1
  21. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.d.ts +13 -0
  22. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.d.ts.map +1 -0
  23. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.d.ts +9 -0
  24. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.d.ts.map +1 -0
  25. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +16 -0
  26. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -0
  27. package/dist/communityRepository/observers/getRecommendedCommunities/enums.d.ts +5 -0
  28. package/dist/communityRepository/observers/getRecommendedCommunities/enums.d.ts.map +1 -0
  29. package/dist/communityRepository/observers/getRecommendedCommunities.d.ts +1 -1
  30. package/dist/communityRepository/observers/getRecommendedCommunities.d.ts.map +1 -1
  31. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.d.ts +13 -0
  32. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.d.ts.map +1 -0
  33. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.d.ts +9 -0
  34. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.d.ts.map +1 -0
  35. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +16 -0
  36. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -0
  37. package/dist/communityRepository/observers/getTrendingCommunities/enums.d.ts +5 -0
  38. package/dist/communityRepository/observers/getTrendingCommunities/enums.d.ts.map +1 -0
  39. package/dist/communityRepository/observers/getTrendingCommunities.d.ts +1 -1
  40. package/dist/communityRepository/observers/getTrendingCommunities.d.ts.map +1 -1
  41. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.d.ts.map +1 -1
  42. package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
  43. package/dist/core/events.d.ts +3 -3
  44. package/dist/core/events.d.ts.map +1 -1
  45. package/dist/index.cjs.js +335 -222
  46. package/dist/index.esm.js +335 -222
  47. package/dist/index.umd.js +3 -3
  48. package/dist/report/api/isReportedByMe.d.ts.map +1 -1
  49. package/package.json +1 -1
  50. package/src/@types/core/events.ts +2 -0
  51. package/src/@types/core/payload.ts +3 -0
  52. package/src/@types/domains/community.ts +6 -0
  53. package/src/client/api/index.ts +3 -0
  54. package/src/communityRepository/api/joinCommunity.ts +1 -1
  55. package/src/communityRepository/api/leaveCommunity.ts +1 -1
  56. package/src/communityRepository/communityMembership/events/index.ts +2 -0
  57. package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +5 -0
  58. package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +5 -0
  59. package/src/communityRepository/communityMembership/events/utils.ts +0 -2
  60. package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersLiveCollectionController.ts +4 -0
  61. package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersLiveCollectionController.ts +4 -0
  62. package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +7 -2
  63. package/src/communityRepository/observers/getCommunity.ts +4 -0
  64. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.ts +109 -0
  65. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.ts +31 -0
  66. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +88 -0
  67. package/src/communityRepository/observers/getRecommendedCommunities/enums.ts +4 -0
  68. package/src/communityRepository/observers/getRecommendedCommunities.ts +9 -81
  69. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.ts +109 -0
  70. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.ts +28 -0
  71. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +86 -0
  72. package/src/communityRepository/observers/getTrendingCommunities/enums.ts +4 -0
  73. package/src/communityRepository/observers/getTrendingCommunities.ts +10 -82
  74. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.ts +7 -2
  75. package/src/communityRepository/utils/communityWithMembership.ts +7 -4
  76. package/src/report/api/createReport.ts +2 -2
  77. package/src/report/api/deleteReport.ts +2 -2
  78. package/src/report/api/isReportedByMe.ts +5 -3
package/dist/index.esm.js CHANGED
@@ -6,6 +6,7 @@ import HttpAgent, { HttpsAgent } from 'agentkeepalive';
6
6
  import io from 'socket.io-client';
7
7
  import AsyncStorage from '@react-native-async-storage/async-storage';
8
8
  import uuid$1 from 'react-native-uuid';
9
+ import { Platform } from 'react-native';
9
10
  import hash from 'object-hash';
10
11
  import Hls from 'hls.js';
11
12
 
@@ -88,8 +89,8 @@ const PostContentType = Object.freeze({
88
89
 
89
90
  function getVersion() {
90
91
  try {
91
- // the string ''v6.30.2-esm'' should be replaced by actual value by @rollup/plugin-replace
92
- return 'v6.30.2-esm';
92
+ // the string ''v6.30.4-esm'' should be replaced by actual value by @rollup/plugin-replace
93
+ return 'v6.30.4-esm';
93
94
  }
94
95
  catch (error) {
95
96
  return '__dev__';
@@ -654,6 +655,18 @@ class ASCConnectionError extends ASCError {
654
655
  : 800210 /* Amity.ClientError.CONNECTION_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
655
656
  this.event = event;
656
657
  }
658
+ }
659
+ /**
660
+ * Input sanitization related error
661
+ * @category Errors
662
+ */
663
+ class ASCInvalidParameterError extends ASCError {
664
+ /**
665
+ * @param message A custom error message
666
+ */
667
+ constructor(message) {
668
+ super(message, 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
669
+ }
657
670
  }
658
671
 
659
672
  let activeClient = null;
@@ -25538,6 +25551,43 @@ function setUploadedFileAccessType(accessType) {
25538
25551
  GlobalFileAccessType$1.getInstance().setFileAccessType(accessType);
25539
25552
  }
25540
25553
 
25554
+ const registerPushNotification = async (deviceToken) => {
25555
+ const client = getActiveClient();
25556
+ let platform;
25557
+ if (Platform.OS === 'ios' || Platform.OS === 'android') {
25558
+ platform = Platform.OS;
25559
+ }
25560
+ else {
25561
+ throw new ASCInvalidParameterError('Unsupported platform');
25562
+ }
25563
+ const deviceId = await getDeviceId();
25564
+ const { data: { status, error }, } = await client.http.post('/v1/notification', {
25565
+ userId: client.userId,
25566
+ deviceId,
25567
+ platform,
25568
+ token: deviceToken,
25569
+ }, { headers: { 'X-API-Key': client.apiKey } });
25570
+ if (error) {
25571
+ throw new ASCApiError(error, 500000 /* Amity.ServerError.BUSINESS_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
25572
+ }
25573
+ return status === 'success';
25574
+ };
25575
+
25576
+ const unregisterPushNotification = async () => {
25577
+ const client = getActiveClient();
25578
+ const deviceId = getDeviceId();
25579
+ const { data: { status, error }, } = await client.http.delete('/v1/notification', {
25580
+ data: {
25581
+ deviceId,
25582
+ },
25583
+ headers: { 'X-API-Key': client.apiKey },
25584
+ });
25585
+ if (error) {
25586
+ throw new ASCApiError(error, 500000 /* Amity.ServerError.BUSINESS_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
25587
+ }
25588
+ return status === 'success';
25589
+ };
25590
+
25541
25591
  /**
25542
25592
  * ```js
25543
25593
  * import { onChannelMarkerFetched } from '@amityco/ts-sdk-react-native'
@@ -25999,6 +26049,8 @@ var index$l = /*#__PURE__*/Object.freeze({
25999
26049
  markerSync: markerSync,
26000
26050
  enableUnreadCount: enableUnreadCount,
26001
26051
  setUploadedFileAccessType: setUploadedFileAccessType,
26052
+ registerPushNotification: registerPushNotification,
26053
+ unregisterPushNotification: unregisterPushNotification,
26002
26054
  onConnectionError: onConnectionError,
26003
26055
  onClientDisconnected: onClientDisconnected,
26004
26056
  onClientBanned: onClientBanned,
@@ -29277,8 +29329,11 @@ function isCurrentUserPartOfCommunity(c, m) {
29277
29329
  */
29278
29330
  function updateMembershipStatus(communities, communityUsers) {
29279
29331
  return communities.map(c => {
29280
- const isJoined = communityUsers.some(m => isCurrentUserPartOfCommunity(c, m) && isMember(m.communityMembership));
29281
- return Object.assign(Object.assign({}, c), { isJoined });
29332
+ if (c.isJoined == null) {
29333
+ const isJoined = communityUsers.some(m => isCurrentUserPartOfCommunity(c, m) && isMember(m.communityMembership));
29334
+ return Object.assign(Object.assign({}, c), { isJoined });
29335
+ }
29336
+ return c;
29282
29337
  });
29283
29338
  }
29284
29339
 
@@ -30557,7 +30612,7 @@ const createMessageReport = async ({ client, referenceId, }) => {
30557
30612
  return !!payload;
30558
30613
  };
30559
30614
  const createPostReport = async ({ client, referenceId, }) => {
30560
- const { data: payload } = await client.http.post(`/api/v3/post/${encodeURIComponent(referenceId)}/flag`);
30615
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(referenceId)}/flag`);
30561
30616
  if (client.cache) {
30562
30617
  const postPayload = await preparePostPayload(payload);
30563
30618
  ingestInCache(postPayload);
@@ -30575,7 +30630,7 @@ const createUserReport = async ({ client, referenceId, }) => {
30575
30630
  return !!payload;
30576
30631
  };
30577
30632
  const createCommentReport = async ({ client, referenceId, }) => {
30578
- const { data: payload } = await client.http.post(`/api/v3/comment/${encodeURIComponent(referenceId)}/flag`);
30633
+ const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(referenceId)}/flag`);
30579
30634
  if (client.cache) {
30580
30635
  const commentPayload = await prepareCommentPayload(payload);
30581
30636
  ingestInCache(commentPayload);
@@ -30624,7 +30679,7 @@ const deleteMessageReport = async ({ client, referenceId, }) => {
30624
30679
  return !!payload;
30625
30680
  };
30626
30681
  const deletePostReport = async ({ client, referenceId, }) => {
30627
- const { data: payload } = await client.http.delete(`/api/v3/post/${encodeURIComponent(referenceId)}/flag`);
30682
+ const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(referenceId)}/unflag`);
30628
30683
  if (client.cache) {
30629
30684
  const postPayload = await preparePostPayload(payload);
30630
30685
  ingestInCache(postPayload);
@@ -30642,7 +30697,7 @@ const deleteUserReport = async ({ client, referenceId, }) => {
30642
30697
  return !!payload;
30643
30698
  };
30644
30699
  const deleteCommentReport = async ({ client, referenceId, }) => {
30645
- const { data: payload } = await client.http.delete(`/api/v3/comment/${encodeURIComponent(referenceId)}/flag`);
30700
+ const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(referenceId)}/unflag`);
30646
30701
  if (client.cache) {
30647
30702
  const commentPayload = await prepareCommentPayload(payload);
30648
30703
  ingestInCache(commentPayload);
@@ -30689,19 +30744,19 @@ const getMessageReport = async ({ client, referenceId, }) => {
30689
30744
  };
30690
30745
  const getPostReport = async ({ client, referenceId, }) => {
30691
30746
  var _a;
30692
- const { data } = await client.http.get(`/api/v3/user/${referenceId}/isflagbyme`);
30747
+ const { data } = await client.http.get(`/api/v3/posts/${referenceId}/isflagbyme`);
30693
30748
  const { result, isFlagByMe } = data !== null && data !== void 0 ? data : {};
30694
30749
  return (_a = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _a !== void 0 ? _a : false;
30695
30750
  };
30696
30751
  const getUserReport = async ({ client, referenceId, }) => {
30697
30752
  var _a;
30698
- const { data } = await client.http.get(`/api/v3/user/${referenceId}/isflagbyme`);
30753
+ const { data } = await client.http.get(`/api/v3/users/${referenceId}/isflagbyme`);
30699
30754
  const { result, isFlagByMe } = data !== null && data !== void 0 ? data : {};
30700
30755
  return (_a = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _a !== void 0 ? _a : false;
30701
30756
  };
30702
30757
  const getCommentReport = async ({ client, referenceId, }) => {
30703
30758
  var _a;
30704
- const { data } = await client.http.get(`/api/v3/comment/${referenceId}/isflagbyme`);
30759
+ const { data } = await client.http.get(`/api/v3/comments/${referenceId}/isflagbyme`);
30705
30760
  const { result, isFlagByMe } = data !== null && data !== void 0 ? data : {};
30706
30761
  return (_a = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _a !== void 0 ? _a : false;
30707
30762
  };
@@ -34940,7 +34995,7 @@ const joinCommunity = async (communityId) => {
34940
34995
  const client = getActiveClient();
34941
34996
  client.log('community/joinCommunity', communityId);
34942
34997
  const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/join`);
34943
- fireEvent('community.joined', payload);
34998
+ fireEvent('local.community.joined', payload);
34944
34999
  const data = prepareCommunityPayload(payload);
34945
35000
  const cachedAt = client.cache && Date.now();
34946
35001
  if (client.cache)
@@ -34971,7 +35026,7 @@ const leaveCommunity = async (communityId) => {
34971
35026
  const client = getActiveClient();
34972
35027
  client.log('community/leaveCommunity', communityId);
34973
35028
  const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/leave`);
34974
- fireEvent('community.left', payload);
35029
+ fireEvent('local.community.left', payload);
34975
35030
  const data = prepareCommunityPayload(payload);
34976
35031
  const cachedAt = client.cache && Date.now();
34977
35032
  if (client.cache)
@@ -35136,8 +35191,6 @@ function getEventRelatedMember(event, payload) {
35136
35191
  if (event === 'community.joined' || event === 'community.left') {
35137
35192
  return payload.communityUsers;
35138
35193
  }
35139
- // NOTE: backend returns the one who took the action and the one on whom
35140
- // the action was taken. We need the 2nd one
35141
35194
  if (event === 'community.userRemoved' || event === 'local.community.userRemoved') {
35142
35195
  return payload.communityUsers.filter(x => x.communityMembership === 'none');
35143
35196
  }
@@ -35412,6 +35465,10 @@ const onCommunityJoined = (callback) => createCommunityMemberEventSubscriber('co
35412
35465
  */
35413
35466
  const onCommunityLeft = (callback) => createCommunityMemberEventSubscriber('community.left', callback);
35414
35467
 
35468
+ const onLocalCommunityJoined = (callback) => createLocalCommunityMemberEventSubscriber('local.community.joined', callback);
35469
+
35470
+ const onLocalCommunityLeft = (callback) => createLocalCommunityMemberEventSubscriber('local.community.left', callback);
35471
+
35415
35472
  /**
35416
35473
  * ```js
35417
35474
  * import { observeCommunity } from '@amityco/ts-sdk-react-native'
@@ -35513,12 +35570,12 @@ class CommunitiesQueryStreamController$1 extends QueryStreamController {
35513
35570
  }
35514
35571
  }
35515
35572
 
35516
- var EnumCommunityActions$1;
35573
+ var EnumCommunityActions$3;
35517
35574
  (function (EnumCommunityActions) {
35518
35575
  EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
35519
35576
  EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
35520
35577
  EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
35521
- })(EnumCommunityActions$1 || (EnumCommunityActions$1 = {}));
35578
+ })(EnumCommunityActions$3 || (EnumCommunityActions$3 = {}));
35522
35579
 
35523
35580
  var EnumCommunityMemberActions$1;
35524
35581
  (function (EnumCommunityMemberActions) {
@@ -35797,7 +35854,9 @@ class CommunityMembersLiveCollectionController extends LiveCollectionController
35797
35854
  startSubscription() {
35798
35855
  return this.queryStreamController.subscribeRTE([
35799
35856
  { fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
35857
+ { fn: onLocalCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
35800
35858
  { fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
35859
+ { fn: onLocalCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
35801
35860
  { fn: onCommunityUserBanned, action: EnumCommunityMemberActions$1.OnCommunityUserBanned },
35802
35861
  { fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnCommunityUserChanged },
35803
35862
  { fn: onCommunityUserRoleAdded, action: EnumCommunityMemberActions$1.OnCommunityUserRoleAdded },
@@ -36057,7 +36116,9 @@ class SearchCommunityMembersLiveCollectionController extends LiveCollectionContr
36057
36116
  startSubscription() {
36058
36117
  return this.queryStreamController.subscribeRTE([
36059
36118
  { fn: onCommunityJoined, action: EnumCommunityMemberActions.OnCommunityJoined },
36119
+ { fn: onLocalCommunityJoined, action: EnumCommunityMemberActions.OnCommunityJoined },
36060
36120
  { fn: onCommunityLeft, action: EnumCommunityMemberActions.OnCommunityLeft },
36121
+ { fn: onLocalCommunityLeft, action: EnumCommunityMemberActions.OnCommunityLeft },
36061
36122
  { fn: onCommunityUserBanned, action: EnumCommunityMemberActions.OnCommunityUserBanned },
36062
36123
  { fn: onCommunityUserChanged, action: EnumCommunityMemberActions.OnCommunityUserChanged },
36063
36124
  {
@@ -36172,7 +36233,9 @@ var index$b = /*#__PURE__*/Object.freeze({
36172
36233
  onLocalCommunityUserAdded: onLocalCommunityUserAdded,
36173
36234
  onLocalCommunityUserRemoved: onLocalCommunityUserRemoved,
36174
36235
  onCommunityJoined: onCommunityJoined,
36175
- onCommunityLeft: onCommunityLeft
36236
+ onCommunityLeft: onCommunityLeft,
36237
+ onLocalCommunityJoined: onLocalCommunityJoined,
36238
+ onLocalCommunityLeft: onLocalCommunityLeft
36176
36239
  });
36177
36240
 
36178
36241
  class SearchCommunityLiveCollectionController extends LiveCollectionController {
@@ -36204,11 +36267,13 @@ class SearchCommunityLiveCollectionController extends LiveCollectionController {
36204
36267
  }
36205
36268
  startSubscription() {
36206
36269
  return this.queryStreamController.subscribeRTE([
36207
- { fn: onCommunityDeleted, action: EnumCommunityActions$1.OnCommunityDeleted },
36208
- { fn: onCommunityUpdated, action: EnumCommunityActions$1.OnCommunityUpdated },
36270
+ { fn: onCommunityDeleted, action: EnumCommunityActions$3.OnCommunityDeleted },
36271
+ { fn: onCommunityUpdated, action: EnumCommunityActions$3.OnCommunityUpdated },
36209
36272
  { fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
36210
36273
  { fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
36211
36274
  { fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
36275
+ { fn: onLocalCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
36276
+ { fn: onLocalCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
36212
36277
  ]);
36213
36278
  }
36214
36279
  notifyChange({ origin, loading, error }) {
@@ -36218,7 +36283,7 @@ class SearchCommunityLiveCollectionController extends LiveCollectionController {
36218
36283
  return;
36219
36284
  const data = this.applyFilter((_b = collection.data
36220
36285
  .map(id => pullFromCache(['community', 'get', id]))
36221
- .filter(Boolean)
36286
+ .filter(isNonNullable)
36222
36287
  .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []);
36223
36288
  if (!this.shouldNotify(data) && origin === 'event')
36224
36289
  return;
@@ -36303,12 +36368,12 @@ class CommunitiesPaginationController extends PaginationController {
36303
36368
  }
36304
36369
  }
36305
36370
 
36306
- var EnumCommunityActions;
36371
+ var EnumCommunityActions$2;
36307
36372
  (function (EnumCommunityActions) {
36308
36373
  EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
36309
36374
  EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
36310
36375
  EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
36311
- })(EnumCommunityActions || (EnumCommunityActions = {}));
36376
+ })(EnumCommunityActions$2 || (EnumCommunityActions$2 = {}));
36312
36377
 
36313
36378
  class CommunitiesQueryStreamController extends QueryStreamController {
36314
36379
  constructor(query, cacheKey, notifyChange, preparePayload) {
@@ -36344,7 +36409,7 @@ class CommunitiesQueryStreamController extends QueryStreamController {
36344
36409
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36345
36410
  if (!collection)
36346
36411
  return;
36347
- if (this.query.displayName && action === EnumCommunityActions.OnCommunityCreated) {
36412
+ if (this.query.displayName && action === EnumCommunityActions$2.OnCommunityCreated) {
36348
36413
  return;
36349
36414
  }
36350
36415
  /*
@@ -36389,12 +36454,14 @@ class CommunityLiveCollectionController extends LiveCollectionController {
36389
36454
  }
36390
36455
  startSubscription() {
36391
36456
  return this.queryStreamController.subscribeRTE([
36392
- { fn: onCommunityCreated, action: EnumCommunityActions.OnCommunityCreated },
36393
- { fn: onCommunityDeleted, action: EnumCommunityActions.OnCommunityDeleted },
36394
- { fn: onCommunityUpdated, action: EnumCommunityActions.OnCommunityUpdated },
36457
+ { fn: onCommunityCreated, action: EnumCommunityActions$2.OnCommunityCreated },
36458
+ { fn: onCommunityDeleted, action: EnumCommunityActions$2.OnCommunityDeleted },
36459
+ { fn: onCommunityUpdated, action: EnumCommunityActions$2.OnCommunityUpdated },
36395
36460
  { fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
36396
36461
  { fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
36397
36462
  { fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
36463
+ { fn: onLocalCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
36464
+ { fn: onLocalCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
36398
36465
  ]);
36399
36466
  }
36400
36467
  notifyChange({ origin, loading, error }) {
@@ -36404,7 +36471,7 @@ class CommunityLiveCollectionController extends LiveCollectionController {
36404
36471
  return;
36405
36472
  const data = this.applyFilter((_b = collection.data
36406
36473
  .map(id => pullFromCache(['community', 'get', id]))
36407
- .filter(Boolean)
36474
+ .filter(isNonNullable)
36408
36475
  .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []);
36409
36476
  if (!this.shouldNotify(data) && origin === 'event')
36410
36477
  return;
@@ -36517,6 +36584,8 @@ const getCommunity = (communityId, callback) => {
36517
36584
  onCommunityDeleted,
36518
36585
  onCommunityJoined,
36519
36586
  onCommunityLeft,
36587
+ onLocalCommunityJoined,
36588
+ onLocalCommunityLeft,
36520
36589
  onCommunityUserBanned,
36521
36590
  onCommunityUserUnbanned,
36522
36591
  onCommunityUserChanged,
@@ -36525,71 +36594,128 @@ const getCommunity = (communityId, callback) => {
36525
36594
  /* end_public_function */
36526
36595
 
36527
36596
  /**
36528
- * ```js
36529
- * import { CommunityRepository } from '@amityco/ts-sdk-react-native'
36530
- * const trendingCommunities = await CommunityRepository.getTrendingCommunities()
36531
- * ```
36532
- *
36533
- * Gets a list of top trending {@link Amity.Community} objects
36534
- *
36535
- * @param query The query parameters
36536
- * @returns A list of {@link Amity.Community} objects
36537
- *
36538
- * @category Community API
36539
- * @async
36540
- * @private
36597
+ * TODO: handle cache receive cache option, and cache policy
36598
+ * TODO: check if querybyIds is supported
36541
36599
  */
36542
- const getTrendingCommunities$1 = async (query) => {
36543
- const client = getActiveClient();
36544
- client.log('community/getTrendingCommunities', query);
36545
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = query !== null && query !== void 0 ? query : {};
36546
- // API-FIX: backend doesnt answer Amity.Response
36547
- // const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
36548
- const { data: payload } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
36549
- const data = prepareCommunityPayload(payload);
36550
- const { communities } = data;
36551
- const cachedAt = client.cache && Date.now();
36552
- if (client.cache) {
36553
- ingestInCache(data, { cachedAt });
36600
+ class TrendingCommunitiesPaginationController extends PaginationController {
36601
+ async getRequest(queryParams, token) {
36602
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
36603
+ const options = token ? { token } : { limit };
36604
+ const { data: queryResponse } = await this.http.get(`/api/v3/communities/top-trending`, {
36605
+ params: Object.assign(Object.assign({}, params), { options }),
36606
+ });
36607
+ return queryResponse;
36554
36608
  }
36555
- return { data: communities, cachedAt };
36556
- };
36609
+ }
36557
36610
 
36558
- const communityQueryFilter = (data, params, userId) => {
36559
- let communities = data;
36560
- communities = filterByPropEquality(communities, 'displayName', params.displayName);
36561
- if (!params.includeDeleted) {
36562
- communities = filterByPropEquality(communities, 'isDeleted', false);
36611
+ class TrendingCommunitiesQueryStreamController extends QueryStreamController {
36612
+ constructor(query, cacheKey, notifyChange, preparePayload) {
36613
+ super(query, cacheKey);
36614
+ this.notifyChange = notifyChange;
36615
+ this.preparePayload = preparePayload;
36563
36616
  }
36564
- if (params.categoryId) {
36565
- communities = communities.filter(c => { var _a; return (_a = c.categoryIds) === null || _a === void 0 ? void 0 : _a.includes(params.categoryId); });
36617
+ async saveToMainDB(response) {
36618
+ const processedPayload = await this.preparePayload(response);
36619
+ const client = getActiveClient();
36620
+ const cachedAt = client.cache && Date.now();
36621
+ if (client.cache) {
36622
+ ingestInCache(processedPayload, { cachedAt });
36623
+ saveCommunityUsers(response.communities, response.communityUsers);
36624
+ }
36566
36625
  }
36567
- if (params.tags) {
36568
- communities = communities.filter(c => { var _a; return (_a = c.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.tags) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
36626
+ appendToQueryStream(response, direction, refresh = false) {
36627
+ var _a, _b;
36628
+ if (refresh) {
36629
+ pushToCache(this.cacheKey, {
36630
+ data: response.communities.map(getResolver('community')),
36631
+ });
36632
+ }
36633
+ else {
36634
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36635
+ const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
36636
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...communities, ...response.communities.map(getResolver('community'))])] }));
36637
+ }
36569
36638
  }
36570
- if (params.membership && userId) {
36571
- communities = filterByCommunityMembership(communities, params.membership, userId);
36639
+ reactor(action) {
36640
+ return (community) => {
36641
+ var _a;
36642
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36643
+ if (!collection)
36644
+ return;
36645
+ pushToCache(this.cacheKey, collection);
36646
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
36647
+ };
36572
36648
  }
36573
- const sortBy = params.sortBy || 'lastCreated';
36574
- if (sortBy === 'lastCreated' || sortBy === 'firstCreated') {
36575
- communities = communities.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
36649
+ subscribeRTE(createSubscriber) {
36650
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
36576
36651
  }
36577
- /*
36578
- * The server returns communities with empty | null displayName's first before
36579
- * returning sorted list of communities with displayNames
36580
- *
36581
- * This section needs to be updated as displayNames can be null as well
36582
- */
36583
- if (sortBy === 'displayName') {
36584
- communities = communities
36585
- // this needs to be aligned with the backend data type
36586
- .map(c => (c.displayName ? c : Object.assign(Object.assign({}, c), { displayName: '' })))
36587
- .sort(sortByDisplayName);
36652
+ }
36653
+
36654
+ var EnumCommunityActions$1;
36655
+ (function (EnumCommunityActions) {
36656
+ EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
36657
+ EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
36658
+ })(EnumCommunityActions$1 || (EnumCommunityActions$1 = {}));
36659
+
36660
+ class TrendingCommunityLiveCollectionController extends LiveCollectionController {
36661
+ constructor(query, callback) {
36662
+ const queryStreamId = hash(query);
36663
+ const cacheKey = ['trendingCommunity', 'collection', queryStreamId];
36664
+ const paginationController = new TrendingCommunitiesPaginationController(query);
36665
+ super(paginationController, queryStreamId, cacheKey, callback);
36666
+ this.query = query;
36667
+ this.queryStreamController = new TrendingCommunitiesQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommunityPayload);
36668
+ this.callback = callback.bind(this);
36669
+ this.loadPage({ initial: true });
36588
36670
  }
36589
- return communities;
36590
- };
36671
+ setup() {
36672
+ var _a;
36673
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36674
+ if (!collection) {
36675
+ pushToCache(this.cacheKey, {
36676
+ data: [],
36677
+ params: {},
36678
+ });
36679
+ }
36680
+ }
36681
+ async persistModel(queryPayload) {
36682
+ await this.queryStreamController.saveToMainDB(queryPayload);
36683
+ }
36684
+ persistQueryStream({ response, direction, refresh, }) {
36685
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
36686
+ }
36687
+ startSubscription() {
36688
+ return this.queryStreamController.subscribeRTE([
36689
+ { fn: onCommunityDeleted, action: EnumCommunityActions$1.OnCommunityDeleted },
36690
+ { fn: onCommunityUpdated, action: EnumCommunityActions$1.OnCommunityUpdated },
36691
+ { fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
36692
+ { fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
36693
+ { fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
36694
+ { fn: onLocalCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
36695
+ { fn: onLocalCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
36696
+ ]);
36697
+ }
36698
+ notifyChange({ origin, loading, error }) {
36699
+ var _a, _b;
36700
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36701
+ if (!collection)
36702
+ return;
36703
+ const data = (_b = collection.data
36704
+ .map(id => pullFromCache(['community', 'get', id]))
36705
+ .filter(isNonNullable)
36706
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
36707
+ if (!this.shouldNotify(data) && origin === 'event')
36708
+ return;
36709
+ this.callback({
36710
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
36711
+ data,
36712
+ hasNextPage: !!this.paginationController.getNextToken(),
36713
+ loading,
36714
+ error,
36715
+ });
36716
+ }
36717
+ }
36591
36718
 
36592
- /* eslint-disable no-use-before-define */
36593
36719
  /* begin_public_function
36594
36720
  id: community.query.trending_communities
36595
36721
  */
@@ -36618,60 +36744,9 @@ const getTrendingCommunities = (params, callback, config) => {
36618
36744
  }
36619
36745
  const timestamp = Date.now();
36620
36746
  log(`getTrendingCommunities(tmpid: ${timestamp}) > listen`);
36621
- const { limit: queryLimit } = params;
36622
- const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
36623
- const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
36624
- const disposers = [];
36625
- const cacheKey = ['community', 'top-trending', { params: { options: { limit } } }];
36626
- const responder = (data, isEventModel = false) => {
36627
- var _a, _b;
36628
- const communities = (_a = data.data
36629
- .map(communityId => pullFromCache(['community', 'get', communityId]))
36630
- .filter(Boolean)
36631
- .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
36632
- callback({
36633
- onNextPage: onFetch,
36634
- data: isEventModel ? communityQueryFilter(communities, params, userId) : communities,
36635
- hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
36636
- loading: data.loading,
36637
- error: data.error,
36638
- });
36639
- };
36640
- const realtimeRouter = (_) => (community) => {
36641
- var _a;
36642
- const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36643
- if (!collection)
36644
- return;
36645
- /*
36646
- * Simply update collection and let responder decide what to do with data
36647
- */
36648
- collection.data = [...new Set([community.communityId, ...collection.data])];
36649
- pushToCache(cacheKey, collection);
36650
- responder(collection);
36651
- };
36652
- const onFetch = (initial = false) => {
36653
- var _a, _b;
36654
- const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36655
- const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
36656
- if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
36657
- return;
36658
- const query = createQuery(getTrendingCommunities$1, params);
36659
- runQuery(query, ({ data: result, error, loading }) => {
36660
- const data = {
36661
- loading,
36662
- error,
36663
- params,
36664
- data: communities,
36665
- };
36666
- if (result) {
36667
- data.data = [...new Set([...communities, ...result.map(getResolver('community'))])];
36668
- }
36669
- pushToCache(cacheKey, data);
36670
- responder(data);
36671
- }, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
36672
- };
36673
- disposers.push(onCommunityUserChanged(realtimeRouter()));
36674
- onFetch(true);
36747
+ const trendingCommunitiesLiveCollection = new TrendingCommunityLiveCollectionController(params, callback);
36748
+ const disposers = trendingCommunitiesLiveCollection.startSubscription();
36749
+ const cacheKey = trendingCommunitiesLiveCollection.getCacheKey();
36675
36750
  disposers.push(() => dropFromCache(cacheKey));
36676
36751
  return () => {
36677
36752
  log(`getTrendingCommunities(tmpid: ${timestamp}) > dispose`);
@@ -36680,39 +36755,128 @@ const getTrendingCommunities = (params, callback, config) => {
36680
36755
  };
36681
36756
  /* end_public_function */
36682
36757
 
36683
- /* begin_public_function
36684
- id: community.query.recommended_communities
36685
- */
36686
36758
  /**
36687
- * ```js
36688
- * import { CommunityRepository } from '@amityco/ts-sdk-react-native'
36689
- * const communities = await CommunityRepository.getRecommendedCommunities()
36690
- * ```
36691
- *
36692
- * Gets a list of recommended {@link Amity.Community} objects
36693
- *
36694
- * @param query The query parameters
36695
- * @returns A list of {@link Amity.Community} objects
36696
- *
36697
- * @category Community API
36698
- * @async
36699
- * @private
36759
+ * TODO: handle cache receive cache option, and cache policy
36760
+ * TODO: check if querybyIds is supported
36700
36761
  */
36701
- const getRecommendedCommunities$1 = async (query) => {
36702
- const client = getActiveClient();
36703
- client.log('community/getRecommendedCommunities', query);
36704
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = query !== null && query !== void 0 ? query : {};
36705
- // API-FIX: backend doesnt answer Amity.Response
36706
- // const { data: payload } = await client.http.get<Amity.Response<CommunityPayload>>(
36707
- const { data: payload } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
36708
- const data = prepareCommunityPayload(payload);
36709
- const { communities } = data;
36710
- const cachedAt = client.cache && Date.now();
36711
- if (client.cache) {
36712
- ingestInCache(data, { cachedAt });
36762
+ class RecommendedCommunitiesPaginationController extends PaginationController {
36763
+ async getRequest(queryParams, token) {
36764
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
36765
+ const options = token ? { token } : { limit };
36766
+ const { data: queryResponse } = await this.http.get(`/api/v3/communities/recommended`, {
36767
+ params: Object.assign(Object.assign({}, params), { options }),
36768
+ });
36769
+ return queryResponse;
36713
36770
  }
36714
- return { data: communities, cachedAt };
36715
- };
36771
+ }
36772
+
36773
+ class RecommendedCommunitiesQueryStreamController extends QueryStreamController {
36774
+ constructor(query, cacheKey, notifyChange, preparePayload) {
36775
+ super(query, cacheKey);
36776
+ this.notifyChange = notifyChange;
36777
+ this.preparePayload = preparePayload;
36778
+ }
36779
+ async saveToMainDB(response) {
36780
+ const processedPayload = await this.preparePayload(response);
36781
+ const client = getActiveClient();
36782
+ const cachedAt = client.cache && Date.now();
36783
+ if (client.cache) {
36784
+ ingestInCache(processedPayload, { cachedAt });
36785
+ saveCommunityUsers(response.communities, response.communityUsers);
36786
+ }
36787
+ }
36788
+ appendToQueryStream(response, direction, refresh = false) {
36789
+ var _a, _b;
36790
+ if (refresh) {
36791
+ pushToCache(this.cacheKey, {
36792
+ data: response.communities.map(getResolver('community')),
36793
+ });
36794
+ }
36795
+ else {
36796
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36797
+ const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
36798
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...communities, ...response.communities.map(getResolver('community'))])] }));
36799
+ }
36800
+ }
36801
+ reactor(action) {
36802
+ return (community) => {
36803
+ var _a;
36804
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36805
+ if (!collection)
36806
+ return;
36807
+ pushToCache(this.cacheKey, collection);
36808
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
36809
+ };
36810
+ }
36811
+ subscribeRTE(createSubscriber) {
36812
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
36813
+ }
36814
+ }
36815
+
36816
+ var EnumCommunityActions;
36817
+ (function (EnumCommunityActions) {
36818
+ EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
36819
+ EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
36820
+ })(EnumCommunityActions || (EnumCommunityActions = {}));
36821
+
36822
+ class RecommendedCommunityLiveCollectionController extends LiveCollectionController {
36823
+ constructor(query, callback) {
36824
+ const queryStreamId = hash(query);
36825
+ const cacheKey = ['community', 'collection', queryStreamId];
36826
+ const paginationController = new RecommendedCommunitiesPaginationController(query);
36827
+ super(paginationController, queryStreamId, cacheKey, callback);
36828
+ this.query = query;
36829
+ this.queryStreamController = new RecommendedCommunitiesQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommunityPayload);
36830
+ this.callback = callback.bind(this);
36831
+ this.loadPage({ initial: true });
36832
+ }
36833
+ setup() {
36834
+ var _a;
36835
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36836
+ if (!collection) {
36837
+ pushToCache(this.cacheKey, {
36838
+ data: [],
36839
+ params: {},
36840
+ });
36841
+ }
36842
+ }
36843
+ async persistModel(queryPayload) {
36844
+ await this.queryStreamController.saveToMainDB(queryPayload);
36845
+ }
36846
+ persistQueryStream({ response, direction, refresh, }) {
36847
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
36848
+ }
36849
+ startSubscription() {
36850
+ return this.queryStreamController.subscribeRTE([
36851
+ { fn: onCommunityDeleted, action: EnumCommunityActions.OnCommunityDeleted },
36852
+ { fn: onCommunityUpdated, action: EnumCommunityActions.OnCommunityUpdated },
36853
+ { fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
36854
+ { fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
36855
+ { fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
36856
+ { fn: onLocalCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
36857
+ { fn: onLocalCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
36858
+ ]);
36859
+ }
36860
+ notifyChange({ origin, loading, error }) {
36861
+ var _a, _b;
36862
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36863
+ if (!collection)
36864
+ return;
36865
+ const data = (_b = collection.data
36866
+ .map(id => pullFromCache(['community', 'get', id]))
36867
+ .filter(isNonNullable)
36868
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
36869
+ if (!this.shouldNotify(data) && origin === 'event')
36870
+ return;
36871
+ this.callback({
36872
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
36873
+ data,
36874
+ hasNextPage: !!this.paginationController.getNextToken(),
36875
+ loading,
36876
+ error,
36877
+ });
36878
+ }
36879
+ }
36716
36880
 
36717
36881
  /* begin_public_function
36718
36882
  id: community.query.recommended_communities
@@ -36742,60 +36906,9 @@ const getRecommendedCommunities = (params, callback, config) => {
36742
36906
  }
36743
36907
  const timestamp = Date.now();
36744
36908
  log(`getRecommendedCommunities(tmpid: ${timestamp}) > listen`);
36745
- const { limit: queryLimit } = params; __rest(params, ["limit"]);
36746
- const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
36747
- const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
36748
- const disposers = [];
36749
- const cacheKey = ['community', 'recommended', { params: { options: { limit } } }];
36750
- const responder = (data, isEventModel = false) => {
36751
- var _a, _b;
36752
- const communities = (_a = data.data
36753
- .map(communityId => pullFromCache(['community', 'get', communityId]))
36754
- .filter(Boolean)
36755
- .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
36756
- callback({
36757
- onNextPage: onFetch,
36758
- data: isEventModel ? communityQueryFilter(communities, params, userId) : communities,
36759
- hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
36760
- loading: data.loading,
36761
- error: data.error,
36762
- });
36763
- };
36764
- const realtimeRouter = (_) => (community) => {
36765
- var _a;
36766
- const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36767
- if (!collection)
36768
- return;
36769
- /*
36770
- * Simply update collection and let responder decide what to do with data
36771
- */
36772
- collection.data = [...new Set([community.communityId, ...collection.data])];
36773
- pushToCache(cacheKey, collection);
36774
- responder(collection);
36775
- };
36776
- const onFetch = (initial = false) => {
36777
- var _a, _b;
36778
- const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
36779
- const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
36780
- if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
36781
- return;
36782
- const query = createQuery(getRecommendedCommunities$1, params);
36783
- runQuery(query, ({ data: result, error, loading }) => {
36784
- const data = {
36785
- loading,
36786
- error,
36787
- params,
36788
- data: communities,
36789
- };
36790
- if (result) {
36791
- data.data = [...new Set([...communities, ...result.map(getResolver('community'))])];
36792
- }
36793
- pushToCache(cacheKey, data);
36794
- responder(data);
36795
- }, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
36796
- };
36797
- disposers.push(onCommunityUserChanged(realtimeRouter()));
36798
- onFetch(true);
36909
+ const recommendedCommunitiesLiveCollection = new RecommendedCommunityLiveCollectionController(params, callback);
36910
+ const disposers = recommendedCommunitiesLiveCollection.startSubscription();
36911
+ const cacheKey = recommendedCommunitiesLiveCollection.getCacheKey();
36799
36912
  disposers.push(() => dropFromCache(cacheKey));
36800
36913
  return () => {
36801
36914
  log(`getRecommendedCommunities(tmpid: ${timestamp}) > dispose`);
@@ -40700,7 +40813,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
40700
40813
  getPoll: getPoll
40701
40814
  });
40702
40815
 
40703
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
40816
+ 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-----";
40704
40817
  /*
40705
40818
  * The crypto algorithm used for importing key and signing string
40706
40819
  */