mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-21 00:49:17 +01:00
Environments in URL and better rendering
This commit is contained in:
@@ -3,17 +3,13 @@ import type { Environment } from '../lib/models';
|
||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||
import { useEnvironments } from './useEnvironments';
|
||||
|
||||
export function useActiveEnvironment(): [Environment | null, (environment: Environment) => void] {
|
||||
const [id, setId] = useActiveEnvironmentId();
|
||||
export function useActiveEnvironment(): Environment | null {
|
||||
const id = useActiveEnvironmentId();
|
||||
const environments = useEnvironments();
|
||||
const environment = useMemo(
|
||||
() => environments.find((w) => w.id === id) ?? null,
|
||||
[environments, id],
|
||||
);
|
||||
|
||||
const setActiveEnvironment = useCallback((e: Environment) => {
|
||||
setId(e.id)
|
||||
}, [setId]);
|
||||
|
||||
return [environment, setActiveEnvironment];
|
||||
return environment;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user