Prefer getNextLink

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-06-13 23:55:37 +02:00
parent b8a19ff794
commit 8029fc0e95
16 changed files with 92 additions and 92 deletions

View File

@ -2,7 +2,7 @@ import { useInfiniteQuery, useMutation, keepPreviousData } from '@tanstack/react
import { fetchRelationships } from 'soapbox/actions/accounts';
import { importFetchedAccounts } from 'soapbox/actions/importer';
import { getLinks } from 'soapbox/api';
import { getNextLink } from 'soapbox/api';
import { useApi, useAppDispatch } from 'soapbox/hooks';
import { PaginatedResult, removePageItem } from '../utils/queries';
@ -34,7 +34,7 @@ const useSuggestions = () => {
const endpoint = pageParam?.link || '/api/v2/suggestions';
const response = await api<Suggestion[]>(endpoint);
const hasMore = !!response.headers.get('link');
const nextLink = getLinks(response).refs.find(link => link.rel === 'next')?.uri;
const nextLink = getNextLink(response);
const accounts = response.json.map(({ account }) => account);
const accountIds = accounts.map((account) => account.id);
@ -92,7 +92,7 @@ const useOnboardingSuggestions = () => {
const link = pageParam?.link || '/api/v2/suggestions';
const response = await api<Suggestion[]>(link);
const hasMore = !!response.headers.get('link');
const nextLink = getLinks(response).refs.find(link => link.rel === 'next')?.uri;
const nextLink = getNextLink(response);
const accounts = response.json.map(({ account }) => account);
const accountIds = accounts.map((account) => account.id);