@amityco/ts-sdk-react-native 6.33.1 → 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/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 +223 -21
- package/dist/index.esm.js +223 -21
- package/dist/index.umd.js +3 -3
- package/package.json +1 -1
- package/src/@types/core/payload.ts +7 -0
- package/src/@types/domains/community.ts +24 -0
- 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/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__';
|
|
@@ -29845,6 +29845,11 @@ const prepareCommunityRequest = (params) => {
|
|
|
29845
29845
|
return Object.assign(Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined)), {
|
|
29846
29846
|
// Convert story setting to the actual value. (Allow by default)
|
|
29847
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);
|
|
29848
29853
|
};
|
|
29849
29854
|
|
|
29850
29855
|
const preparePostPayload = (payload) => {
|
|
@@ -35919,12 +35924,12 @@ class CommunitiesQueryStreamController$1 extends QueryStreamController {
|
|
|
35919
35924
|
}
|
|
35920
35925
|
}
|
|
35921
35926
|
|
|
35922
|
-
var EnumCommunityActions$
|
|
35927
|
+
var EnumCommunityActions$4;
|
|
35923
35928
|
(function (EnumCommunityActions) {
|
|
35924
35929
|
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
35925
35930
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
35926
35931
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
35927
|
-
})(EnumCommunityActions$
|
|
35932
|
+
})(EnumCommunityActions$4 || (EnumCommunityActions$4 = {}));
|
|
35928
35933
|
|
|
35929
35934
|
var EnumCommunityMemberActions$1;
|
|
35930
35935
|
(function (EnumCommunityMemberActions) {
|
|
@@ -36616,8 +36621,8 @@ class SearchCommunityLiveCollectionController extends LiveCollectionController {
|
|
|
36616
36621
|
}
|
|
36617
36622
|
startSubscription() {
|
|
36618
36623
|
return this.queryStreamController.subscribeRTE([
|
|
36619
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions$
|
|
36620
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions$
|
|
36624
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$4.OnCommunityDeleted },
|
|
36625
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$4.OnCommunityUpdated },
|
|
36621
36626
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
36622
36627
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
36623
36628
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -36717,12 +36722,12 @@ class CommunitiesPaginationController extends PaginationController {
|
|
|
36717
36722
|
}
|
|
36718
36723
|
}
|
|
36719
36724
|
|
|
36720
|
-
var EnumCommunityActions$
|
|
36725
|
+
var EnumCommunityActions$3;
|
|
36721
36726
|
(function (EnumCommunityActions) {
|
|
36722
36727
|
EnumCommunityActions["OnCommunityCreated"] = "onCommunityCreated";
|
|
36723
36728
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
36724
36729
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
36725
|
-
})(EnumCommunityActions$
|
|
36730
|
+
})(EnumCommunityActions$3 || (EnumCommunityActions$3 = {}));
|
|
36726
36731
|
|
|
36727
36732
|
class CommunitiesQueryStreamController extends QueryStreamController {
|
|
36728
36733
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
@@ -36758,7 +36763,7 @@ class CommunitiesQueryStreamController extends QueryStreamController {
|
|
|
36758
36763
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
36759
36764
|
if (!collection)
|
|
36760
36765
|
return;
|
|
36761
|
-
if (this.query.displayName && action === EnumCommunityActions$
|
|
36766
|
+
if (this.query.displayName && action === EnumCommunityActions$3.OnCommunityCreated) {
|
|
36762
36767
|
return;
|
|
36763
36768
|
}
|
|
36764
36769
|
/*
|
|
@@ -36803,9 +36808,9 @@ class CommunityLiveCollectionController extends LiveCollectionController {
|
|
|
36803
36808
|
}
|
|
36804
36809
|
startSubscription() {
|
|
36805
36810
|
return this.queryStreamController.subscribeRTE([
|
|
36806
|
-
{ fn: onCommunityCreated, action: EnumCommunityActions$
|
|
36807
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions$
|
|
36808
|
-
{ 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 },
|
|
36809
36814
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
36810
36815
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
36811
36816
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -37000,11 +37005,11 @@ class TrendingCommunitiesQueryStreamController extends QueryStreamController {
|
|
|
37000
37005
|
}
|
|
37001
37006
|
}
|
|
37002
37007
|
|
|
37003
|
-
var EnumCommunityActions$
|
|
37008
|
+
var EnumCommunityActions$2;
|
|
37004
37009
|
(function (EnumCommunityActions) {
|
|
37005
37010
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
37006
37011
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
37007
|
-
})(EnumCommunityActions$
|
|
37012
|
+
})(EnumCommunityActions$2 || (EnumCommunityActions$2 = {}));
|
|
37008
37013
|
|
|
37009
37014
|
class TrendingCommunityLiveCollectionController extends LiveCollectionController {
|
|
37010
37015
|
constructor(query, callback) {
|
|
@@ -37035,8 +37040,8 @@ class TrendingCommunityLiveCollectionController extends LiveCollectionController
|
|
|
37035
37040
|
}
|
|
37036
37041
|
startSubscription() {
|
|
37037
37042
|
return this.queryStreamController.subscribeRTE([
|
|
37038
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions$
|
|
37039
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions$
|
|
37043
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$2.OnCommunityDeleted },
|
|
37044
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$2.OnCommunityUpdated },
|
|
37040
37045
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
37041
37046
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
37042
37047
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -37162,11 +37167,11 @@ class RecommendedCommunitiesQueryStreamController extends QueryStreamController
|
|
|
37162
37167
|
}
|
|
37163
37168
|
}
|
|
37164
37169
|
|
|
37165
|
-
var EnumCommunityActions;
|
|
37170
|
+
var EnumCommunityActions$1;
|
|
37166
37171
|
(function (EnumCommunityActions) {
|
|
37167
37172
|
EnumCommunityActions["OnCommunityDeleted"] = "onCommunityDeleted";
|
|
37168
37173
|
EnumCommunityActions["OnCommunityUpdated"] = "onCommunityUpdated";
|
|
37169
|
-
})(EnumCommunityActions || (EnumCommunityActions = {}));
|
|
37174
|
+
})(EnumCommunityActions$1 || (EnumCommunityActions$1 = {}));
|
|
37170
37175
|
|
|
37171
37176
|
class RecommendedCommunityLiveCollectionController extends LiveCollectionController {
|
|
37172
37177
|
constructor(query, callback) {
|
|
@@ -37197,8 +37202,8 @@ class RecommendedCommunityLiveCollectionController extends LiveCollectionControl
|
|
|
37197
37202
|
}
|
|
37198
37203
|
startSubscription() {
|
|
37199
37204
|
return this.queryStreamController.subscribeRTE([
|
|
37200
|
-
{ fn: onCommunityDeleted, action: EnumCommunityActions.OnCommunityDeleted },
|
|
37201
|
-
{ fn: onCommunityUpdated, action: EnumCommunityActions.OnCommunityUpdated },
|
|
37205
|
+
{ fn: onCommunityDeleted, action: EnumCommunityActions$1.OnCommunityDeleted },
|
|
37206
|
+
{ fn: onCommunityUpdated, action: EnumCommunityActions$1.OnCommunityUpdated },
|
|
37202
37207
|
{ fn: onCommunityJoined, action: EnumCommunityMemberActions$1.OnCommunityJoined },
|
|
37203
37208
|
{ fn: onCommunityLeft, action: EnumCommunityMemberActions$1.OnCommunityLeft },
|
|
37204
37209
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions$1.OnMemberCountChanged },
|
|
@@ -37266,6 +37271,201 @@ const getRecommendedCommunities = (params, callback, config) => {
|
|
|
37266
37271
|
};
|
|
37267
37272
|
/* end_public_function */
|
|
37268
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
|
+
|
|
37269
37469
|
/* begin_public_function
|
|
37270
37470
|
id: community.moderation.add_roles
|
|
37271
37471
|
*/
|
|
@@ -37429,7 +37629,9 @@ var index$9 = /*#__PURE__*/Object.freeze({
|
|
|
37429
37629
|
getCommunities: getCommunities,
|
|
37430
37630
|
getCommunity: getCommunity,
|
|
37431
37631
|
getTrendingCommunities: getTrendingCommunities,
|
|
37432
|
-
getRecommendedCommunities: getRecommendedCommunities
|
|
37632
|
+
getRecommendedCommunities: getRecommendedCommunities,
|
|
37633
|
+
semanticSearchCommunities: semanticSearchCommunities,
|
|
37634
|
+
get AmityCommunityMemberStatusFilter () { return AmityCommunityMemberStatusFilter; }
|
|
37433
37635
|
});
|
|
37434
37636
|
|
|
37435
37637
|
/* begin_public_function
|