File tree Expand file tree Collapse file tree 6 files changed +35
-26
lines changed
Expand file tree Collapse file tree 6 files changed +35
-26
lines changed Original file line number Diff line number Diff line change 11import { stats } from "tauri-plugin-cache-api" ;
22import { log } from "$lib/log" ;
3- import { settings } from "$lib/settings" ;
43import { loadThemes } from "$lib/themes" ;
54
65export async function init ( ) {
76 const { totalSize } = await stats ( ) ;
87 log . info ( `Cache has ${ totalSize } items` ) ;
98
10- await settings . start ( ) ;
11- log . info ( "Settings synced" ) ;
12-
139 await loadThemes ( ) ;
1410}
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ import { page } from "$app/state";
44import { app } from "$lib/app.svelte" ;
55import type { Channel } from "$lib/models/channel.svelte" ;
66import { settings } from "$lib/settings" ;
7- import type { SplitBranch , SplitDirection } from "$lib/split-layout" ;
7+ import type { SplitBranch } from "$lib/split-layout" ;
8+
9+ type SplitDirection = "up" | "down" | "left" | "right" ;
810
911async function splitItem ( channel : Channel , direction : SplitDirection ) {
1012 return MenuItem . new ( {
Original file line number Diff line number Diff line change 11import { RuneStore } from "@tauri-store/svelte" ;
22import type { User } from "./graphql/twitch" ;
3- import type { SplitNode } from "./split-layout" ;
43
54export type HighlightType =
65 | "mention"
@@ -70,7 +69,6 @@ interface Settings extends UserSettings {
7069 user : StoredUser | null ;
7170 lastJoined : string | null ;
7271 pinned : string [ ] ;
73- layout : SplitNode | null ;
7472}
7573
7674export const defaultHighlightTypes : Record < HighlightType , HighlightConfig > = {
@@ -88,7 +86,6 @@ export const defaults: Settings = {
8886 user : null ,
8987 lastJoined : null ,
9088 pinned : [ ] ,
91- layout : null ,
9289
9390 "appearance.theme" : "" ,
9491 "chat.hideScrollbar" : false ,
@@ -117,14 +114,4 @@ export const defaults: Settings = {
117114 "advanced.logs.level" : "info" ,
118115} ;
119116
120- export const settings = new RuneStore < Settings > ( "settings" , defaults , {
121- hooks : {
122- beforeBackendSync ( state ) {
123- if ( typeof state . layout === "string" ) {
124- state . layout = null ;
125- }
126-
127- return state ;
128- } ,
129- } ,
130- } ) ;
117+ export const settings = new RuneStore < Settings > ( "settings" , defaults , { autoStart : true } ) ;
Original file line number Diff line number Diff line change 11import type { DragDropEvents } from "@dnd-kit-svelte/svelte" ;
22import type { PaneGroupProps } from "paneforge" ;
3- import { settings } from "$lib/settings " ;
3+ import { layout } from "./stores " ;
44
5- export type SplitAxis = PaneGroupProps [ "direction" ] ;
6- export type SplitDirection = "up" | "down" | "left" | "right" ;
5+ type SplitAxis = PaneGroupProps [ "direction" ] ;
76
87export interface SplitBranch {
98 axis : SplitAxis ;
@@ -18,11 +17,11 @@ type SplitPath = ("before" | "after")[];
1817
1918export class SplitLayout {
2019 public get root ( ) {
21- return settings . state . layout ;
20+ return layout . state . root ;
2221 }
2322
2423 public set root ( value : SplitNode | null ) {
25- settings . state . layout = value ;
24+ layout . state . root = value ;
2625 }
2726
2827 public insert ( target : string , newNode : string , branch : SplitBranch ) {
Original file line number Diff line number Diff line change 1+ import { RuneStore } from "@tauri-store/svelte" ;
2+ import type { SplitNode } from "./split-layout" ;
3+
4+ interface Layout {
5+ [ key : string ] : unknown ;
6+ root : SplitNode | null ;
7+ }
8+
9+ export const layout = new RuneStore < Layout > (
10+ "layout" ,
11+ { root : null } ,
12+ {
13+ autoStart : true ,
14+ hooks : {
15+ beforeBackendSync ( state ) {
16+ if ( typeof state . root === "string" ) {
17+ state . root = null ;
18+ }
19+
20+ return state ;
21+ } ,
22+ } ,
23+ } ,
24+ ) ;
Original file line number Diff line number Diff line change 88 import { buttonVariants } from " $lib/components/ui/button" ;
99 import * as Empty from " $lib/components/ui/empty" ;
1010 import { settings } from " $lib/settings" ;
11+ import { layout } from " $lib/stores" ;
1112
1213 let loading = $state (true );
1314
1819 await app .user .fetchEmoteSets ();
1920 }
2021
21- if (settings .state .layout ) {
22- app .splits .root = settings .state .layout ;
22+ if (layout .state .root ) {
23+ app .splits .root = layout .state .root ;
2324
2425 await goto (" /channels/split" );
2526 } else if (settings .state .lastJoined ) {
You can’t perform that action at this time.
0 commit comments