mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-12 22:42:13 +02:00
- Introduced a comprehensive specification for renaming `searchSpace` to `workspace` in `surfsense_web` and `surfsense_desktop`, ensuring all TypeScript identifiers, React props, and local data structures are updated. - Implemented migration shims for persisted local state to prevent data loss during the transition. - Updated observability metrics and IPC channels to reflect the new naming convention. - Removed legacy `active-search-space` module and replaced it with `active-workspace` to maintain consistency. - Ensured no behavioral changes or data loss for users during the renaming process.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { atomWithQuery } from "jotai-tanstack-query";
|
|
import { activeWorkspaceIdAtom } from "@/atoms/workspaces/workspace-query.atoms";
|
|
import { automationsApiService } from "@/lib/apis/automations-api.service";
|
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
|
|
|
// First page of the active workspace's automations.
|
|
// Detail + paginated/parameterized reads live in hooks (see use-automation.ts,
|
|
// use-automation-runs.ts) so atoms stay tied to "current scope" and don't
|
|
// proliferate atom families for every (id, limit, offset) tuple.
|
|
const DEFAULT_LIMIT = 50;
|
|
const DEFAULT_OFFSET = 0;
|
|
|
|
export const automationsListAtom = atomWithQuery((get) => {
|
|
const workspaceId = get(activeWorkspaceIdAtom);
|
|
|
|
return {
|
|
queryKey: cacheKeys.automations.list(Number(workspaceId ?? 0), DEFAULT_LIMIT, DEFAULT_OFFSET),
|
|
enabled: !!workspaceId,
|
|
staleTime: 60 * 1000,
|
|
queryFn: async () => {
|
|
if (!workspaceId) {
|
|
return { items: [], total: 0 };
|
|
}
|
|
return automationsApiService.listAutomations({
|
|
workspace_id: Number(workspaceId),
|
|
limit: DEFAULT_LIMIT,
|
|
offset: DEFAULT_OFFSET,
|
|
});
|
|
},
|
|
};
|
|
});
|