mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-06-06 02:31:13 +02:00
ui: simpler streams
This commit is contained in:
@@ -2,11 +2,7 @@ import { v4 as uuidv4 } from "uuid";
|
||||
import type { MosaicNode } from "react-mosaic-component";
|
||||
import { GrimoireState, WindowInstance, UserRelays } from "@/types/app";
|
||||
import { insertWindow } from "@/lib/layout-utils";
|
||||
import {
|
||||
applyPresetToLayout,
|
||||
balanceLayout,
|
||||
type LayoutPreset,
|
||||
} from "@/lib/layout-presets";
|
||||
import { applyPresetToLayout, type LayoutPreset } from "@/lib/layout-presets";
|
||||
|
||||
/**
|
||||
* Finds the lowest available workspace number.
|
||||
@@ -398,28 +394,3 @@ export const applyPresetLayout = (
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Balances all split percentages in the active workspace to 50/50.
|
||||
* Useful for equalizing splits after manual resizing.
|
||||
*/
|
||||
export const balanceLayoutInWorkspace = (
|
||||
state: GrimoireState,
|
||||
): GrimoireState => {
|
||||
const activeId = state.activeWorkspaceId;
|
||||
const ws = state.workspaces[activeId];
|
||||
|
||||
// Balance the layout tree
|
||||
const balancedLayout = balanceLayout(ws.layout);
|
||||
|
||||
return {
|
||||
...state,
|
||||
workspaces: {
|
||||
...state.workspaces,
|
||||
[activeId]: {
|
||||
...ws,
|
||||
layout: balancedLayout,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -241,11 +241,6 @@ export const useGrimoire = () => {
|
||||
[setState],
|
||||
);
|
||||
|
||||
const balanceLayout = useCallback(
|
||||
() => setState((prev) => Logic.balanceLayoutInWorkspace(prev)),
|
||||
[setState],
|
||||
);
|
||||
|
||||
return {
|
||||
state,
|
||||
locale: state.locale || browserLocale,
|
||||
@@ -261,6 +256,5 @@ export const useGrimoire = () => {
|
||||
setActiveAccountRelays,
|
||||
updateLayoutConfig,
|
||||
applyPresetLayout,
|
||||
balanceLayout,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user