UNPKG

@amityco/ts-sdk

Version:

Amity Social Cloud Typescript SDK

55 lines 2.36 kB
/** * Session-scoped singleton engine that manages TTL-based fetching and caching * of blocked users. Provides a lazy `ensureFetched()` gate for the * `getAllBlockedUsers()` API. * * Key behaviours: * - `onSessionEstablished()` is a no-op — fetch is lazy, triggered only by consumer call * - `onSessionDestroyed()` resets `lastFetchedAt` to null (ensures fresh fetch on next session) * - `ensureFetched()` fetches from server only when cache is expired or never fetched * - `lastFetchedAt` is only updated on successful fetch * - reads query the follow cache live, so block/unblock changes are reflected * even within the TTL window * * @internal */ declare class BlockedUserSyncEngine { /** Epoch ms of last successful fetch. null = never fetched in this session. */ private lastFetchedAt; /** No-op — fetch is lazy, triggered by consumer calling getAllBlockedUsers(). */ onSessionEstablished(): void; /** Resets state so the next session starts with a cold cache. */ onSessionDestroyed(): void; /** No-op for this engine. */ onTokenExpired(): void; private isCacheExpired; /** * Ensures the local store is populated with fresh blocked-user data. * * - If the cache is still within the 5-minute TTL window: resolves immediately * (no server call). * - If the cache is expired (or never fetched): fetches from the server, * persists the payload to the cache, and updates `lastFetchedAt`. * * On failure the error propagates to the caller and `lastFetchedAt` is NOT * updated, so the next call will retry. */ ensureFetched(): Promise<void>; /** * Returns the blocked users by querying the follow cache live — the outgoing * direction (`from === me`, `status === 'blocked'`). Reading the cache (not a * fetched snapshot) means `blockUser()` / `unblockUser()` changes are reflected * even within the TTL window. * * Applies the spec-mandated query: * - filter `from === currentUserId`, `status === 'blocked'`, blocked user not deleted * - sort by `updatedAt` DESC * - hard limit of 100 results */ getCachedUsers(): Amity.User[]; } declare const _default: { getInstance: () => BlockedUserSyncEngine; }; export default _default; //# sourceMappingURL=blockedUserSyncEngine.d.ts.map