ui: simpler streams

This commit is contained in:
Alejandro Gómez
2025-12-18 15:29:01 +01:00
parent b57ff31907
commit 3fba62b316
16 changed files with 223 additions and 639 deletions

View File

@@ -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,
},
},
};
};

View File

@@ -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,
};
};