chore: Update gitignore and init state before running app
This commit is contained in:
parent
ac6a6de8e3
commit
f11b620531
6 changed files with 26 additions and 37 deletions
2
desktop/.gitignore
vendored
2
desktop/.gitignore
vendored
|
|
@ -1,3 +1,3 @@
|
|||
/dist-isolation
|
||||
/coverage
|
||||
./src/bindings.ts
|
||||
/src/bindings.ts
|
||||
|
|
|
|||
|
|
@ -7,25 +7,12 @@ macro_rules! collect_commands {
|
|||
use crate::api::commands::*;
|
||||
tauri_specta::ts::builder()
|
||||
.commands(tauri_specta::collect_commands![
|
||||
initialize_state,
|
||||
is_dev
|
||||
])
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tracing::instrument(skip_all)]
|
||||
#[tauri::command]
|
||||
pub async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
onelauncher::ProxyState::initialize(app).await?;
|
||||
let s = onelauncher::State::get().await?;
|
||||
onelauncher::State::update();
|
||||
|
||||
s.processor.write().await.restore().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub fn is_dev() -> bool {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,16 @@ struct SingleInstancePayload {
|
|||
cwd: String,
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
onelauncher::ProxyState::initialize(app).await?;
|
||||
let s = onelauncher::State::get().await?;
|
||||
onelauncher::State::update();
|
||||
|
||||
s.processor.write().await.restore().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn run() {
|
||||
// initializes the logger and runs the app. if the logger fails to initialize
|
||||
// we panic because nothing else can be debugged once the logger fails.
|
||||
|
|
@ -60,6 +70,8 @@ pub async fn run_app<F: FnOnce(&mut tauri::App) + Send + 'static>(
|
|||
.build(tauri::tauri_build_context!())
|
||||
.expect("failed to build tauri application");
|
||||
|
||||
initialize_state(app.app_handle().clone()).await;
|
||||
|
||||
app.run(|_app_handle, _event| {})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
|
||||
|
||||
export const commands = {
|
||||
async initializeState() : Promise<Result<null, OneLauncherSerializableError>> {
|
||||
try {
|
||||
return { status: "ok", data: await TAURI_INVOKE("initialize_state") };
|
||||
} catch (e) {
|
||||
if(e instanceof Error) throw e;
|
||||
else return { status: "error", error: e as any };
|
||||
}
|
||||
},
|
||||
async isDev() : Promise<boolean> {
|
||||
return await TAURI_INVOKE("is_dev");
|
||||
}
|
||||
|
|
@ -18,7 +10,7 @@ return await TAURI_INVOKE("is_dev");
|
|||
|
||||
/** user-defined types **/
|
||||
|
||||
export type OneLauncherSerializableError = { CommonError: string }
|
||||
|
||||
|
||||
/** tauri-specta globals **/
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ interface LaunchCallbacks {
|
|||
};
|
||||
|
||||
export function launchCluster(uuid: string, callbacks?: LaunchCallbacks): Promise<number> {
|
||||
return;
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async (resolve) => {
|
||||
let unlisten_stdout: UnlistenFn | undefined;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
import { render } from 'solid-js/web';
|
||||
|
||||
import './imports';
|
||||
import * as bridge from "./bindings";
|
||||
|
||||
import { Route, Router } from '@solidjs/router';
|
||||
import App from './ui/App';
|
||||
|
|
@ -12,18 +11,16 @@ import UpdatesPage from './ui/pages/Updates';
|
|||
import ClusterRoot from '~ui/pages/cluster/ClusterRoot';
|
||||
import SettingsRoot from '~ui/pages/settings/SettingsRoot';
|
||||
|
||||
bridge.commands.initializeState()
|
||||
|
||||
render(() => (
|
||||
<Router root={App}>
|
||||
<Route path="/" component={HomePage} />
|
||||
<Route path="/browser" component={BrowserPage} />
|
||||
<Route path="/updates" component={UpdatesPage} />
|
||||
<Route path="/clusters" component={ClusterRoot}>
|
||||
<ClusterRoot.Routes />
|
||||
</Route>
|
||||
<Route path="/settings" component={SettingsRoot}>
|
||||
<SettingsRoot.Routes />
|
||||
</Route>
|
||||
</Router>
|
||||
<Router root={App}>
|
||||
<Route path="/" component={HomePage} />
|
||||
<Route path="/browser" component={BrowserPage} />
|
||||
<Route path="/updates" component={UpdatesPage} />
|
||||
<Route path="/clusters" component={ClusterRoot}>
|
||||
<ClusterRoot.Routes />
|
||||
</Route>
|
||||
<Route path="/settings" component={SettingsRoot}>
|
||||
<SettingsRoot.Routes />
|
||||
</Route>
|
||||
</Router>
|
||||
), document.getElementById('root') as HTMLElement);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue