remove mock peers

This commit is contained in:
Eduard Gert
2026-05-22 16:28:24 +02:00
parent 8f957ff41a
commit 513ecd456c
8 changed files with 107 additions and 443 deletions
+45
View File
@@ -0,0 +1,45 @@
import { createContext, useCallback, useContext, useState, type ReactNode } from "react";
import { Window } from "@wailsio/runtime";
export type ViewMode = "default" | "advanced";
// Window dimensions per view. Height matches the Settings window (640) so
// the chrome height is identical across surfaces; width grows from the
// compact 380 default to 900 in advanced.
export const VIEW_SIZE: Record<ViewMode, { width: number; height: number }> = {
default: { width: 380, height: 640 },
advanced: { width: 900, height: 640 },
};
type ViewModeContextValue = {
viewMode: ViewMode;
setViewMode: (mode: ViewMode) => void;
};
const ViewModeContext = createContext<ViewModeContextValue | null>(null);
export const ViewModeProvider = ({ children }: { children: ReactNode }) => {
const [viewMode, setMode] = useState<ViewMode>("default");
const setViewMode = useCallback(
(mode: ViewMode) => {
setMode((prev) => {
if (prev === mode) return prev;
const { width, height } = VIEW_SIZE[mode];
void Window.SetSize(width, height).catch(() => {});
return mode;
});
},
[],
);
return (
<ViewModeContext.Provider value={{ viewMode, setViewMode }}>
{children}
</ViewModeContext.Provider>
);
};
export const useViewMode = () => {
const ctx = useContext(ViewModeContext);
if (!ctx) throw new Error("useViewMode must be used inside ViewModeProvider");
return ctx;
};