UNPKG

@amityco/ts-sdk-react-native

Version:

Amity Social Cloud Typescript SDK

38 lines (34 loc) 1.17 kB
import { PaginationController } from '~/core/liveCollection/PaginationController'; import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants'; import { inferIsDeleted } from '~/utils/inferIsDeleted'; export class UserFeedPaginationController extends PaginationController< 'post', Amity.UserFeedLiveCollection > { async getRequest(queryParams: Amity.UserFeedLiveCollection, token: string | undefined) { const { userId, feedSources, dataTypes, includeDeleted, matchingOnlyParentPost, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, ...params } = queryParams; const options = token ? { token } : { limit }; const { data: queryResponse } = await this.http.get<Amity.PostPayload & Amity.Pagination>( `/api/v4/user-feeds/${userId}`, { params: { ...params, options, dataTypes: dataTypes?.length ? dataTypes : undefined, includePostedFeed: feedSources, isDeleted: inferIsDeleted(includeDeleted), matchingOnlyParentPost: matchingOnlyParentPost ?? !dataTypes?.length, }, }, ); return queryResponse; } }