rqbit/desktop/src/main.tsx

36 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-12-07 11:56:02 +00:00
import { StrictMode } from "react";
import ReactDOM from "react-dom/client";
2023-12-02 22:24:36 +00:00
import { API } from "./api";
2023-12-06 12:14:26 +00:00
import { invoke } from "@tauri-apps/api";
2023-12-07 00:13:11 +00:00
import { CurrentDesktopState, RqbitDesktopConfig } from "./configuration";
2023-12-06 22:38:55 +00:00
import { RqbitDesktop } from "./rqbit-desktop";
import { APIContext } from "./rqbit-webui-src/context";
2023-12-06 12:14:26 +00:00
async function get_version(): Promise<string> {
return invoke<string>("get_version");
}
async function get_default_config(): Promise<RqbitDesktopConfig> {
return invoke<RqbitDesktopConfig>("config_default");
}
2023-12-07 00:13:11 +00:00
async function get_current_config(): Promise<CurrentDesktopState> {
return invoke<CurrentDesktopState>("config_current");
2023-12-07 00:13:11 +00:00
}
Promise.all([get_version(), get_default_config(), get_current_config()]).then(
([version, defaultConfig, currentState]) => {
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<StrictMode>
<APIContext.Provider value={API}>
<RqbitDesktop
version={version}
defaultConfig={defaultConfig}
currentState={currentState}
/>
</APIContext.Provider>
</StrictMode>
2023-12-06 12:14:26 +00:00
);
}
);