Skip to content

Commit 0ba753f

Browse files
committed
persist layout
1 parent 5626a41 commit 0ba753f

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/lib/managers/split-manager.svelte.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { DragDropEvents } from "@dnd-kit-svelte/svelte";
22
import type { PaneGroupProps } from "paneforge";
3+
import { settings } from "$lib/settings";
34

45
export type SplitDirection = "up" | "down" | "left" | "right";
56

@@ -15,10 +16,12 @@ export type SplitNode = SplitParent | string;
1516
type SplitPath = "first" | "second";
1617

1718
export class SplitManager {
18-
public root = $state<SplitNode | null>(null);
19+
public get root() {
20+
return settings.state.layout;
21+
}
1922

20-
public constructor(root?: SplitNode) {
21-
this.root = root ?? null;
23+
public set root(value: SplitNode | null) {
24+
settings.state.layout = value;
2225
}
2326

2427
public insert(target: string, newNode: string, data: SplitParent) {

src/lib/settings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RuneStore } from "@tauri-store/svelte";
22
import type { User } from "./graphql/twitch";
3+
import type { SplitNode } from "./managers/split-manager.svelte";
34

45
export type HighlightType =
56
| "mention"
@@ -69,6 +70,7 @@ interface Settings extends UserSettings {
6970
user: StoredUser | null;
7071
lastJoined: string | null;
7172
pinned: string[];
73+
layout: SplitNode | null;
7274
}
7375

7476
export const defaultHighlightTypes: Record<HighlightType, HighlightConfig> = {
@@ -86,6 +88,7 @@ export const defaults: Settings = {
8688
user: null,
8789
lastJoined: null,
8890
pinned: [],
91+
layout: null,
8992

9093
"appearance.theme": "",
9194
"chat.hideScrollbar": false,

src/routes/(main)/+page.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
await app.user.fetchEmoteSets();
1919
}
2020
21-
if (settings.state.lastJoined) {
21+
if (settings.state.layout) {
22+
app.splits.root = settings.state.layout;
23+
24+
await goto("/channels/split");
25+
} else if (settings.state.lastJoined) {
2226
await goto(`/channels/${settings.state.lastJoined}`);
2327
}
2428

0 commit comments

Comments
 (0)