refactor refetch and stale time

This commit is contained in:
Kevin Puig
2025-09-28 10:47:29 -04:00
parent ac5f6ed680
commit 8fcc775c66
4 changed files with 11 additions and 11 deletions

View File

@@ -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,
});
};

View File

@@ -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,
});
};

View File

@@ -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,
});
};

View File

@@ -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