waveterm/frontend/layout/lib/layoutAtom.ts

14 lines
516 B
TypeScript
Raw Normal View History

// Copyright 2025, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
2024-06-12 00:42:10 +00:00
import { WOS } from "@/app/store/global";
2025-10-03 17:10:07 +00:00
import { Atom, Getter } from "jotai";
2025-10-03 17:10:07 +00:00
export function getLayoutStateAtomFromTab(tabAtom: Atom<Tab>, get: Getter): WritableWaveObjectAtom<LayoutState> {
const tabData = get(tabAtom);
if (!tabData) return;
const layoutStateOref = WOS.makeORef("layout", tabData.layoutstate);
const layoutStateAtom = WOS.getWaveObjectAtom<LayoutState>(layoutStateOref);
return layoutStateAtom;
}