@amityco/ts-sdk 7.33.1 → 7.33.2-840ee4f3.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/domains/content.d.ts +5 -0
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/client/api/getFeedSettings.d.ts +3 -1
- package/dist/client/api/getFeedSettings.d.ts.map +1 -1
- package/dist/client/api/setupLoginSubscriptions.d.ts.map +1 -1
- package/dist/index.cjs.js +213 -8
- package/dist/index.esm.js +213 -8
- package/dist/index.umd.js +2 -2
- package/dist/userRepository/api/getAllFollowers.d.ts +19 -0
- package/dist/userRepository/api/getAllFollowers.d.ts.map +1 -0
- package/dist/userRepository/api/getAllFollowings.d.ts +21 -0
- package/dist/userRepository/api/getAllFollowings.d.ts.map +1 -0
- package/dist/userRepository/api/index.d.ts +2 -0
- package/dist/userRepository/api/index.d.ts.map +1 -1
- package/dist/userRepository/api/tests/integration/getAllFollowers.integration.test.d.ts +2 -0
- package/dist/userRepository/api/tests/integration/getAllFollowers.integration.test.d.ts.map +1 -0
- package/dist/userRepository/services/FollowUserSyncEngine/followUserSyncEngine.d.ts +60 -0
- package/dist/userRepository/services/FollowUserSyncEngine/followUserSyncEngine.d.ts.map +1 -0
- package/dist/userRepository/services/FollowUserSyncEngine/followUserSyncEngineOnLoginHandler.d.ts +3 -0
- package/dist/userRepository/services/FollowUserSyncEngine/followUserSyncEngineOnLoginHandler.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -132,6 +132,11 @@ declare global {
|
|
|
132
132
|
maxResolution: Amity.VideoResolution;
|
|
133
133
|
minResolution: Amity.VideoResolution;
|
|
134
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* Network switch for muted auto-play of feed videos.
|
|
137
|
+
* {@link getFeedSettings} returns `false` when the server omits it.
|
|
138
|
+
*/
|
|
139
|
+
autoPlay?: boolean;
|
|
135
140
|
};
|
|
136
141
|
type ContentSetting<T extends ContentType = 'text' | 'video'> = T extends 'text' ? ContentSettingText : T extends 'video' ? ContentSettingVideo : never;
|
|
137
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/content.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAC;AAEH,oBAAY,qBAAqB;IAC/B,mBAAmB,iCAAiC;IACpD,iBAAiB,uBAAuB;IACxC,oBAAoB,2BAA2B;IAC/C,iBAAiB,yBAAyB;IAC1C,4BAA4B,oCAAoC;IAChE,sBAAsB,2CAA2C;IACjE,qBAAqB,6BAA6B;IAClD,WAAW,kBAAkB;IAC7B,gBAAgB,wCAAwC;IACxD,MAAM,WAAW;CAClB;AAED;;;GAGG;AACH,OAAO,EAAE,qBAAqB,IAAI,0BAA0B,EAAE,CAAC;AAE/D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,iBAAiB,GAClB,OAAO,CAAC,GAAG,qBAAqB,EAAE,EAAE,GAAG,qBAAqB,CAAC,MAAM,EAAE,CAAC,GACtE,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;QAElB;;;;;;WAMG;QACH,KAAK,kBAAkB,GAAG;YACxB,MAAM,EAAE,qBAAqB,CAAC;YAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;SACjB,CAAC;QAEF,KAAK,WAAW,GACZ,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,YAAY,GACZ,MAAM,GACN,OAAO,GACP,KAAK,GACL,MAAM,CAAC;QAEX,KAAK,eAAe,GAAG,OAAO,CAAC,OAAO,eAAe,CAAC,CAAC;QAEvD,KAAK,eAAe,GAAG;YACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;YACtB,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QAEF,KAAK,eAAe,GAAG;YACrB,MAAM,EAAE,KAAK,CAA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CAAC;YACpB,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC;QAEF,KAAK,mBAAmB,GAAG;YACzB,WAAW,EAAE,OAAO,CAAC;YACrB,OAAO,EAAE,OAAO,CAAC;YACjB,kBAAkB,EAAE,MAAM,CAAC;YAC3B,eAAe,EAAE;gBACf,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC;gBACrC,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC;aACtC,CAAC;YACF;;;eAGG;YACH,QAAQ,CAAC,EAAE,OAAO,CAAC;SACpB,CAAC;QAEF,KAAK,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,MAAM,GAAG,OAAO,IAAI,CAAC,SAAS,MAAM,GAC5E,kBAAkB,GAClB,CAAC,SAAS,OAAO,GACjB,mBAAmB,GACnB,KAAK,CAAC;KACX;CACF"}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
* import { getFeedSettings } from '@amityco/ts-sdk'
|
|
4
4
|
* const feedSettings = await getFeedSettings()
|
|
5
5
|
* const postFeedSetting = feedSettings.post
|
|
6
|
+
* const isAutoPlayEnabled = postFeedSetting?.find(({ contentType }) => contentType === 'video')?.autoPlay
|
|
6
7
|
* ```
|
|
7
8
|
*
|
|
8
|
-
* Fetches a {@link Amity.FeedSettings} object
|
|
9
|
+
* Fetches a {@link Amity.FeedSettings} object. Video content settings always
|
|
10
|
+
* carry `autoPlay`, which is `false` when the server omits it.
|
|
9
11
|
*
|
|
10
12
|
* @returns A Promise of {@link Amity.FeedSettings} object
|
|
11
13
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFeedSettings.d.ts","sourceRoot":"","sources":["../../../src/client/api/getFeedSettings.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"getFeedSettings.d.ts","sourceRoot":"","sources":["../../../src/client/api/getFeedSettings.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,QAAa,QAAQ,MAAM,YAAY,CAmBlE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupLoginSubscriptions.d.ts","sourceRoot":"","sources":["../../../src/client/api/setupLoginSubscriptions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setupLoginSubscriptions.d.ts","sourceRoot":"","sources":["../../../src/client/api/setupLoginSubscriptions.ts"],"names":[],"mappings":"AA2BA;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,iBAAkB,MAAM,YAAY,KAAG,MAAM,YAAY,EAoE5F,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -6257,9 +6257,11 @@ const validateTexts = async (texts) => {
|
|
|
6257
6257
|
* import { getFeedSettings } from '@amityco/ts-sdk'
|
|
6258
6258
|
* const feedSettings = await getFeedSettings()
|
|
6259
6259
|
* const postFeedSetting = feedSettings.post
|
|
6260
|
+
* const isAutoPlayEnabled = postFeedSetting?.find(({ contentType }) => contentType === 'video')?.autoPlay
|
|
6260
6261
|
* ```
|
|
6261
6262
|
*
|
|
6262
|
-
* Fetches a {@link Amity.FeedSettings} object
|
|
6263
|
+
* Fetches a {@link Amity.FeedSettings} object. Video content settings always
|
|
6264
|
+
* carry `autoPlay`, which is `false` when the server omits it.
|
|
6263
6265
|
*
|
|
6264
6266
|
* @returns A Promise of {@link Amity.FeedSettings} object
|
|
6265
6267
|
*
|
|
@@ -6270,7 +6272,14 @@ const getFeedSettings = async () => {
|
|
|
6270
6272
|
const client = getActiveClient();
|
|
6271
6273
|
const { data } = await client.http.get(`/api/v3/network-settings/feed-setting`);
|
|
6272
6274
|
return Object.fromEntries(data.feedSettings.map(({ feedType, contentSettings }) => {
|
|
6273
|
-
return [
|
|
6275
|
+
return [
|
|
6276
|
+
feedType,
|
|
6277
|
+
contentSettings === null || contentSettings === void 0 ? void 0 : contentSettings.map(setting => {
|
|
6278
|
+
var _a;
|
|
6279
|
+
return setting.contentType === 'video'
|
|
6280
|
+
? Object.assign(Object.assign({}, setting), { autoPlay: (_a = setting.autoPlay) !== null && _a !== void 0 ? _a : false }) : setting;
|
|
6281
|
+
}),
|
|
6282
|
+
];
|
|
6274
6283
|
}));
|
|
6275
6284
|
};
|
|
6276
6285
|
|
|
@@ -7936,7 +7945,7 @@ function prepareBlockedUserPayload(response) {
|
|
|
7936
7945
|
}
|
|
7937
7946
|
|
|
7938
7947
|
const BLOCK_LIST_LIMIT$1 = 100;
|
|
7939
|
-
const TTL_MS$
|
|
7948
|
+
const TTL_MS$2 = 5 * 60 * 1000; // 5 minutes
|
|
7940
7949
|
/**
|
|
7941
7950
|
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
7942
7951
|
* of blocked users. Provides a lazy `ensureFetched()` gate for the
|
|
@@ -7974,7 +7983,7 @@ class BlockedUserSyncEngine {
|
|
|
7974
7983
|
isCacheExpired() {
|
|
7975
7984
|
if (this.lastFetchedAt === null)
|
|
7976
7985
|
return true;
|
|
7977
|
-
return Date.now() - this.lastFetchedAt > TTL_MS$
|
|
7986
|
+
return Date.now() - this.lastFetchedAt > TTL_MS$2;
|
|
7978
7987
|
}
|
|
7979
7988
|
/**
|
|
7980
7989
|
* Ensures the local store is populated with fresh blocked-user data.
|
|
@@ -8065,7 +8074,7 @@ function prepareBlockingUserPayload(response) {
|
|
|
8065
8074
|
}
|
|
8066
8075
|
|
|
8067
8076
|
const BLOCK_LIST_LIMIT = 100;
|
|
8068
|
-
const TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
8077
|
+
const TTL_MS$1 = 5 * 60 * 1000; // 5 minutes
|
|
8069
8078
|
/**
|
|
8070
8079
|
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
8071
8080
|
* of blocking users (the "blocked-by" list — users who blocked the current
|
|
@@ -8104,7 +8113,7 @@ class BlockingUserSyncEngine {
|
|
|
8104
8113
|
isCacheExpired() {
|
|
8105
8114
|
if (this.lastFetchedAt === null)
|
|
8106
8115
|
return true;
|
|
8107
|
-
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
8116
|
+
return Date.now() - this.lastFetchedAt > TTL_MS$1;
|
|
8108
8117
|
}
|
|
8109
8118
|
/**
|
|
8110
8119
|
* Ensures the local store is populated with fresh blocking-user data.
|
|
@@ -8199,6 +8208,138 @@ function prepareFollowStatusPayload(response) {
|
|
|
8199
8208
|
return Object.assign(Object.assign({}, rest), { follows });
|
|
8200
8209
|
}
|
|
8201
8210
|
|
|
8211
|
+
const FOLLOW_LIST_LIMIT = 100;
|
|
8212
|
+
const TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
8213
|
+
const ENDPOINTS = {
|
|
8214
|
+
followers: '/api/v4/me/followers',
|
|
8215
|
+
followings: '/api/v4/me/following',
|
|
8216
|
+
};
|
|
8217
|
+
/**
|
|
8218
|
+
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
8219
|
+
* of the current user's accepted followers or followings. Provides a lazy
|
|
8220
|
+
* `ensureFetched()` gate for the `getAllFollowers()` / `getAllFollowings()` APIs.
|
|
8221
|
+
*
|
|
8222
|
+
* Key behaviours:
|
|
8223
|
+
* - `onSessionEstablished()` is a no-op — fetch is lazy, triggered only by consumer call
|
|
8224
|
+
* - `onSessionDestroyed()` resets `lastFetchedAt` to null (ensures fresh fetch on next session)
|
|
8225
|
+
* - `ensureFetched()` fetches from server only when cache is expired or never fetched
|
|
8226
|
+
* - `lastFetchedAt` is only updated on successful fetch
|
|
8227
|
+
* - reads query the follow cache live, so follow / unfollow / remove-follower
|
|
8228
|
+
* changes are reflected even within the TTL window
|
|
8229
|
+
*
|
|
8230
|
+
* @internal
|
|
8231
|
+
*/
|
|
8232
|
+
class FollowUserSyncEngine {
|
|
8233
|
+
constructor(direction) {
|
|
8234
|
+
/** Epoch ms of last successful fetch. null = never fetched in this session. */
|
|
8235
|
+
this.lastFetchedAt = null;
|
|
8236
|
+
this.direction = direction;
|
|
8237
|
+
}
|
|
8238
|
+
/** No-op — fetch is lazy, triggered by consumer calling the API. */
|
|
8239
|
+
// eslint-disable-next-line class-methods-use-this
|
|
8240
|
+
onSessionEstablished() {
|
|
8241
|
+
// intentionally empty
|
|
8242
|
+
}
|
|
8243
|
+
/** Resets state so the next session starts with a cold cache. */
|
|
8244
|
+
onSessionDestroyed() {
|
|
8245
|
+
this.lastFetchedAt = null;
|
|
8246
|
+
}
|
|
8247
|
+
/** No-op for this engine. */
|
|
8248
|
+
// eslint-disable-next-line class-methods-use-this
|
|
8249
|
+
onTokenExpired() {
|
|
8250
|
+
// intentionally empty
|
|
8251
|
+
}
|
|
8252
|
+
isCacheExpired() {
|
|
8253
|
+
if (this.lastFetchedAt === null)
|
|
8254
|
+
return true;
|
|
8255
|
+
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
8256
|
+
}
|
|
8257
|
+
/**
|
|
8258
|
+
* Ensures the local store is populated with fresh follow data.
|
|
8259
|
+
*
|
|
8260
|
+
* - If the cache is still within the 5-minute TTL window: resolves immediately
|
|
8261
|
+
* (no server call).
|
|
8262
|
+
* - If the cache is expired (or never fetched): fetches the first page
|
|
8263
|
+
* (limit 100) of accepted follows, persists the payload to the cache, and
|
|
8264
|
+
* updates `lastFetchedAt`.
|
|
8265
|
+
*
|
|
8266
|
+
* On failure the error propagates to the caller and `lastFetchedAt` is NOT
|
|
8267
|
+
* updated, so the next call will retry.
|
|
8268
|
+
*/
|
|
8269
|
+
async ensureFetched() {
|
|
8270
|
+
if (!this.isCacheExpired())
|
|
8271
|
+
return;
|
|
8272
|
+
const client = getActiveClient();
|
|
8273
|
+
const { data } = await client.http.get(ENDPOINTS[this.direction], { params: { status: 'accepted', options: { limit: FOLLOW_LIST_LIMIT }, isDeleted: false } });
|
|
8274
|
+
const cachedAt = client.cache && Date.now();
|
|
8275
|
+
if (client.cache) {
|
|
8276
|
+
ingestInCache(prepareFollowersPayload(data), { cachedAt });
|
|
8277
|
+
}
|
|
8278
|
+
// Only update timestamp on success — failure leaves it unchanged so the
|
|
8279
|
+
// next call retries.
|
|
8280
|
+
this.lastFetchedAt = Date.now();
|
|
8281
|
+
}
|
|
8282
|
+
/**
|
|
8283
|
+
* Returns the followers / followings by querying the follow cache live.
|
|
8284
|
+
*
|
|
8285
|
+
* - filter `status === 'accepted'` and the current user on the matching side
|
|
8286
|
+
* of the edge, other user not deleted
|
|
8287
|
+
* - sort by `updatedAt` DESC
|
|
8288
|
+
* - hard limit of 100 results
|
|
8289
|
+
*/
|
|
8290
|
+
getCachedUsers() {
|
|
8291
|
+
var _a;
|
|
8292
|
+
const client = getActiveClient();
|
|
8293
|
+
if (!client.cache)
|
|
8294
|
+
return [];
|
|
8295
|
+
const { userId } = client;
|
|
8296
|
+
const isFollowers = this.direction === 'followers';
|
|
8297
|
+
return ((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
|
|
8298
|
+
.map(entry => entry.data)
|
|
8299
|
+
.filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'accepted' &&
|
|
8300
|
+
(isFollowers ? follow.to === userId : follow.from === userId))
|
|
8301
|
+
.sort((a, b) => { var _a, _b; return (((_a = a.updatedAt) !== null && _a !== void 0 ? _a : '') < ((_b = b.updatedAt) !== null && _b !== void 0 ? _b : '') ? 1 : -1); })
|
|
8302
|
+
.map(follow => {
|
|
8303
|
+
var _a;
|
|
8304
|
+
return (_a = pullFromCache(['user', 'get', isFollowers ? follow.from : follow.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
8305
|
+
})
|
|
8306
|
+
.filter((user) => user != null && user.isDeleted !== true)
|
|
8307
|
+
.slice(0, FOLLOW_LIST_LIMIT)
|
|
8308
|
+
.map(userLinkedObject);
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
const instances = {};
|
|
8312
|
+
var FollowUserSyncEngine$1 = {
|
|
8313
|
+
getInstance: (direction) => {
|
|
8314
|
+
if (!instances[direction])
|
|
8315
|
+
instances[direction] = new FollowUserSyncEngine(direction);
|
|
8316
|
+
return instances[direction];
|
|
8317
|
+
},
|
|
8318
|
+
};
|
|
8319
|
+
|
|
8320
|
+
var followUserSyncEngineOnLoginHandler = () => {
|
|
8321
|
+
const engines = [
|
|
8322
|
+
FollowUserSyncEngine$1.getInstance('followers'),
|
|
8323
|
+
FollowUserSyncEngine$1.getInstance('followings'),
|
|
8324
|
+
];
|
|
8325
|
+
onSessionStateChange(state => {
|
|
8326
|
+
engines.forEach(engine => {
|
|
8327
|
+
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
8328
|
+
engine.onSessionEstablished();
|
|
8329
|
+
}
|
|
8330
|
+
else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
8331
|
+
engine.onTokenExpired();
|
|
8332
|
+
}
|
|
8333
|
+
else {
|
|
8334
|
+
engine.onSessionDestroyed();
|
|
8335
|
+
}
|
|
8336
|
+
});
|
|
8337
|
+
});
|
|
8338
|
+
return () => {
|
|
8339
|
+
engines.forEach(engine => engine.onSessionDestroyed());
|
|
8340
|
+
};
|
|
8341
|
+
};
|
|
8342
|
+
|
|
8202
8343
|
/**
|
|
8203
8344
|
* Subscribes to a block MQTT event (`user.didBlock` / `user.didUnblock`),
|
|
8204
8345
|
* ingests the carried `FollowersPayload` (follows + users) into the cache so
|
|
@@ -8922,7 +9063,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
|
|
|
8922
9063
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
8923
9064
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
8924
9065
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
8925
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler(), userFlagByMeOnLoginHandler());
|
|
9066
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), followUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler(), userFlagByMeOnLoginHandler());
|
|
8926
9067
|
if (client.useLegacyUnreadCount) {
|
|
8927
9068
|
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
8928
9069
|
}
|
|
@@ -14142,7 +14283,7 @@ const getWatchSessionStorage = () => {
|
|
|
14142
14283
|
return storageInstance;
|
|
14143
14284
|
};
|
|
14144
14285
|
|
|
14145
|
-
const privateKey = "
|
|
14286
|
+
const privateKey = "MIIEpQIBAAKCAQEAwAEc/oZgYIvKSUG/C3mONYLR4ZPgAjMEX4bJ+xqqakUDRtqlNO+eZs2blQ1Ko0DBkqPExyQezvjibH5W2UZBV5RaBTlTcNVKTToMBEGesAfaEcM3qUyQHxdbFYZv6P4sb14dcwxTQ8usmaV8ooiR1Fcaso5ZWYcZ8Hb46FbQ7OoVumsBtPWwfZ4f003o5VCl6AIM6lcLv9UDLlFVYhE+PeXpRHtfWlGqxMvqC9oinlwhL6nWv6VjQXW4nhcib72dPBzfHT7k/PMKto2SxALYdb68ENiAGuJLWi3AUHSyYCJK2w7wIlWfJUAI0v26ub10IpExr6D5QuW2577jjP93iwIDAQABAoIBAFWfqXhwIIatkFY+9Z1+ZcbDQimgsmMIsUiQaX6Lk7e0cxOj6czDlxYtVtaPiNtow2pLkjNkjkCqiP7tEHnwdK9DvylZOTa2R15NJpK3WLcTqVIGhsn/FL5owfvFah6z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59LcSx2Bh28fp3/efiVIOpVd4Y=";
|
|
14146
14287
|
/*
|
|
14147
14288
|
* The crypto algorithm used for importing key and signing string
|
|
14148
14289
|
*/
|
|
@@ -16300,6 +16441,68 @@ const getAllBlockingUsers = async () => {
|
|
|
16300
16441
|
};
|
|
16301
16442
|
/* end_public_function */
|
|
16302
16443
|
|
|
16444
|
+
/* begin_public_function
|
|
16445
|
+
id: user.get_all_followers
|
|
16446
|
+
*/
|
|
16447
|
+
/**
|
|
16448
|
+
* ```js
|
|
16449
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
16450
|
+
* const followers = await UserRepository.getAllFollowers()
|
|
16451
|
+
* ```
|
|
16452
|
+
*
|
|
16453
|
+
* Returns all users who follow the current user (accepted follows only) as a
|
|
16454
|
+
* non-paginated list (limit 100) with TTL-based caching (5-minute window).
|
|
16455
|
+
* Within the TTL window, subsequent calls resolve instantly from the local store
|
|
16456
|
+
* without any server call. After the TTL expires, the next call triggers a fresh
|
|
16457
|
+
* server fetch.
|
|
16458
|
+
*
|
|
16459
|
+
* @returns A promise that resolves to an array of follower {@link Amity.User} objects
|
|
16460
|
+
*
|
|
16461
|
+
* @category Follow API
|
|
16462
|
+
* @async
|
|
16463
|
+
*/
|
|
16464
|
+
const getAllFollowers = async () => {
|
|
16465
|
+
const client = getActiveClient();
|
|
16466
|
+
client.log('user/getAllFollowers');
|
|
16467
|
+
const engine = FollowUserSyncEngine$1.getInstance('followers');
|
|
16468
|
+
// Ensure data is fetched (no-op if cache is fresh)
|
|
16469
|
+
await engine.ensureFetched();
|
|
16470
|
+
return engine.getCachedUsers();
|
|
16471
|
+
};
|
|
16472
|
+
/* end_public_function */
|
|
16473
|
+
|
|
16474
|
+
/* begin_public_function
|
|
16475
|
+
id: user.get_all_followings
|
|
16476
|
+
*/
|
|
16477
|
+
/**
|
|
16478
|
+
* ```js
|
|
16479
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
16480
|
+
* const followings = await UserRepository.getAllFollowings()
|
|
16481
|
+
* ```
|
|
16482
|
+
*
|
|
16483
|
+
* Returns all users the current user follows (accepted follows only) as a
|
|
16484
|
+
* non-paginated list (limit 100) with TTL-based caching (5-minute window).
|
|
16485
|
+
* Within the TTL window, subsequent calls resolve instantly from the local store
|
|
16486
|
+
* without any server call. After the TTL expires, the next call triggers a fresh
|
|
16487
|
+
* server fetch.
|
|
16488
|
+
*
|
|
16489
|
+
* The directional inverse of {@link getAllFollowers}.
|
|
16490
|
+
*
|
|
16491
|
+
* @returns A promise that resolves to an array of followed {@link Amity.User} objects
|
|
16492
|
+
*
|
|
16493
|
+
* @category Follow API
|
|
16494
|
+
* @async
|
|
16495
|
+
*/
|
|
16496
|
+
const getAllFollowings = async () => {
|
|
16497
|
+
const client = getActiveClient();
|
|
16498
|
+
client.log('user/getAllFollowings');
|
|
16499
|
+
const engine = FollowUserSyncEngine$1.getInstance('followings');
|
|
16500
|
+
// Ensure data is fetched (no-op if cache is fresh)
|
|
16501
|
+
await engine.ensureFetched();
|
|
16502
|
+
return engine.getCachedUsers();
|
|
16503
|
+
};
|
|
16504
|
+
/* end_public_function */
|
|
16505
|
+
|
|
16303
16506
|
/**
|
|
16304
16507
|
* ```js
|
|
16305
16508
|
* import { onUserUpdated } from '@amityco/ts-sdk'
|
|
@@ -17402,6 +17605,8 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
17402
17605
|
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
17403
17606
|
getAllBlockedUsers: getAllBlockedUsers,
|
|
17404
17607
|
getAllBlockingUsers: getAllBlockingUsers,
|
|
17608
|
+
getAllFollowers: getAllFollowers,
|
|
17609
|
+
getAllFollowings: getAllFollowings,
|
|
17405
17610
|
onUserUpdated: onUserUpdated,
|
|
17406
17611
|
onUserDeleted: onUserDeleted$2,
|
|
17407
17612
|
onUserFlagged: onUserFlagged,
|
package/dist/index.esm.js
CHANGED
|
@@ -6257,9 +6257,11 @@ const validateTexts = async (texts) => {
|
|
|
6257
6257
|
* import { getFeedSettings } from '@amityco/ts-sdk'
|
|
6258
6258
|
* const feedSettings = await getFeedSettings()
|
|
6259
6259
|
* const postFeedSetting = feedSettings.post
|
|
6260
|
+
* const isAutoPlayEnabled = postFeedSetting?.find(({ contentType }) => contentType === 'video')?.autoPlay
|
|
6260
6261
|
* ```
|
|
6261
6262
|
*
|
|
6262
|
-
* Fetches a {@link Amity.FeedSettings} object
|
|
6263
|
+
* Fetches a {@link Amity.FeedSettings} object. Video content settings always
|
|
6264
|
+
* carry `autoPlay`, which is `false` when the server omits it.
|
|
6263
6265
|
*
|
|
6264
6266
|
* @returns A Promise of {@link Amity.FeedSettings} object
|
|
6265
6267
|
*
|
|
@@ -6270,7 +6272,14 @@ const getFeedSettings = async () => {
|
|
|
6270
6272
|
const client = getActiveClient();
|
|
6271
6273
|
const { data } = await client.http.get(`/api/v3/network-settings/feed-setting`);
|
|
6272
6274
|
return Object.fromEntries(data.feedSettings.map(({ feedType, contentSettings }) => {
|
|
6273
|
-
return [
|
|
6275
|
+
return [
|
|
6276
|
+
feedType,
|
|
6277
|
+
contentSettings === null || contentSettings === void 0 ? void 0 : contentSettings.map(setting => {
|
|
6278
|
+
var _a;
|
|
6279
|
+
return setting.contentType === 'video'
|
|
6280
|
+
? Object.assign(Object.assign({}, setting), { autoPlay: (_a = setting.autoPlay) !== null && _a !== void 0 ? _a : false }) : setting;
|
|
6281
|
+
}),
|
|
6282
|
+
];
|
|
6274
6283
|
}));
|
|
6275
6284
|
};
|
|
6276
6285
|
|
|
@@ -7936,7 +7945,7 @@ function prepareBlockedUserPayload(response) {
|
|
|
7936
7945
|
}
|
|
7937
7946
|
|
|
7938
7947
|
const BLOCK_LIST_LIMIT$1 = 100;
|
|
7939
|
-
const TTL_MS$
|
|
7948
|
+
const TTL_MS$2 = 5 * 60 * 1000; // 5 minutes
|
|
7940
7949
|
/**
|
|
7941
7950
|
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
7942
7951
|
* of blocked users. Provides a lazy `ensureFetched()` gate for the
|
|
@@ -7974,7 +7983,7 @@ class BlockedUserSyncEngine {
|
|
|
7974
7983
|
isCacheExpired() {
|
|
7975
7984
|
if (this.lastFetchedAt === null)
|
|
7976
7985
|
return true;
|
|
7977
|
-
return Date.now() - this.lastFetchedAt > TTL_MS$
|
|
7986
|
+
return Date.now() - this.lastFetchedAt > TTL_MS$2;
|
|
7978
7987
|
}
|
|
7979
7988
|
/**
|
|
7980
7989
|
* Ensures the local store is populated with fresh blocked-user data.
|
|
@@ -8065,7 +8074,7 @@ function prepareBlockingUserPayload(response) {
|
|
|
8065
8074
|
}
|
|
8066
8075
|
|
|
8067
8076
|
const BLOCK_LIST_LIMIT = 100;
|
|
8068
|
-
const TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
8077
|
+
const TTL_MS$1 = 5 * 60 * 1000; // 5 minutes
|
|
8069
8078
|
/**
|
|
8070
8079
|
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
8071
8080
|
* of blocking users (the "blocked-by" list — users who blocked the current
|
|
@@ -8104,7 +8113,7 @@ class BlockingUserSyncEngine {
|
|
|
8104
8113
|
isCacheExpired() {
|
|
8105
8114
|
if (this.lastFetchedAt === null)
|
|
8106
8115
|
return true;
|
|
8107
|
-
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
8116
|
+
return Date.now() - this.lastFetchedAt > TTL_MS$1;
|
|
8108
8117
|
}
|
|
8109
8118
|
/**
|
|
8110
8119
|
* Ensures the local store is populated with fresh blocking-user data.
|
|
@@ -8199,6 +8208,138 @@ function prepareFollowStatusPayload(response) {
|
|
|
8199
8208
|
return Object.assign(Object.assign({}, rest), { follows });
|
|
8200
8209
|
}
|
|
8201
8210
|
|
|
8211
|
+
const FOLLOW_LIST_LIMIT = 100;
|
|
8212
|
+
const TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
8213
|
+
const ENDPOINTS = {
|
|
8214
|
+
followers: '/api/v4/me/followers',
|
|
8215
|
+
followings: '/api/v4/me/following',
|
|
8216
|
+
};
|
|
8217
|
+
/**
|
|
8218
|
+
* Session-scoped singleton engine that manages TTL-based fetching and caching
|
|
8219
|
+
* of the current user's accepted followers or followings. Provides a lazy
|
|
8220
|
+
* `ensureFetched()` gate for the `getAllFollowers()` / `getAllFollowings()` APIs.
|
|
8221
|
+
*
|
|
8222
|
+
* Key behaviours:
|
|
8223
|
+
* - `onSessionEstablished()` is a no-op — fetch is lazy, triggered only by consumer call
|
|
8224
|
+
* - `onSessionDestroyed()` resets `lastFetchedAt` to null (ensures fresh fetch on next session)
|
|
8225
|
+
* - `ensureFetched()` fetches from server only when cache is expired or never fetched
|
|
8226
|
+
* - `lastFetchedAt` is only updated on successful fetch
|
|
8227
|
+
* - reads query the follow cache live, so follow / unfollow / remove-follower
|
|
8228
|
+
* changes are reflected even within the TTL window
|
|
8229
|
+
*
|
|
8230
|
+
* @internal
|
|
8231
|
+
*/
|
|
8232
|
+
class FollowUserSyncEngine {
|
|
8233
|
+
constructor(direction) {
|
|
8234
|
+
/** Epoch ms of last successful fetch. null = never fetched in this session. */
|
|
8235
|
+
this.lastFetchedAt = null;
|
|
8236
|
+
this.direction = direction;
|
|
8237
|
+
}
|
|
8238
|
+
/** No-op — fetch is lazy, triggered by consumer calling the API. */
|
|
8239
|
+
// eslint-disable-next-line class-methods-use-this
|
|
8240
|
+
onSessionEstablished() {
|
|
8241
|
+
// intentionally empty
|
|
8242
|
+
}
|
|
8243
|
+
/** Resets state so the next session starts with a cold cache. */
|
|
8244
|
+
onSessionDestroyed() {
|
|
8245
|
+
this.lastFetchedAt = null;
|
|
8246
|
+
}
|
|
8247
|
+
/** No-op for this engine. */
|
|
8248
|
+
// eslint-disable-next-line class-methods-use-this
|
|
8249
|
+
onTokenExpired() {
|
|
8250
|
+
// intentionally empty
|
|
8251
|
+
}
|
|
8252
|
+
isCacheExpired() {
|
|
8253
|
+
if (this.lastFetchedAt === null)
|
|
8254
|
+
return true;
|
|
8255
|
+
return Date.now() - this.lastFetchedAt > TTL_MS;
|
|
8256
|
+
}
|
|
8257
|
+
/**
|
|
8258
|
+
* Ensures the local store is populated with fresh follow data.
|
|
8259
|
+
*
|
|
8260
|
+
* - If the cache is still within the 5-minute TTL window: resolves immediately
|
|
8261
|
+
* (no server call).
|
|
8262
|
+
* - If the cache is expired (or never fetched): fetches the first page
|
|
8263
|
+
* (limit 100) of accepted follows, persists the payload to the cache, and
|
|
8264
|
+
* updates `lastFetchedAt`.
|
|
8265
|
+
*
|
|
8266
|
+
* On failure the error propagates to the caller and `lastFetchedAt` is NOT
|
|
8267
|
+
* updated, so the next call will retry.
|
|
8268
|
+
*/
|
|
8269
|
+
async ensureFetched() {
|
|
8270
|
+
if (!this.isCacheExpired())
|
|
8271
|
+
return;
|
|
8272
|
+
const client = getActiveClient();
|
|
8273
|
+
const { data } = await client.http.get(ENDPOINTS[this.direction], { params: { status: 'accepted', options: { limit: FOLLOW_LIST_LIMIT }, isDeleted: false } });
|
|
8274
|
+
const cachedAt = client.cache && Date.now();
|
|
8275
|
+
if (client.cache) {
|
|
8276
|
+
ingestInCache(prepareFollowersPayload(data), { cachedAt });
|
|
8277
|
+
}
|
|
8278
|
+
// Only update timestamp on success — failure leaves it unchanged so the
|
|
8279
|
+
// next call retries.
|
|
8280
|
+
this.lastFetchedAt = Date.now();
|
|
8281
|
+
}
|
|
8282
|
+
/**
|
|
8283
|
+
* Returns the followers / followings by querying the follow cache live.
|
|
8284
|
+
*
|
|
8285
|
+
* - filter `status === 'accepted'` and the current user on the matching side
|
|
8286
|
+
* of the edge, other user not deleted
|
|
8287
|
+
* - sort by `updatedAt` DESC
|
|
8288
|
+
* - hard limit of 100 results
|
|
8289
|
+
*/
|
|
8290
|
+
getCachedUsers() {
|
|
8291
|
+
var _a;
|
|
8292
|
+
const client = getActiveClient();
|
|
8293
|
+
if (!client.cache)
|
|
8294
|
+
return [];
|
|
8295
|
+
const { userId } = client;
|
|
8296
|
+
const isFollowers = this.direction === 'followers';
|
|
8297
|
+
return ((_a = queryCache(['follow', 'get'])) !== null && _a !== void 0 ? _a : [])
|
|
8298
|
+
.map(entry => entry.data)
|
|
8299
|
+
.filter(follow => (follow === null || follow === void 0 ? void 0 : follow.status) === 'accepted' &&
|
|
8300
|
+
(isFollowers ? follow.to === userId : follow.from === userId))
|
|
8301
|
+
.sort((a, b) => { var _a, _b; return (((_a = a.updatedAt) !== null && _a !== void 0 ? _a : '') < ((_b = b.updatedAt) !== null && _b !== void 0 ? _b : '') ? 1 : -1); })
|
|
8302
|
+
.map(follow => {
|
|
8303
|
+
var _a;
|
|
8304
|
+
return (_a = pullFromCache(['user', 'get', isFollowers ? follow.from : follow.to])) === null || _a === void 0 ? void 0 : _a.data;
|
|
8305
|
+
})
|
|
8306
|
+
.filter((user) => user != null && user.isDeleted !== true)
|
|
8307
|
+
.slice(0, FOLLOW_LIST_LIMIT)
|
|
8308
|
+
.map(userLinkedObject);
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
const instances = {};
|
|
8312
|
+
var FollowUserSyncEngine$1 = {
|
|
8313
|
+
getInstance: (direction) => {
|
|
8314
|
+
if (!instances[direction])
|
|
8315
|
+
instances[direction] = new FollowUserSyncEngine(direction);
|
|
8316
|
+
return instances[direction];
|
|
8317
|
+
},
|
|
8318
|
+
};
|
|
8319
|
+
|
|
8320
|
+
var followUserSyncEngineOnLoginHandler = () => {
|
|
8321
|
+
const engines = [
|
|
8322
|
+
FollowUserSyncEngine$1.getInstance('followers'),
|
|
8323
|
+
FollowUserSyncEngine$1.getInstance('followings'),
|
|
8324
|
+
];
|
|
8325
|
+
onSessionStateChange(state => {
|
|
8326
|
+
engines.forEach(engine => {
|
|
8327
|
+
if (state === "established" /* Amity.SessionStates.ESTABLISHED */) {
|
|
8328
|
+
engine.onSessionEstablished();
|
|
8329
|
+
}
|
|
8330
|
+
else if (state === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
|
|
8331
|
+
engine.onTokenExpired();
|
|
8332
|
+
}
|
|
8333
|
+
else {
|
|
8334
|
+
engine.onSessionDestroyed();
|
|
8335
|
+
}
|
|
8336
|
+
});
|
|
8337
|
+
});
|
|
8338
|
+
return () => {
|
|
8339
|
+
engines.forEach(engine => engine.onSessionDestroyed());
|
|
8340
|
+
};
|
|
8341
|
+
};
|
|
8342
|
+
|
|
8202
8343
|
/**
|
|
8203
8344
|
* Subscribes to a block MQTT event (`user.didBlock` / `user.didUnblock`),
|
|
8204
8345
|
* ingests the carried `FollowersPayload` (follows + users) into the cache so
|
|
@@ -8922,7 +9063,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
|
|
|
8922
9063
|
// NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
|
|
8923
9064
|
// the channel because currently backend can't handle this, so every time a user is banned from
|
|
8924
9065
|
// a channel or the channel is deleted the channel's unread count will not be reset to zero
|
|
8925
|
-
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler(), userFlagByMeOnLoginHandler());
|
|
9066
|
+
onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), followUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler(), userFlagByMeOnLoginHandler());
|
|
8926
9067
|
if (client.useLegacyUnreadCount) {
|
|
8927
9068
|
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
8928
9069
|
}
|
|
@@ -14142,7 +14283,7 @@ const getWatchSessionStorage = () => {
|
|
|
14142
14283
|
return storageInstance;
|
|
14143
14284
|
};
|
|
14144
14285
|
|
|
14145
|
-
const privateKey = "
|
|
14286
|
+
const privateKey = "MIIEpQIBAAKCAQEAwAEc/oZgYIvKSUG/C3mONYLR4ZPgAjMEX4bJ+xqqakUDRtqlNO+eZs2blQ1Ko0DBkqPExyQezvjibH5W2UZBV5RaBTlTcNVKTToMBEGesAfaEcM3qUyQHxdbFYZv6P4sb14dcwxTQ8usmaV8ooiR1Fcaso5ZWYcZ8Hb46FbQ7OoVumsBtPWwfZ4f003o5VCl6AIM6lcLv9UDLlFVYhE+PeXpRHtfWlGqxMvqC9oinlwhL6nWv6VjQXW4nhcib72dPBzfHT7k/PMKto2SxALYdb68ENiAGuJLWi3AUHSyYCJK2w7wIlWfJUAI0v26ub10IpExr6D5QuW2577jjP93iwIDAQABAoIBAFWfqXhwIIatkFY+9Z1+ZcbDQimgsmMIsUiQaX6Lk7e0cxOj6czDlxYtVtaPiNtow2pLkjNkjkCqiP7tEHnwdK9DvylZOTa2R15NJpK3WLcTqVIGhsn/FL5owfvFah6zSsmXZParZm5zY9NZE03ALZhOB9/cz0e3kf/EbpfeL2mW7MApyiUt5i09ycchroOpcWp73ipIxvgigtZyUGFmsQicWhUs28F0D7w4Qfk76yG3nqXeb+BAMhCaIaa/k/aAxhiZG/ygEQWQrcC8gfe+jyicMAQPDEVS9YuUMGsLjIjKuVLZzp2xirQnhc2i2zVNEIvG6soprPOBEMQugzrtX5ECgYEA3b7KAbBIbDl1e4ZSCWhHdHkiWVZHaopsR/LhqDDNhXjWjq3AesgV6k0j9EdziMn/HmmOso0bz99GTV3JZf4A9ztTLumJlkHbdVtlgOqSjrFLj12rH9KXTheyIhWSpUmm8+WB1xasFbqpvJaGo7F3pd2Fqj1XR4mp5BO7c/t7LJ0CgYEA3aouEzXQ9THRKYocdfY69EI1Il1t/d/RSqqd9BxEjxBgxkM13ZiYIn/R4WW/nCUrlmhxG44Aa2Gob4Ahfsui2xKTg/g/3Zk/rAxAEGkfOLGoenaJMD41fH4wUq3FRYwkvnaMb9Hd6f/TlBHslIRa2NN58bSBGJCyBP2b59+2+EcCgYEAixDVRXvV37GlYUOa/XVdosk5Zoe6oDGRuQm0xbNdoUBoZvDHDvme7ONWEiQha/8qtVsD+CyQ7awcPfb8kK9c0bBt+bTS6d4BkTcxkEkMgtrkBVR8Nqfu5jXsLH4VCv4G61zbMhZw8+ut+az5YX2yCN7Frj9sFlxapMRPQmzMEe0CgYEAumsAzM8ZqNv4mAK65Mnr0rhLj1cbxcKRdUYACOgtEFQpzxN/HZnTeFAe5nx3pI3uFlRHq3DFEYnT6dHMWaJQmAULYpVIwMi9L6gtyJ9fzoI6uqMtxRDMUqKdaSsTGOY/kJ6KhQ/unXi1K3XXjR+yd1+C0q+HUm1+CYxvrZYLfskCgYEArsEy+IQOiqniJ0NE2vVUF+UK/IRZaic9YKcpov5Ot7Vvzm/MnnW4N1ljVskocETBWMmPUvNSExVjPebi+rxd8fa5kY8BJScPTzMFbunZn/wjtGdcM10qdlVQ9doG61A/9P3ezFKCfS4AvF/H/59LcSx2Bh28fp3/efiVIOpVd4Y=";
|
|
14146
14287
|
/*
|
|
14147
14288
|
* The crypto algorithm used for importing key and signing string
|
|
14148
14289
|
*/
|
|
@@ -16300,6 +16441,68 @@ const getAllBlockingUsers = async () => {
|
|
|
16300
16441
|
};
|
|
16301
16442
|
/* end_public_function */
|
|
16302
16443
|
|
|
16444
|
+
/* begin_public_function
|
|
16445
|
+
id: user.get_all_followers
|
|
16446
|
+
*/
|
|
16447
|
+
/**
|
|
16448
|
+
* ```js
|
|
16449
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
16450
|
+
* const followers = await UserRepository.getAllFollowers()
|
|
16451
|
+
* ```
|
|
16452
|
+
*
|
|
16453
|
+
* Returns all users who follow the current user (accepted follows only) as a
|
|
16454
|
+
* non-paginated list (limit 100) with TTL-based caching (5-minute window).
|
|
16455
|
+
* Within the TTL window, subsequent calls resolve instantly from the local store
|
|
16456
|
+
* without any server call. After the TTL expires, the next call triggers a fresh
|
|
16457
|
+
* server fetch.
|
|
16458
|
+
*
|
|
16459
|
+
* @returns A promise that resolves to an array of follower {@link Amity.User} objects
|
|
16460
|
+
*
|
|
16461
|
+
* @category Follow API
|
|
16462
|
+
* @async
|
|
16463
|
+
*/
|
|
16464
|
+
const getAllFollowers = async () => {
|
|
16465
|
+
const client = getActiveClient();
|
|
16466
|
+
client.log('user/getAllFollowers');
|
|
16467
|
+
const engine = FollowUserSyncEngine$1.getInstance('followers');
|
|
16468
|
+
// Ensure data is fetched (no-op if cache is fresh)
|
|
16469
|
+
await engine.ensureFetched();
|
|
16470
|
+
return engine.getCachedUsers();
|
|
16471
|
+
};
|
|
16472
|
+
/* end_public_function */
|
|
16473
|
+
|
|
16474
|
+
/* begin_public_function
|
|
16475
|
+
id: user.get_all_followings
|
|
16476
|
+
*/
|
|
16477
|
+
/**
|
|
16478
|
+
* ```js
|
|
16479
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
16480
|
+
* const followings = await UserRepository.getAllFollowings()
|
|
16481
|
+
* ```
|
|
16482
|
+
*
|
|
16483
|
+
* Returns all users the current user follows (accepted follows only) as a
|
|
16484
|
+
* non-paginated list (limit 100) with TTL-based caching (5-minute window).
|
|
16485
|
+
* Within the TTL window, subsequent calls resolve instantly from the local store
|
|
16486
|
+
* without any server call. After the TTL expires, the next call triggers a fresh
|
|
16487
|
+
* server fetch.
|
|
16488
|
+
*
|
|
16489
|
+
* The directional inverse of {@link getAllFollowers}.
|
|
16490
|
+
*
|
|
16491
|
+
* @returns A promise that resolves to an array of followed {@link Amity.User} objects
|
|
16492
|
+
*
|
|
16493
|
+
* @category Follow API
|
|
16494
|
+
* @async
|
|
16495
|
+
*/
|
|
16496
|
+
const getAllFollowings = async () => {
|
|
16497
|
+
const client = getActiveClient();
|
|
16498
|
+
client.log('user/getAllFollowings');
|
|
16499
|
+
const engine = FollowUserSyncEngine$1.getInstance('followings');
|
|
16500
|
+
// Ensure data is fetched (no-op if cache is fresh)
|
|
16501
|
+
await engine.ensureFetched();
|
|
16502
|
+
return engine.getCachedUsers();
|
|
16503
|
+
};
|
|
16504
|
+
/* end_public_function */
|
|
16505
|
+
|
|
16303
16506
|
/**
|
|
16304
16507
|
* ```js
|
|
16305
16508
|
* import { onUserUpdated } from '@amityco/ts-sdk'
|
|
@@ -17402,6 +17605,8 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
17402
17605
|
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
17403
17606
|
getAllBlockedUsers: getAllBlockedUsers,
|
|
17404
17607
|
getAllBlockingUsers: getAllBlockingUsers,
|
|
17608
|
+
getAllFollowers: getAllFollowers,
|
|
17609
|
+
getAllFollowings: getAllFollowings,
|
|
17405
17610
|
onUserUpdated: onUserUpdated,
|
|
17406
17611
|
onUserDeleted: onUserDeleted$2,
|
|
17407
17612
|
onUserFlagged: onUserFlagged,
|