From 77b1aba5acc66dfaeb02b08d60d88442336026a6 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Tue, 23 Apr 2024 13:56:35 +0100 Subject: feature(extension): Allow adding tags and lists to newly hoarded bookmarks --- packages/shared-react/hooks/bookmarks.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'packages/shared-react/hooks/bookmarks.ts') diff --git a/packages/shared-react/hooks/bookmarks.ts b/packages/shared-react/hooks/bookmarks.ts index 2a549d1f..ceaed3a9 100644 --- a/packages/shared-react/hooks/bookmarks.ts +++ b/packages/shared-react/hooks/bookmarks.ts @@ -1,7 +1,26 @@ import { api } from "../trpc"; +import { isBookmarkStillLoading } from "../utils/bookmarkUtils"; import { useBookmarkGridContext } from "./bookmark-grid-context"; import { useAddBookmarkToList } from "./lists"; +export function useAutoRefreshingBookmarkQuery( + input: Parameters[0], +) { + return api.bookmarks.getBookmark.useQuery(input, { + refetchInterval: (query) => { + const data = query.state.data; + if (!data) { + return false; + } + // If the link is not crawled or not tagged + if (isBookmarkStillLoading(data)) { + return 1000; + } + return false; + }, + }); +} + export function useCreateBookmarkWithPostHook( ...opts: Parameters ) { -- cgit v1.2.3-70-g09d2