Skip to content

Commit

Permalink
feat: Persist splitter sizes in settings.json
Browse files Browse the repository at this point in the history
Fixes #79
  • Loading branch information
OiNutter committed Oct 3, 2021
1 parent 36b8cc9 commit 1c1b123
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/ServerInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import EditorWindow, { FileManagementProps } from "./EditorWindow";
import ResultsWindow from "./ResultsWindow";
import TablePanel from "./TablePanel";
import Split from "react-split";
import Settings from "../settings/settings";

interface ServerInterfaceProps extends FileManagementProps {
connection: KdbConnection;
Expand All @@ -25,6 +26,8 @@ const ServerInterface: FC<ServerInterfaceProps> = ({
const [isLoading, setIsLoading] = useState(false);
const [results, setResults] = useState<Result | undefined>();

const settings = Settings.getInstance();

async function executeQuery(script: string) {
if (connection && connection.isConnected()) {
try {
Expand Down Expand Up @@ -85,7 +88,7 @@ const ServerInterface: FC<ServerInterfaceProps> = ({

<Split
direction="vertical"
sizes={[40, 60]}
sizes={settings.get("splitterSizes")}
gutterSize={10}
gutter={renderGutter}
minSize={100}
Expand All @@ -97,6 +100,9 @@ const ServerInterface: FC<ServerInterfaceProps> = ({
alignItems: "stretch",
minWidth: 0,
}}
onDragEnd={(sizes: number[]) => {
settings.set("splitterSizes", sizes);
}}
>
<EditorWindow
onExecuteQuery={executeQuery}
Expand Down
2 changes: 2 additions & 0 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import fs from "fs/promises";
interface SettingsData {
customAuthPlugin?: string[];
autoUpdate: boolean;
splitterSizes: number[];
}

export default class Settings {
data: SettingsData = {
autoUpdate: true,
splitterSizes: [40, 60],
};
filePath: string = "";
loaded: boolean = false;
Expand Down

0 comments on commit 1c1b123

Please sign in to comment.