@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.cjs.js
CHANGED
|
@@ -123,8 +123,8 @@ const PostContentType = Object.freeze({
|
|
|
123
123
|
|
|
124
124
|
function getVersion() {
|
|
125
125
|
try {
|
|
126
|
-
// the string ''v6.
|
|
127
|
-
return 'v6.
|
|
126
|
+
// the string ''v6.34.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
127
|
+
return 'v6.34.0-cjs';
|
|
128
128
|
}
|
|
129
129
|
catch (error) {
|
|
130
130
|
return '__dev__';
|
|
@@ -5895,6 +5895,10 @@ const messageLinkedObject = (message) => {
|
|
|
5895
5895
|
},
|
|
5896
5896
|
get deliveredCount() {
|
|
5897
5897
|
return getMessageReadCount(message).deliveredCount;
|
|
5898
|
+
},
|
|
5899
|
+
get creator() {
|
|
5900
|
+
var _a;
|
|
5901
|
+
return (_a = pullFromCache(['user', 'get', message.creatorId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
5898
5902
|
}, markRead: () => markReadMessage(message) });
|
|
5899
5903
|
};
|
|
5900
5904
|
|
|
@@ -12579,6 +12583,12 @@ const getReachedUsers = (params, callback) => {
|
|
|
12579
12583
|
};
|
|
12580
12584
|
};
|
|
12581
12585
|
|
|
12586
|
+
var AmityUserSearchMatchType;
|
|
12587
|
+
(function (AmityUserSearchMatchType) {
|
|
12588
|
+
AmityUserSearchMatchType["DEFAULT"] = "default";
|
|
12589
|
+
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
12590
|
+
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
12591
|
+
|
|
12582
12592
|
var index$j = /*#__PURE__*/Object.freeze({
|
|
12583
12593
|
__proto__: null,
|
|
12584
12594
|
Relationship: index$k,
|
|
@@ -12598,7 +12608,8 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
12598
12608
|
getBlockedUsers: getBlockedUsers$1,
|
|
12599
12609
|
searchUserByDisplayName: searchUserByDisplayName,
|
|
12600
12610
|
getViewedUsers: getViewedUsers,
|
|
12601
|
-
getReachedUsers: getReachedUsers
|
|
12611
|
+
getReachedUsers: getReachedUsers,
|
|
12612
|
+
get AmityUserSearchMatchType () { return AmityUserSearchMatchType; }
|
|
12602
12613
|
});
|
|
12603
12614
|
|
|
12604
12615
|
/* begin_public_function
|
|
@@ -13761,6 +13772,11 @@ const prepareCommunityRequest = (params) => {
|
|
|
13761
13772
|
return Object.assign(Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined)), {
|
|
13762
13773
|
// Convert story setting to the actual value. (Allow by default)
|
|
13763
13774
|
allowCommentInStory: typeof (storySetting === null || storySetting === void 0 ? void 0 : storySetting.enableComment) === 'boolean' ? storySetting.enableComment : true });
|
|
13775
|
+
};
|
|
13776
|
+
const prepareSemanticSearchCommunityPayload = (_a) => {
|
|
13777
|
+
var communityPayload = __rest(_a, ["searchResult"]);
|
|
13778
|
+
const processedCommunityPayload = prepareCommunityPayload(communityPayload);
|
|
13779
|
+
return Object.assign({}, processedCommunityPayload);
|
|
13764
13780
|
};
|
|
13765
13781
|
|
|
13766
13782
|
const preparePostPayload = (payload) => {
|
|
@@ -14815,9 +14831,9 @@ class ReactionLiveCollectionController extends LiveCollectionController {
|
|
|
14815
14831
|
*/
|
|
14816
14832
|
const getReactions = (params, callback, config) => {
|
|
14817
14833
|
const { log, cache } = getActiveClient();
|
|
14818
|
-
if (!cache) {
|
|
14819
|
-
|
|
14820
|
-
}
|
|
14834
|
+
// if (!cache) {
|
|
14835
|
+
// console.log('For using Live Collection feature you need to enable Cache!');
|
|
14836
|
+
// }
|
|
14821
14837
|
const timestamp = Date.now();
|
|
14822
14838
|
log(`getReactions(tmpid: ${timestamp}) > listen`);
|
|
14823
14839
|
const reactionLiveCollection = new ReactionLiveCollectionController(params, callback);
|
|
@@ -19835,12 +19851,12 @@ class CommunitiesQueryStreamController$1 extends QueryStreamController {
|
|
|
19835
19851
|
}
|
|
19836
19852
|
}
|
|
19837
19853
|
|
|
19838
|
-
var EnumCommunityActions$
|
|
19854
|
+
var EnumCommunityActions$4;
|
|
19839
19855
|
(function (EnumCommunityActions) {
|
|
19840
19856
|
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
19841
19857
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
19842
19858
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
19843
|
-
})(EnumCommunityActions$
|
|
19859
|
+
})(EnumCommunityActions$4 || (EnumCommunityActions$4 = {}));
|
|
19844
19860
|
|
|
19845
19861
|
var EnumCommunityMemberActions$1;
|
|
19846
19862
|
(function (EnumCommunityMemberActions) {
|
|
@@ -20532,8 +20548,8 @@ class SearchCommunityLiveCollectionController extends LiveCollectionController {
|
|
|
20532
20548
|
}
|
|
20533
20549
|
startSubscription() {
|
|
20534
20550
|
return this.queryStreamController.subscribeRTE([
|
|
20535
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions$
|
|
20536
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions$
|
|
20551
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$4.OnCommunityDeleted },
|
|
20552
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$4.OnCommunityUpdated },
|
|
20537
20553
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
20538
20554
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
20539
20555
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -20633,12 +20649,12 @@ class CommunitiesPaginationController extends PaginationController {
|
|
|
20633
20649
|
}
|
|
20634
20650
|
}
|
|
20635
20651
|
|
|
20636
|
-
var EnumCommunityActions$
|
|
20652
|
+
var EnumCommunityActions$3;
|
|
20637
20653
|
(function (EnumCommunityActions) {
|
|
20638
20654
|
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
20639
20655
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
20640
20656
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
20641
|
-
})(EnumCommunityActions$
|
|
20657
|
+
})(EnumCommunityActions$3 || (EnumCommunityActions$3 = {}));
|
|
20642
20658
|
|
|
20643
20659
|
class CommunitiesQueryStreamController extends QueryStreamController {
|
|
20644
20660
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
@@ -20674,7 +20690,7 @@ class CommunitiesQueryStreamController extends QueryStreamController {
|
|
|
20674
20690
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
20675
20691
|
if (!collection)
|
|
20676
20692
|
return;
|
|
20677
|
-
if (this.query.displayName && action === EnumCommunityActions$
|
|
20693
|
+
if (this.query.displayName && action === EnumCommunityActions$3.OnCommunityCreated) {
|
|
20678
20694
|
return;
|
|
20679
20695
|
}
|
|
20680
20696
|
/*
|
|
@@ -20719,9 +20735,9 @@ class CommunityLiveCollectionController extends LiveCollectionController {
|
|
|
20719
20735
|
}
|
|
20720
20736
|
startSubscription() {
|
|
20721
20737
|
return this.queryStreamController.subscribeRTE([
|
|
20722
|
-
{ fn: onCommunityCreated, action: EnumCommunityActions$
|
|
20723
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions$
|
|
20724
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions$
|
|
20738
|
+
{ fn: onCommunityCreated, action: EnumCommunityActions$3.OnCommunityCreated },
|
|
20739
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$3.OnCommunityDeleted },
|
|
20740
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$3.OnCommunityUpdated },
|
|
20725
20741
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
20726
20742
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
20727
20743
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -20916,11 +20932,11 @@ class TrendingCommunitiesQueryStreamController extends QueryStreamController {
|
|
|
20916
20932
|
}
|
|
20917
20933
|
}
|
|
20918
20934
|
|
|
20919
|
-
var EnumCommunityActions$
|
|
20935
|
+
var EnumCommunityActions$2;
|
|
20920
20936
|
(function (EnumCommunityActions) {
|
|
20921
20937
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
20922
20938
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
20923
|
-
})(EnumCommunityActions$
|
|
20939
|
+
})(EnumCommunityActions$2 || (EnumCommunityActions$2 = {}));
|
|
20924
20940
|
|
|
20925
20941
|
class TrendingCommunityLiveCollectionController extends LiveCollectionController {
|
|
20926
20942
|
constructor(query, callback) {
|
|
@@ -20951,8 +20967,8 @@ class TrendingCommunityLiveCollectionController extends LiveCollectionController
|
|
|
20951
20967
|
}
|
|
20952
20968
|
startSubscription() {
|
|
20953
20969
|
return this.queryStreamController.subscribeRTE([
|
|
20954
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions$
|
|
20955
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions$
|
|
20970
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$2.OnCommunityDeleted },
|
|
20971
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$2.OnCommunityUpdated },
|
|
20956
20972
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
20957
20973
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
20958
20974
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -21078,11 +21094,11 @@ class RecommendedCommunitiesQueryStreamController extends QueryStreamController
|
|
|
21078
21094
|
}
|
|
21079
21095
|
}
|
|
21080
21096
|
|
|
21081
|
-
var EnumCommunityActions;
|
|
21097
|
+
var EnumCommunityActions$1;
|
|
21082
21098
|
(function (EnumCommunityActions) {
|
|
21083
21099
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
21084
21100
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
21085
|
-
})(EnumCommunityActions || (EnumCommunityActions = {}));
|
|
21101
|
+
})(EnumCommunityActions$1 || (EnumCommunityActions$1 = {}));
|
|
21086
21102
|
|
|
21087
21103
|
class RecommendedCommunityLiveCollectionController extends LiveCollectionController {
|
|
21088
21104
|
constructor(query, callback) {
|
|
@@ -21113,8 +21129,8 @@ class RecommendedCommunityLiveCollectionController extends LiveCollectionControl
|
|
|
21113
21129
|
}
|
|
21114
21130
|
startSubscription() {
|
|
21115
21131
|
return this.queryStreamController.subscribeRTE([
|
|
21116
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions.OnCommunityDeleted },
|
|
21117
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions.OnCommunityUpdated },
|
|
21132
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$1.OnCommunityDeleted },
|
|
21133
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$1.OnCommunityUpdated },
|
|
21118
21134
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
21119
21135
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
21120
21136
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -21182,6 +21198,201 @@ const getRecommendedCommunities = (params, callback, config) => {
|
|
|
21182
21198
|
};
|
|
21183
21199
|
/* end_public_function */
|
|
21184
21200
|
|
|
21201
|
+
class SemanticSearchCommunityPaginationController extends PaginationController {
|
|
21202
|
+
async getRequest(queryParams, token) {
|
|
21203
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, communityMembershipStatus } = queryParams, params = __rest(queryParams, ["limit", "communityMembershipStatus"]);
|
|
21204
|
+
const baseOptions = {
|
|
21205
|
+
type: queryParams.limit ? 'pagination' : undefined,
|
|
21206
|
+
};
|
|
21207
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
21208
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/semantic-search/communities`, {
|
|
21209
|
+
params: Object.assign(Object.assign({}, params), { filter: communityMembershipStatus !== null && communityMembershipStatus !== void 0 ? communityMembershipStatus : "all" /* AmityCommunityMemberStatusFilter.ALL */, options }),
|
|
21210
|
+
});
|
|
21211
|
+
return queryResponse;
|
|
21212
|
+
}
|
|
21213
|
+
}
|
|
21214
|
+
|
|
21215
|
+
function prepareSemanticCommunitiesReferenceId(response) {
|
|
21216
|
+
return response.communities.map(community => {
|
|
21217
|
+
const score = response.searchResult.find(result => result.communityId === community.communityId);
|
|
21218
|
+
return `${community.communityId}:${score}`;
|
|
21219
|
+
});
|
|
21220
|
+
}
|
|
21221
|
+
|
|
21222
|
+
class SemanticSearchCommunityQueryStreamController extends QueryStreamController {
|
|
21223
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
21224
|
+
super(query, cacheKey);
|
|
21225
|
+
this.notifyChange = notifyChange;
|
|
21226
|
+
this.preparePayload = preparePayload;
|
|
21227
|
+
}
|
|
21228
|
+
async saveToMainDB(response) {
|
|
21229
|
+
const processedPayload = this.preparePayload(response);
|
|
21230
|
+
const client = getActiveClient();
|
|
21231
|
+
const cachedAt = client.cache && Date.now();
|
|
21232
|
+
if (client.cache) {
|
|
21233
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
21234
|
+
}
|
|
21235
|
+
}
|
|
21236
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
21237
|
+
var _a, _b;
|
|
21238
|
+
if (refresh) {
|
|
21239
|
+
pushToCache(this.cacheKey, {
|
|
21240
|
+
data: prepareSemanticCommunitiesReferenceId(response),
|
|
21241
|
+
});
|
|
21242
|
+
}
|
|
21243
|
+
else {
|
|
21244
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21245
|
+
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
21246
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...communities, ...prepareSemanticCommunitiesReferenceId(response)])] }));
|
|
21247
|
+
}
|
|
21248
|
+
}
|
|
21249
|
+
reactor(action) {
|
|
21250
|
+
return (community) => {
|
|
21251
|
+
var _a;
|
|
21252
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21253
|
+
if (!collection)
|
|
21254
|
+
return;
|
|
21255
|
+
collection.data = [...new Set([community.communityId, ...collection.data])];
|
|
21256
|
+
pushToCache(this.cacheKey, collection);
|
|
21257
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
21258
|
+
};
|
|
21259
|
+
//
|
|
21260
|
+
}
|
|
21261
|
+
subscribeRTE(createSubscriber) {
|
|
21262
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
21263
|
+
}
|
|
21264
|
+
}
|
|
21265
|
+
|
|
21266
|
+
var EnumCommunityActions;
|
|
21267
|
+
(function (EnumCommunityActions) {
|
|
21268
|
+
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
21269
|
+
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
21270
|
+
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
21271
|
+
})(EnumCommunityActions || (EnumCommunityActions = {}));
|
|
21272
|
+
|
|
21273
|
+
class SemanticSearchCommunityLiveCollectionController extends LiveCollectionController {
|
|
21274
|
+
constructor(query, callback) {
|
|
21275
|
+
const queryStreamId = hash__default["default"](query);
|
|
21276
|
+
const cacheKey = ['community', 'collection', queryStreamId];
|
|
21277
|
+
const paginationController = new SemanticSearchCommunityPaginationController(query);
|
|
21278
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
21279
|
+
this.query = query;
|
|
21280
|
+
this.queryStreamController = new SemanticSearchCommunityQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareSemanticSearchCommunityPayload);
|
|
21281
|
+
this.callback = callback.bind(this);
|
|
21282
|
+
this.loadPage({ initial: true });
|
|
21283
|
+
}
|
|
21284
|
+
setup() {
|
|
21285
|
+
var _a;
|
|
21286
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21287
|
+
if (!collection) {
|
|
21288
|
+
pushToCache(this.cacheKey, {
|
|
21289
|
+
data: [],
|
|
21290
|
+
params: {},
|
|
21291
|
+
});
|
|
21292
|
+
}
|
|
21293
|
+
}
|
|
21294
|
+
async persistModel(queryPayload) {
|
|
21295
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
21296
|
+
}
|
|
21297
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
21298
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
21299
|
+
}
|
|
21300
|
+
startSubscription() {
|
|
21301
|
+
return this.queryStreamController.subscribeRTE([
|
|
21302
|
+
{ fn: onCommunityCreated, action: EnumCommunityActions.OnCommunityCreated },
|
|
21303
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions.OnCommunityDeleted },
|
|
21304
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions.OnCommunityUpdated },
|
|
21305
|
+
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
21306
|
+
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
21307
|
+
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
21308
|
+
{ fn: onLocalCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
21309
|
+
{ fn: onLocalCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
21310
|
+
]);
|
|
21311
|
+
}
|
|
21312
|
+
notifyChange({ origin, loading, error }) {
|
|
21313
|
+
var _a, _b;
|
|
21314
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21315
|
+
if (!collection)
|
|
21316
|
+
return;
|
|
21317
|
+
const data = this.applyFilter((_b = collection.data
|
|
21318
|
+
.map(communityIdWithScore => {
|
|
21319
|
+
const [communityId, score] = communityIdWithScore.split(':');
|
|
21320
|
+
return {
|
|
21321
|
+
communityId,
|
|
21322
|
+
score: parseFloat(score),
|
|
21323
|
+
};
|
|
21324
|
+
})
|
|
21325
|
+
.sort((a, b) => b.score - a.score)
|
|
21326
|
+
.map(({ communityId }) => pullFromCache(['community', 'get', communityId]))
|
|
21327
|
+
.filter(isNonNullable)
|
|
21328
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []);
|
|
21329
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
21330
|
+
return;
|
|
21331
|
+
this.callback({
|
|
21332
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
21333
|
+
data,
|
|
21334
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
21335
|
+
loading,
|
|
21336
|
+
error,
|
|
21337
|
+
});
|
|
21338
|
+
}
|
|
21339
|
+
applyFilter(data) {
|
|
21340
|
+
const { userId } = getActiveClient();
|
|
21341
|
+
let communities = data;
|
|
21342
|
+
if (this.query.categoryIds) {
|
|
21343
|
+
communities = communities.filter(c => {
|
|
21344
|
+
var _a;
|
|
21345
|
+
return (_a = c.categoryIds) === null || _a === void 0 ? void 0 : _a.some((id) => {
|
|
21346
|
+
if (!this.query.categoryIds)
|
|
21347
|
+
return true;
|
|
21348
|
+
if (this.query.categoryIds.length === 0)
|
|
21349
|
+
return true;
|
|
21350
|
+
return this.query.categoryIds.includes(id);
|
|
21351
|
+
});
|
|
21352
|
+
});
|
|
21353
|
+
}
|
|
21354
|
+
if (this.query.tags) {
|
|
21355
|
+
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); }); });
|
|
21356
|
+
}
|
|
21357
|
+
if (this.query.communityMembershipStatus && userId) {
|
|
21358
|
+
communities = filterByCommunityMembership(communities, this.query.communityMembershipStatus, userId);
|
|
21359
|
+
}
|
|
21360
|
+
return communities;
|
|
21361
|
+
}
|
|
21362
|
+
}
|
|
21363
|
+
|
|
21364
|
+
/**
|
|
21365
|
+
* search posts by semantic search
|
|
21366
|
+
*
|
|
21367
|
+
* @returns the associated pinned post(s)
|
|
21368
|
+
*
|
|
21369
|
+
* @category Posts Live Collection
|
|
21370
|
+
*
|
|
21371
|
+
*/
|
|
21372
|
+
const semanticSearchCommunities = (params, callback, config) => {
|
|
21373
|
+
const { log, cache } = getActiveClient();
|
|
21374
|
+
if (!cache) {
|
|
21375
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
21376
|
+
}
|
|
21377
|
+
const timestamp = Date.now();
|
|
21378
|
+
log(`semanticSearchCommunities(tmpid: ${timestamp}) > listen`);
|
|
21379
|
+
const semanticSearchPostLiveCollection = new SemanticSearchCommunityLiveCollectionController(params, callback);
|
|
21380
|
+
const disposers = semanticSearchPostLiveCollection.startSubscription();
|
|
21381
|
+
const cacheKey = semanticSearchPostLiveCollection.getCacheKey();
|
|
21382
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
21383
|
+
return () => {
|
|
21384
|
+
log(`semanticSearchCommunities(tmpid: ${timestamp}) > dispose`);
|
|
21385
|
+
disposers.forEach(fn => fn());
|
|
21386
|
+
};
|
|
21387
|
+
};
|
|
21388
|
+
|
|
21389
|
+
var AmityCommunityMemberStatusFilter;
|
|
21390
|
+
(function (AmityCommunityMemberStatusFilter) {
|
|
21391
|
+
AmityCommunityMemberStatusFilter["ALL"] = "all";
|
|
21392
|
+
AmityCommunityMemberStatusFilter["MEMBER"] = "member";
|
|
21393
|
+
AmityCommunityMemberStatusFilter["NOT_MEMBER"] = "notMember";
|
|
21394
|
+
})(AmityCommunityMemberStatusFilter || (AmityCommunityMemberStatusFilter = {}));
|
|
21395
|
+
|
|
21185
21396
|
/* begin_public_function
|
|
21186
21397
|
id: community.moderation.add_roles
|
|
21187
21398
|
*/
|
|
@@ -21345,7 +21556,9 @@ var index$9 = /*#__PURE__*/Object.freeze({
|
|
|
21345
21556
|
getCommunities: getCommunities,
|
|
21346
21557
|
getCommunity: getCommunity,
|
|
21347
21558
|
getTrendingCommunities: getTrendingCommunities,
|
|
21348
|
-
getRecommendedCommunities: getRecommendedCommunities
|
|
21559
|
+
getRecommendedCommunities: getRecommendedCommunities,
|
|
21560
|
+
semanticSearchCommunities: semanticSearchCommunities,
|
|
21561
|
+
get AmityCommunityMemberStatusFilter () { return AmityCommunityMemberStatusFilter; }
|
|
21349
21562
|
});
|
|
21350
21563
|
|
|
21351
21564
|
/* begin_public_function
|
|
@@ -24053,9 +24266,9 @@ class GlobalPinnedPostLiveCollectionController extends LiveCollectionController
|
|
|
24053
24266
|
*/
|
|
24054
24267
|
const getGlobalPinnedPosts = (params, callback, config) => {
|
|
24055
24268
|
const { log, cache } = getActiveClient();
|
|
24056
|
-
if (!cache) {
|
|
24057
|
-
|
|
24058
|
-
}
|
|
24269
|
+
// if (!cache) {
|
|
24270
|
+
// console.log(ENABLE_CACHE_MESSAGE);
|
|
24271
|
+
// }
|
|
24059
24272
|
const timestamp = Date.now();
|
|
24060
24273
|
log(`getGlobalPinnedPosts(tmpid: ${timestamp}) > listen`);
|
|
24061
24274
|
const globalPinnedPostLiveCollection = new GlobalPinnedPostLiveCollectionController(params, callback);
|