JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "use-paginated-channel-content.ts"

Full Path: /home/markqprx/iniasli.pro/client/channels/requests/use-paginated-channel-content.ts
File size: 791 bytes
MIME-type: text/plain
Charset: utf-8

import {useInfiniteData} from '@common/ui/infinite-scroll/use-infinite-data';
import {Channel, ChannelContentItem} from '@common/channels/channel';
import {
  channelEndpoint,
  channelQueryKey,
} from '@common/channels/requests/use-channel';
import {useChannelQueryParams} from '@common/channels/use-channel-query-params';

export function usePaginatedChannelContent<
  T extends ChannelContentItem = ChannelContentItem
>(channel: Channel<T>) {
  const queryParams = useChannelQueryParams(channel);
  return useInfiniteData<T>({
    willSortOrFilter: true,
    initialPage: channel.content,
    queryKey: channelQueryKey(channel.id),
    endpoint: channelEndpoint(channel.id),
    paginate: 'simple',
    queryParams: {
      returnContentOnly: 'true',
      ...queryParams,
    },
  });
}