Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat: make search context queries static (#1622)

gbirman7aa2611f053d
diff --git a/js/app/packages/app/component/next-soup/search-context.tsx b/js/app/packages/app/component/next-soup/search-context.tsx
index 1383eb571a..a4fa0593dd 100644
--- a/js/app/packages/app/component/next-soup/search-context.tsx
+++ b/js/app/packages/app/component/next-soup/search-context.tsx
@@ -54,7 +54,12 @@ export const useSearchContext = () => {
};
export const SearchProvider: FlowComponent = (props) => {
- const itemsQuery = useSoupItemsQuery(() => ITEM_PRELOAD_ARGS);
+ const itemsQuery = useSoupItemsQuery(
+ () => ITEM_PRELOAD_ARGS,
+ () => ({
+ staleTime: 'static',
+ })
+ );
const itemsFetchNextPage = throttle(() => itemsQuery.fetchNextPage(), 2000);
createDeferred(() => {
if (itemsQuery.hasNextPage && !itemsQuery.isFetchingNextPage) {
@@ -62,7 +67,12 @@ export const SearchProvider: FlowComponent = (props) => {
}
});
- const channelItemsQuery = useSoupItemsQuery(() => CHANNEL_PRELOAD_ARGS);
+ const channelItemsQuery = useSoupItemsQuery(
+ () => CHANNEL_PRELOAD_ARGS,
+ () => ({
+ staleTime: 'static',
+ })
+ );
const channelItemsFetchNextPage = throttle(
() => channelItemsQuery.fetchNextPage(),
2000
diff --git a/js/app/packages/queries/soup/items.ts b/js/app/packages/queries/soup/items.ts
index afbb8ba01a..e3c24cdfe5 100644
--- a/js/app/packages/queries/soup/items.ts
+++ b/js/app/packages/queries/soup/items.ts
@@ -10,6 +10,7 @@ import type { PostSoupRequest } from '@service-storage/generated/schemas/postSou
import {
useInfiniteQuery,
type UseInfiniteQueryResult,
+ type StaleTime,
} from '@tanstack/solid-query';
import type { Accessor } from 'solid-js';
@@ -27,7 +28,8 @@ export type SoupItemsQueryArgs = {
export type UseSoupQueryResult = UseInfiniteQueryResult<EntityData[], Error>;
interface SoupItemsQueryOptions {
- enabled: boolean;
+ enabled?: boolean;
+ staleTime?: StaleTime;
}
export const useSoupItemsQuery = (
@@ -62,6 +64,7 @@ export const useSoupItemsQuery = (
});
},
enabled: options?.().enabled,
+ staleTime: options?.().staleTime,
placeholderData: (p) => p,
}));
};