@@ -3,10 +3,11 @@ import { createStore, SetStoreFunction } from "solid-js/store";
33import { ProfileManager } from "./profiles" ;
44import { isURL , isFQDN } from "validator" ;
55import { invoke } from "@tauri-apps/api/core" ;
6- import { Accessor , createSignal , Setter } from "solid-js" ;
6+ import { Setter } from "solid-js" ;
77import { Shortcuts } from "./shortcuts" ;
88import { DownloadProgress , FileDialog } from "cef-client/dist/event_stream" ;
99import { Downloads } from "./downloads" ;
10+ import { UIState } from "./ui" ;
1011import { open } from '@tauri-apps/plugin-dialog' ;
1112
1213type TabId = number ;
@@ -49,26 +50,20 @@ export class AppState {
4950 downloads : Downloads ;
5051 shortcuts : Shortcuts ;
5152 profiles : ProfileManager | undefined ;
53+ ui : UIState ;
5254
5355 tabs : TabState [ ] ;
5456 setTabs : SetStoreFunction < TabState [ ] > ;
5557 connections : Map < TabId , TabConnection > = new Map ( ) ;
5658
57- browserFocused : Accessor < boolean > ;
58- setBrowserFocused : Setter < boolean > ;
59-
60- private focusUrlCallback : ( ( ) => void ) | null = null ;
61- private showNewTabInputCallback : ( ( ) => void ) | null = null ;
62-
6359 constructor ( client : Browser , profiles ?: ProfileManager ) {
6460 this . client = client ;
6561
6662 this . downloads = new Downloads ( ) ;
6763 this . shortcuts = new Shortcuts ( this ) ;
6864 this . profiles = profiles ;
65+ this . ui = new UIState ( ) ;
6966 [ this . tabs , this . setTabs ] = createStore < TabState [ ] > ( [ ] ) ;
70-
71- [ this . browserFocused , this . setBrowserFocused ] = createSignal ( false ) ;
7267 }
7368
7469 async setClient ( client : Browser ) {
@@ -97,36 +92,7 @@ export class AppState {
9792 let tab = await this . client . openTab ( { url } ) ! ;
9893 this . addTab ( tab ) ;
9994 this . setActiveTab ( tab . id ) ;
100- this . focusUrl ( ) ;
101- }
102-
103- setFocusUrlCallback ( callback : ( ) => void ) {
104- this . focusUrlCallback = callback ;
105- }
106-
107- setShowNewTabInputCallback ( callback : ( ) => void ) {
108- this . showNewTabInputCallback = callback ;
109- }
110-
111- focusUrl ( ) {
112- if ( this . focusUrlCallback ) this . focusUrlCallback ( ) ;
113- }
114-
115- showNewTabInput ( ) {
116- if ( this . showNewTabInputCallback ) {
117- this . showNewTabInputCallback ( ) ;
118- } else {
119- console . warn ( "showNewTabInputCallback is not set" ) ;
120- }
121- }
122-
123- isBrowserFocused ( ) : boolean {
124- return this . browserFocused ( ) ;
125- }
126-
127- getStackTrace ( ) : string {
128- const error = new Error ( ) ;
129- return error . stack ?? 'No stack trace available' ;
95+ this . ui . focusUrl ( ) ;
13096 }
13197
13298 getActiveTab ( ) : TabState | undefined {
0 commit comments