|
|
@@ -1,19 +1,28 @@
|
|
|
-import { SWRResponse } from 'swr';
|
|
|
-import useSWRImmutable from 'swr/immutable';
|
|
|
+import useSWR, { SWRResponse } from 'swr';
|
|
|
|
|
|
import { apiGet } from '~/client/util/apiv1-client';
|
|
|
import { IResTagsListApiv1, IResTagsSearchApiv1 } from '~/interfaces/tag';
|
|
|
|
|
|
export const useSWRxTagsList = (limit?: number, offset?: number): SWRResponse<IResTagsListApiv1, Error> => {
|
|
|
- return useSWRImmutable(
|
|
|
+ return useSWR(
|
|
|
['/tags.list', limit, offset],
|
|
|
([endpoint, limit, offset]) => apiGet(endpoint, { limit, offset }).then((result: IResTagsListApiv1) => result),
|
|
|
+ {
|
|
|
+ keepPreviousData: true,
|
|
|
+ revalidateOnFocus: false,
|
|
|
+ revalidateOnReconnect: false,
|
|
|
+ },
|
|
|
);
|
|
|
};
|
|
|
|
|
|
export const useSWRxTagsSearch = (query: string): SWRResponse<IResTagsSearchApiv1, Error> => {
|
|
|
- return useSWRImmutable(
|
|
|
+ return useSWR(
|
|
|
['/tags.search', query],
|
|
|
([endpoint, query]) => apiGet(endpoint, { q: query }).then((result: IResTagsSearchApiv1) => result),
|
|
|
+ {
|
|
|
+ keepPreviousData: true,
|
|
|
+ revalidateOnFocus: false,
|
|
|
+ revalidateOnReconnect: false,
|
|
|
+ },
|
|
|
);
|
|
|
};
|