mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-27 03:41:11 +01:00
Tackled remaining perf wins
This commit is contained in:
@@ -4,11 +4,18 @@ import { atom } from 'jotai/index';
|
||||
|
||||
export const environmentsAtom = atom<Environment[]>([]);
|
||||
|
||||
export function useEnvironments() {
|
||||
const allEnvironments = useAtomValue(environmentsAtom);
|
||||
export const environmentsBreakdownAtom = atom<{
|
||||
baseEnvironment: Environment | null;
|
||||
allEnvironments: Environment[];
|
||||
subEnvironments: Environment[];
|
||||
}>((get) => {
|
||||
const allEnvironments = get(environmentsAtom);
|
||||
const baseEnvironment = allEnvironments.find((e) => e.environmentId == null) ?? null;
|
||||
const subEnvironments =
|
||||
allEnvironments.filter((e) => e.environmentId === (baseEnvironment?.id ?? 'n/a')) ?? [];
|
||||
|
||||
return { baseEnvironment, subEnvironments, allEnvironments } as const;
|
||||
});
|
||||
|
||||
export function useEnvironments() {
|
||||
return useAtomValue(environmentsBreakdownAtom);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user