fix: remove empty-array placeholderData so archived threads loading state is reachable
placeholderData with a fallback to an empty array caused TanStack Query v5 to start in 'success' status, making isPending always false. The loading UI was dead code and users saw a misleading 'No archived threads' flash. Now placeholderData only returns the previous value (undefined on first load), so the query correctly starts in pending status.
This commit is contained in:
1 file changed
+1
-4
@@ -1,4 +1,3 @@
|
||||
import type { OrchestrationListArchivedThreadsResult } from "@t3tools/contracts";
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
import { ensureNativeApi } from "~/nativeApi";
|
||||
|
||||
@@ -8,8 +7,6 @@ export const orchestrationQueryKeys = {
|
||||
};
|
||||
|
||||
const DEFAULT_ARCHIVED_THREADS_STALE_TIME = 15_000;
|
||||
const EMPTY_ARCHIVED_THREADS: OrchestrationListArchivedThreadsResult = [];
|
||||
|
||||
export function archivedThreadsQueryOptions() {
|
||||
return queryOptions({
|
||||
queryKey: orchestrationQueryKeys.archivedThreads(),
|
||||
@@ -18,6 +15,6 @@ export function archivedThreadsQueryOptions() {
|
||||
return api.orchestration.listArchivedThreads();
|
||||
},
|
||||
staleTime: DEFAULT_ARCHIVED_THREADS_STALE_TIME,
|
||||
placeholderData: (previous) => previous ?? EMPTY_ARCHIVED_THREADS,
|
||||
placeholderData: (previous) => previous,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user