From 8fcc775c66ce23fa441d7da9291578cb13294086 Mon Sep 17 00:00:00 2001 From: Kevin Puig <119972216+k-puig@users.noreply.github.com> Date: Sun, 28 Sep 2025 10:47:29 -0400 Subject: [PATCH] refactor refetch and stale time --- concord-client/src/hooks/useCategories.ts | 4 ++-- concord-client/src/hooks/useMessages.ts | 8 ++++---- concord-client/src/hooks/useServers.ts | 8 ++++---- concord-client/src/lib/api-client.ts | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/concord-client/src/hooks/useCategories.ts b/concord-client/src/hooks/useCategories.ts index f54bf62..05448ee 100644 --- a/concord-client/src/hooks/useCategories.ts +++ b/concord-client/src/hooks/useCategories.ts @@ -10,7 +10,7 @@ export const useCategoriesByInstance = (instanceId: string | undefined) => { ? categoryApi.getCategoriesByInstance(instanceId) : Promise.resolve([]), enabled: !!instanceId, - staleTime: 5 * 60 * 1000, // 5 minutes + staleTime: 500 * 1, // 5 minutes }); }; @@ -23,7 +23,7 @@ export const useCategoryById = (categoryId: string | undefined) => { ? categoryApi.getCategoryById(categoryId) : Promise.resolve(null), enabled: !!categoryId, - staleTime: 5 * 60 * 1000, + staleTime: 500 * 1, }); }; diff --git a/concord-client/src/hooks/useMessages.ts b/concord-client/src/hooks/useMessages.ts index 3933b89..17073af 100644 --- a/concord-client/src/hooks/useMessages.ts +++ b/concord-client/src/hooks/useMessages.ts @@ -23,8 +23,8 @@ export const useChannelMessages = (channelId?: string, limit = 50) => { } }, enabled: !!channelId, - staleTime: 1000 * 60 * 1, - refetchInterval: 1000 * 30, + staleTime: 500 * 1, + refetchInterval: 500 * 1, }); }; @@ -58,7 +58,7 @@ export const useChannelMessagesPaginated = ( } }, enabled: !!channelId && !!beforeDate, - staleTime: 1000 * 60 * 5, + staleTime: 500 * 1, }); }; @@ -261,7 +261,7 @@ export const usePinnedMessages = (channelId?: string) => { } }, enabled: !!channelId, - staleTime: 1000 * 60 * 5, + staleTime: 500 * 1, }); }; diff --git a/concord-client/src/hooks/useServers.ts b/concord-client/src/hooks/useServers.ts index ba25703..e9b446b 100644 --- a/concord-client/src/hooks/useServers.ts +++ b/concord-client/src/hooks/useServers.ts @@ -58,7 +58,7 @@ export const useServers = () => { throw new Error("Failed to fetch servers"); } }, - staleTime: 1000 * 60 * 5, + staleTime: 500 * 1, }); }; @@ -113,7 +113,7 @@ export const useInstanceDetails = (instanceId?: string) => { } }, enabled: !!instanceId, - staleTime: 1000 * 60 * 5, + staleTime: 500 * 1, }); }; @@ -134,7 +134,7 @@ export const useInstanceMembers = (instanceId?: string) => { } }, enabled: !!instanceId, - staleTime: 1000 * 60 * 2, + staleTime: 500 * 1, }); }; @@ -264,6 +264,6 @@ export const useChannels = (instanceId?: string) => { return instance?.categories || []; }, enabled: !!instanceId && !!instance, - staleTime: 1000 * 60 * 5, + staleTime: 500 * 1, }); }; diff --git a/concord-client/src/lib/api-client.ts b/concord-client/src/lib/api-client.ts index 0a2ae37..b064efc 100644 --- a/concord-client/src/lib/api-client.ts +++ b/concord-client/src/lib/api-client.ts @@ -8,7 +8,7 @@ export const API_BASE_URL = export const queryClient = new QueryClient({ defaultOptions: { queries: { - staleTime: 1000 * 60, // 1 minute + staleTime: 500 * 1, // 1 minute refetchOnWindowFocus: true, retry: (failureCount, error: any) => { // Don't retry on auth errors