|
@@ -3,14 +3,13 @@ import { apiv3Get } from '../client/util/apiv3-client';
|
|
|
import { IBookmarkInfo } from '../interfaces/bookmark-info';
|
|
import { IBookmarkInfo } from '../interfaces/bookmark-info';
|
|
|
|
|
|
|
|
|
|
|
|
|
-export const useSWRBookmarkInfo = (pageId: string): SWRResponse<IBookmarkInfo, Error> => {
|
|
|
|
|
- return useSWR(
|
|
|
|
|
- `/bookmarks/info?pageId=${pageId}`,
|
|
|
|
|
- endpoint => apiv3Get(endpoint).then((response) => {
|
|
|
|
|
- return {
|
|
|
|
|
- sumOfBookmarks: response.data.sumOfBookmarks,
|
|
|
|
|
- isBookmarked: response.data.isBookmarked,
|
|
|
|
|
- };
|
|
|
|
|
- }),
|
|
|
|
|
- );
|
|
|
|
|
|
|
+export const useSWRBookmarkInfo = (pageId: string | null): SWRResponse<IBookmarkInfo, Error> => {
|
|
|
|
|
+ return useSWR(pageId != null
|
|
|
|
|
+ ? `/bookmarks/info?pageId=${pageId}` : null,
|
|
|
|
|
+ endpoint => apiv3Get(endpoint).then((response) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ sumOfBookmarks: response.data.sumOfBookmarks,
|
|
|
|
|
+ isBookmarked: response.data.isBookmarked,
|
|
|
|
|
+ };
|
|
|
|
|
+ }));
|
|
|
};
|
|
};
|