@amityco/ts-sdk-react-native 6.33.0 → 6.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/core/payload.d.ts +8 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +16 -0
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +1 -0
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +4 -2
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/communityRepository/constants/index.d.ts +6 -0
- package/dist/communityRepository/constants/index.d.ts.map +1 -0
- package/dist/communityRepository/index.d.ts +1 -0
- package/dist/communityRepository/index.d.ts.map +1 -1
- package/dist/communityRepository/observers/index.d.ts +1 -0
- package/dist/communityRepository/observers/index.d.ts.map +1 -1
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.d.ts +14 -0
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.d.ts.map +1 -0
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.d.ts +10 -0
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.d.ts.map +1 -0
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +16 -0
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -0
- package/dist/communityRepository/observers/semanticSearch/enums.d.ts +6 -0
- package/dist/communityRepository/observers/semanticSearch/enums.d.ts.map +1 -0
- package/dist/communityRepository/observers/semanticSearch/utils.d.ts +3 -0
- package/dist/communityRepository/observers/semanticSearch/utils.d.ts.map +1 -0
- package/dist/communityRepository/observers/semanticSearchCommunities.d.ts +10 -0
- package/dist/communityRepository/observers/semanticSearchCommunities.d.ts.map +1 -0
- package/dist/communityRepository/utils/payload.d.ts +1 -0
- package/dist/communityRepository/utils/payload.d.ts.map +1 -1
- package/dist/index.cjs.js +241 -28
- package/dist/index.esm.js +241 -28
- package/dist/index.umd.js +3 -3
- package/dist/userRepository/constants/index.d.ts +5 -0
- package/dist/userRepository/constants/index.d.ts.map +1 -0
- package/dist/userRepository/index.d.ts +1 -0
- package/dist/userRepository/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/messageLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/payload.ts +7 -0
- package/src/@types/domains/community.ts +24 -0
- package/src/@types/domains/message.ts +1 -0
- package/src/@types/domains/user.ts +6 -2
- package/src/communityRepository/constants/index.ts +5 -0
- package/src/communityRepository/index.ts +1 -0
- package/src/communityRepository/observers/index.ts +2 -0
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.ts +164 -0
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.ts +36 -0
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +86 -0
- package/src/communityRepository/observers/semanticSearch/enums.ts +5 -0
- package/src/communityRepository/observers/semanticSearch/utils.ts +16 -0
- package/src/communityRepository/observers/semanticSearchCommunities.ts +42 -0
- package/src/communityRepository/utils/payload.ts +11 -0
- package/src/postRepository/observers/getGlobalPinnedPosts.ts +3 -3
- package/src/reactionRepository/observers/getReactions/getReactions.ts +3 -3
- package/src/userRepository/constants/index.ts +4 -0
- package/src/userRepository/index.ts +1 -0
- package/src/utils/linkedObject/messageLinkedObject.ts +4 -0
package/dist/index.esm.js
CHANGED
|
@@ -89,8 +89,8 @@ const PostContentType = Object.freeze({
|
|
|
89
89
|
|
|
90
90
|
function getVersion() {
|
|
91
91
|
try {
|
|
92
|
-
// the string ''v6.
|
|
93
|
-
return 'v6.
|
|
92
|
+
// the string ''v6.34.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
93
|
+
return 'v6.34.0-esm';
|
|
94
94
|
}
|
|
95
95
|
catch (error) {
|
|
96
96
|
return '__dev__';
|
|
@@ -21968,6 +21968,10 @@ const messageLinkedObject = (message) => {
|
|
|
21968
21968
|
},
|
|
21969
21969
|
get deliveredCount() {
|
|
21970
21970
|
return getMessageReadCount(message).deliveredCount;
|
|
21971
|
+
},
|
|
21972
|
+
get creator() {
|
|
21973
|
+
var _a;
|
|
21974
|
+
return (_a = pullFromCache(['user', 'get', message.creatorId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21971
21975
|
}, markRead: () => markReadMessage(message) });
|
|
21972
21976
|
};
|
|
21973
21977
|
|
|
@@ -28652,6 +28656,12 @@ const getReachedUsers = (params, callback) => {
|
|
|
28652
28656
|
};
|
|
28653
28657
|
};
|
|
28654
28658
|
|
|
28659
|
+
var AmityUserSearchMatchType;
|
|
28660
|
+
(function (AmityUserSearchMatchType) {
|
|
28661
|
+
AmityUserSearchMatchType["DEFAULT"] = "default";
|
|
28662
|
+
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
28663
|
+
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
28664
|
+
|
|
28655
28665
|
var index$j = /*#__PURE__*/Object.freeze({
|
|
28656
28666
|
__proto__: null,
|
|
28657
28667
|
Relationship: index$k,
|
|
@@ -28671,7 +28681,8 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
28671
28681
|
getBlockedUsers: getBlockedUsers$1,
|
|
28672
28682
|
searchUserByDisplayName: searchUserByDisplayName,
|
|
28673
28683
|
getViewedUsers: getViewedUsers,
|
|
28674
|
-
getReachedUsers: getReachedUsers
|
|
28684
|
+
getReachedUsers: getReachedUsers,
|
|
28685
|
+
get AmityUserSearchMatchType () { return AmityUserSearchMatchType; }
|
|
28675
28686
|
});
|
|
28676
28687
|
|
|
28677
28688
|
/* begin_public_function
|
|
@@ -29834,6 +29845,11 @@ const prepareCommunityRequest = (params) => {
|
|
|
29834
29845
|
return Object.assign(Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined)), {
|
|
29835
29846
|
// Convert story setting to the actual value. (Allow by default)
|
|
29836
29847
|
allowCommentInStory: typeof (storySetting === null || storySetting === void 0 ? void 0 : storySetting.enableComment) === 'boolean' ? storySetting.enableComment : true });
|
|
29848
|
+
};
|
|
29849
|
+
const prepareSemanticSearchCommunityPayload = (_a) => {
|
|
29850
|
+
var communityPayload = __rest(_a, ["searchResult"]);
|
|
29851
|
+
const processedCommunityPayload = prepareCommunityPayload(communityPayload);
|
|
29852
|
+
return Object.assign({}, processedCommunityPayload);
|
|
29837
29853
|
};
|
|
29838
29854
|
|
|
29839
29855
|
const preparePostPayload = (payload) => {
|
|
@@ -30888,9 +30904,9 @@ class ReactionLiveCollectionController extends LiveCollectionController {
|
|
|
30888
30904
|
*/
|
|
30889
30905
|
const getReactions = (params, callback, config) => {
|
|
30890
30906
|
const { log, cache } = getActiveClient();
|
|
30891
|
-
if (!cache) {
|
|
30892
|
-
|
|
30893
|
-
}
|
|
30907
|
+
// if (!cache) {
|
|
30908
|
+
// console.log('For using Live Collection feature you need to enable Cache!');
|
|
30909
|
+
// }
|
|
30894
30910
|
const timestamp = Date.now();
|
|
30895
30911
|
log(`getReactions(tmpid: ${timestamp}) > listen`);
|
|
30896
30912
|
const reactionLiveCollection = new ReactionLiveCollectionController(params, callback);
|
|
@@ -35908,12 +35924,12 @@ class CommunitiesQueryStreamController$1 extends QueryStreamController {
|
|
|
35908
35924
|
}
|
|
35909
35925
|
}
|
|
35910
35926
|
|
|
35911
|
-
var EnumCommunityActions$
|
|
35927
|
+
var EnumCommunityActions$4;
|
|
35912
35928
|
(function (EnumCommunityActions) {
|
|
35913
35929
|
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
35914
35930
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
35915
35931
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
35916
|
-
})(EnumCommunityActions$
|
|
35932
|
+
})(EnumCommunityActions$4 || (EnumCommunityActions$4 = {}));
|
|
35917
35933
|
|
|
35918
35934
|
var EnumCommunityMemberActions$1;
|
|
35919
35935
|
(function (EnumCommunityMemberActions) {
|
|
@@ -36605,8 +36621,8 @@ class SearchCommunityLiveCollectionController extends LiveCollectionController {
|
|
|
36605
36621
|
}
|
|
36606
36622
|
startSubscription() {
|
|
36607
36623
|
return this.queryStreamController.subscribeRTE([
|
|
36608
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions$
|
|
36609
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions$
|
|
36624
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$4.OnCommunityDeleted },
|
|
36625
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$4.OnCommunityUpdated },
|
|
36610
36626
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
36611
36627
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
36612
36628
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -36706,12 +36722,12 @@ class CommunitiesPaginationController extends PaginationController {
|
|
|
36706
36722
|
}
|
|
36707
36723
|
}
|
|
36708
36724
|
|
|
36709
|
-
var EnumCommunityActions$
|
|
36725
|
+
var EnumCommunityActions$3;
|
|
36710
36726
|
(function (EnumCommunityActions) {
|
|
36711
36727
|
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
36712
36728
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
36713
36729
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
36714
|
-
})(EnumCommunityActions$
|
|
36730
|
+
})(EnumCommunityActions$3 || (EnumCommunityActions$3 = {}));
|
|
36715
36731
|
|
|
36716
36732
|
class CommunitiesQueryStreamController extends QueryStreamController {
|
|
36717
36733
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
@@ -36747,7 +36763,7 @@ class CommunitiesQueryStreamController extends QueryStreamController {
|
|
|
36747
36763
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
36748
36764
|
if (!collection)
|
|
36749
36765
|
return;
|
|
36750
|
-
if (this.query.displayName && action === EnumCommunityActions$
|
|
36766
|
+
if (this.query.displayName && action === EnumCommunityActions$3.OnCommunityCreated) {
|
|
36751
36767
|
return;
|
|
36752
36768
|
}
|
|
36753
36769
|
/*
|
|
@@ -36792,9 +36808,9 @@ class CommunityLiveCollectionController extends LiveCollectionController {
|
|
|
36792
36808
|
}
|
|
36793
36809
|
startSubscription() {
|
|
36794
36810
|
return this.queryStreamController.subscribeRTE([
|
|
36795
|
-
{ fn: onCommunityCreated, action: EnumCommunityActions$
|
|
36796
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions$
|
|
36797
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions$
|
|
36811
|
+
{ fn: onCommunityCreated, action: EnumCommunityActions$3.OnCommunityCreated },
|
|
36812
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$3.OnCommunityDeleted },
|
|
36813
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$3.OnCommunityUpdated },
|
|
36798
36814
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
36799
36815
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
36800
36816
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -36989,11 +37005,11 @@ class TrendingCommunitiesQueryStreamController extends QueryStreamController {
|
|
|
36989
37005
|
}
|
|
36990
37006
|
}
|
|
36991
37007
|
|
|
36992
|
-
var EnumCommunityActions$
|
|
37008
|
+
var EnumCommunityActions$2;
|
|
36993
37009
|
(function (EnumCommunityActions) {
|
|
36994
37010
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
36995
37011
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
36996
|
-
})(EnumCommunityActions$
|
|
37012
|
+
})(EnumCommunityActions$2 || (EnumCommunityActions$2 = {}));
|
|
36997
37013
|
|
|
36998
37014
|
class TrendingCommunityLiveCollectionController extends LiveCollectionController {
|
|
36999
37015
|
constructor(query, callback) {
|
|
@@ -37024,8 +37040,8 @@ class TrendingCommunityLiveCollectionController extends LiveCollectionController
|
|
|
37024
37040
|
}
|
|
37025
37041
|
startSubscription() {
|
|
37026
37042
|
return this.queryStreamController.subscribeRTE([
|
|
37027
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions$
|
|
37028
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions$
|
|
37043
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$2.OnCommunityDeleted },
|
|
37044
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$2.OnCommunityUpdated },
|
|
37029
37045
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
37030
37046
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
37031
37047
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -37151,11 +37167,11 @@ class RecommendedCommunitiesQueryStreamController extends QueryStreamController
|
|
|
37151
37167
|
}
|
|
37152
37168
|
}
|
|
37153
37169
|
|
|
37154
|
-
var EnumCommunityActions;
|
|
37170
|
+
var EnumCommunityActions$1;
|
|
37155
37171
|
(function (EnumCommunityActions) {
|
|
37156
37172
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
37157
37173
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
37158
|
-
})(EnumCommunityActions || (EnumCommunityActions = {}));
|
|
37174
|
+
})(EnumCommunityActions$1 || (EnumCommunityActions$1 = {}));
|
|
37159
37175
|
|
|
37160
37176
|
class RecommendedCommunityLiveCollectionController extends LiveCollectionController {
|
|
37161
37177
|
constructor(query, callback) {
|
|
@@ -37186,8 +37202,8 @@ class RecommendedCommunityLiveCollectionController extends LiveCollectionControl
|
|
|
37186
37202
|
}
|
|
37187
37203
|
startSubscription() {
|
|
37188
37204
|
return this.queryStreamController.subscribeRTE([
|
|
37189
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions.OnCommunityDeleted },
|
|
37190
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions.OnCommunityUpdated },
|
|
37205
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$1.OnCommunityDeleted },
|
|
37206
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$1.OnCommunityUpdated },
|
|
37191
37207
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
37192
37208
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
37193
37209
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -37255,6 +37271,201 @@ const getRecommendedCommunities = (params, callback, config) => {
|
|
|
37255
37271
|
};
|
|
37256
37272
|
/* end_public_function */
|
|
37257
37273
|
|
|
37274
|
+
class SemanticSearchCommunityPaginationController extends PaginationController {
|
|
37275
|
+
async getRequest(queryParams, token) {
|
|
37276
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, communityMembershipStatus } = queryParams, params = __rest(queryParams, ["limit", "communityMembershipStatus"]);
|
|
37277
|
+
const baseOptions = {
|
|
37278
|
+
type: queryParams.limit ? 'pagination' : undefined,
|
|
37279
|
+
};
|
|
37280
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
37281
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/semantic-search/communities`, {
|
|
37282
|
+
params: Object.assign(Object.assign({}, params), { filter: communityMembershipStatus !== null && communityMembershipStatus !== void 0 ? communityMembershipStatus : "all" /* AmityCommunityMemberStatusFilter.ALL */, options }),
|
|
37283
|
+
});
|
|
37284
|
+
return queryResponse;
|
|
37285
|
+
}
|
|
37286
|
+
}
|
|
37287
|
+
|
|
37288
|
+
function prepareSemanticCommunitiesReferenceId(response) {
|
|
37289
|
+
return response.communities.map(community => {
|
|
37290
|
+
const score = response.searchResult.find(result => result.communityId === community.communityId);
|
|
37291
|
+
return `${community.communityId}:${score}`;
|
|
37292
|
+
});
|
|
37293
|
+
}
|
|
37294
|
+
|
|
37295
|
+
class SemanticSearchCommunityQueryStreamController extends QueryStreamController {
|
|
37296
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
37297
|
+
super(query, cacheKey);
|
|
37298
|
+
this.notifyChange = notifyChange;
|
|
37299
|
+
this.preparePayload = preparePayload;
|
|
37300
|
+
}
|
|
37301
|
+
async saveToMainDB(response) {
|
|
37302
|
+
const processedPayload = this.preparePayload(response);
|
|
37303
|
+
const client = getActiveClient();
|
|
37304
|
+
const cachedAt = client.cache && Date.now();
|
|
37305
|
+
if (client.cache) {
|
|
37306
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
37307
|
+
}
|
|
37308
|
+
}
|
|
37309
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
37310
|
+
var _a, _b;
|
|
37311
|
+
if (refresh) {
|
|
37312
|
+
pushToCache(this.cacheKey, {
|
|
37313
|
+
data: prepareSemanticCommunitiesReferenceId(response),
|
|
37314
|
+
});
|
|
37315
|
+
}
|
|
37316
|
+
else {
|
|
37317
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
37318
|
+
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
37319
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...communities, ...prepareSemanticCommunitiesReferenceId(response)])] }));
|
|
37320
|
+
}
|
|
37321
|
+
}
|
|
37322
|
+
reactor(action) {
|
|
37323
|
+
return (community) => {
|
|
37324
|
+
var _a;
|
|
37325
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
37326
|
+
if (!collection)
|
|
37327
|
+
return;
|
|
37328
|
+
collection.data = [...new Set([community.communityId, ...collection.data])];
|
|
37329
|
+
pushToCache(this.cacheKey, collection);
|
|
37330
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
37331
|
+
};
|
|
37332
|
+
//
|
|
37333
|
+
}
|
|
37334
|
+
subscribeRTE(createSubscriber) {
|
|
37335
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
37336
|
+
}
|
|
37337
|
+
}
|
|
37338
|
+
|
|
37339
|
+
var EnumCommunityActions;
|
|
37340
|
+
(function (EnumCommunityActions) {
|
|
37341
|
+
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
37342
|
+
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
37343
|
+
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
37344
|
+
})(EnumCommunityActions || (EnumCommunityActions = {}));
|
|
37345
|
+
|
|
37346
|
+
class SemanticSearchCommunityLiveCollectionController extends LiveCollectionController {
|
|
37347
|
+
constructor(query, callback) {
|
|
37348
|
+
const queryStreamId = hash(query);
|
|
37349
|
+
const cacheKey = ['community', 'collection', queryStreamId];
|
|
37350
|
+
const paginationController = new SemanticSearchCommunityPaginationController(query);
|
|
37351
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
37352
|
+
this.query = query;
|
|
37353
|
+
this.queryStreamController = new SemanticSearchCommunityQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareSemanticSearchCommunityPayload);
|
|
37354
|
+
this.callback = callback.bind(this);
|
|
37355
|
+
this.loadPage({ initial: true });
|
|
37356
|
+
}
|
|
37357
|
+
setup() {
|
|
37358
|
+
var _a;
|
|
37359
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
37360
|
+
if (!collection) {
|
|
37361
|
+
pushToCache(this.cacheKey, {
|
|
37362
|
+
data: [],
|
|
37363
|
+
params: {},
|
|
37364
|
+
});
|
|
37365
|
+
}
|
|
37366
|
+
}
|
|
37367
|
+
async persistModel(queryPayload) {
|
|
37368
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
37369
|
+
}
|
|
37370
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
37371
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
37372
|
+
}
|
|
37373
|
+
startSubscription() {
|
|
37374
|
+
return this.queryStreamController.subscribeRTE([
|
|
37375
|
+
{ fn: onCommunityCreated, action: EnumCommunityActions.OnCommunityCreated },
|
|
37376
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions.OnCommunityDeleted },
|
|
37377
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions.OnCommunityUpdated },
|
|
37378
|
+
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
37379
|
+
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
37380
|
+
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
37381
|
+
{ fn: onLocalCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
37382
|
+
{ fn: onLocalCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
37383
|
+
]);
|
|
37384
|
+
}
|
|
37385
|
+
notifyChange({ origin, loading, error }) {
|
|
37386
|
+
var _a, _b;
|
|
37387
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
37388
|
+
if (!collection)
|
|
37389
|
+
return;
|
|
37390
|
+
const data = this.applyFilter((_b = collection.data
|
|
37391
|
+
.map(communityIdWithScore => {
|
|
37392
|
+
const [communityId, score] = communityIdWithScore.split(':');
|
|
37393
|
+
return {
|
|
37394
|
+
communityId,
|
|
37395
|
+
score: parseFloat(score),
|
|
37396
|
+
};
|
|
37397
|
+
})
|
|
37398
|
+
.sort((a, b) => b.score - a.score)
|
|
37399
|
+
.map(({ communityId }) => pullFromCache(['community', 'get', communityId]))
|
|
37400
|
+
.filter(isNonNullable)
|
|
37401
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []);
|
|
37402
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
37403
|
+
return;
|
|
37404
|
+
this.callback({
|
|
37405
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
37406
|
+
data,
|
|
37407
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
37408
|
+
loading,
|
|
37409
|
+
error,
|
|
37410
|
+
});
|
|
37411
|
+
}
|
|
37412
|
+
applyFilter(data) {
|
|
37413
|
+
const { userId } = getActiveClient();
|
|
37414
|
+
let communities = data;
|
|
37415
|
+
if (this.query.categoryIds) {
|
|
37416
|
+
communities = communities.filter(c => {
|
|
37417
|
+
var _a;
|
|
37418
|
+
return (_a = c.categoryIds) === null || _a === void 0 ? void 0 : _a.some((id) => {
|
|
37419
|
+
if (!this.query.categoryIds)
|
|
37420
|
+
return true;
|
|
37421
|
+
if (this.query.categoryIds.length === 0)
|
|
37422
|
+
return true;
|
|
37423
|
+
return this.query.categoryIds.includes(id);
|
|
37424
|
+
});
|
|
37425
|
+
});
|
|
37426
|
+
}
|
|
37427
|
+
if (this.query.tags) {
|
|
37428
|
+
communities = communities.filter(c => { var _a; return (_a = c.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = this.query.tags) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
|
|
37429
|
+
}
|
|
37430
|
+
if (this.query.communityMembershipStatus && userId) {
|
|
37431
|
+
communities = filterByCommunityMembership(communities, this.query.communityMembershipStatus, userId);
|
|
37432
|
+
}
|
|
37433
|
+
return communities;
|
|
37434
|
+
}
|
|
37435
|
+
}
|
|
37436
|
+
|
|
37437
|
+
/**
|
|
37438
|
+
* search posts by semantic search
|
|
37439
|
+
*
|
|
37440
|
+
* @returns the associated pinned post(s)
|
|
37441
|
+
*
|
|
37442
|
+
* @category Posts Live Collection
|
|
37443
|
+
*
|
|
37444
|
+
*/
|
|
37445
|
+
const semanticSearchCommunities = (params, callback, config) => {
|
|
37446
|
+
const { log, cache } = getActiveClient();
|
|
37447
|
+
if (!cache) {
|
|
37448
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
37449
|
+
}
|
|
37450
|
+
const timestamp = Date.now();
|
|
37451
|
+
log(`semanticSearchCommunities(tmpid: ${timestamp}) > listen`);
|
|
37452
|
+
const semanticSearchPostLiveCollection = new SemanticSearchCommunityLiveCollectionController(params, callback);
|
|
37453
|
+
const disposers = semanticSearchPostLiveCollection.startSubscription();
|
|
37454
|
+
const cacheKey = semanticSearchPostLiveCollection.getCacheKey();
|
|
37455
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
37456
|
+
return () => {
|
|
37457
|
+
log(`semanticSearchCommunities(tmpid: ${timestamp}) > dispose`);
|
|
37458
|
+
disposers.forEach(fn => fn());
|
|
37459
|
+
};
|
|
37460
|
+
};
|
|
37461
|
+
|
|
37462
|
+
var AmityCommunityMemberStatusFilter;
|
|
37463
|
+
(function (AmityCommunityMemberStatusFilter) {
|
|
37464
|
+
AmityCommunityMemberStatusFilter["ALL"] = "all";
|
|
37465
|
+
AmityCommunityMemberStatusFilter["MEMBER"] = "member";
|
|
37466
|
+
AmityCommunityMemberStatusFilter["NOT_MEMBER"] = "notMember";
|
|
37467
|
+
})(AmityCommunityMemberStatusFilter || (AmityCommunityMemberStatusFilter = {}));
|
|
37468
|
+
|
|
37258
37469
|
/* begin_public_function
|
|
37259
37470
|
id: community.moderation.add_roles
|
|
37260
37471
|
*/
|
|
@@ -37418,7 +37629,9 @@ var index$9 = /*#__PURE__*/Object.freeze({
|
|
|
37418
37629
|
getCommunities: getCommunities,
|
|
37419
37630
|
getCommunity: getCommunity,
|
|
37420
37631
|
getTrendingCommunities: getTrendingCommunities,
|
|
37421
|
-
getRecommendedCommunities: getRecommendedCommunities
|
|
37632
|
+
getRecommendedCommunities: getRecommendedCommunities,
|
|
37633
|
+
semanticSearchCommunities: semanticSearchCommunities,
|
|
37634
|
+
get AmityCommunityMemberStatusFilter () { return AmityCommunityMemberStatusFilter; }
|
|
37422
37635
|
});
|
|
37423
37636
|
|
|
37424
37637
|
/* begin_public_function
|
|
@@ -40126,9 +40339,9 @@ class GlobalPinnedPostLiveCollectionController extends LiveCollectionController
|
|
|
40126
40339
|
*/
|
|
40127
40340
|
const getGlobalPinnedPosts = (params, callback, config) => {
|
|
40128
40341
|
const { log, cache } = getActiveClient();
|
|
40129
|
-
if (!cache) {
|
|
40130
|
-
|
|
40131
|
-
}
|
|
40342
|
+
// if (!cache) {
|
|
40343
|
+
// console.log(ENABLE_CACHE_MESSAGE);
|
|
40344
|
+
// }
|
|
40132
40345
|
const timestamp = Date.now();
|
|
40133
40346
|
log(`getGlobalPinnedPosts(tmpid: ${timestamp}) > listen`);
|
|
40134
40347
|
const globalPinnedPostLiveCollection = new GlobalPinnedPostLiveCollectionController(params, callback);
|