summaryrefslogtreecommitdiffhomepage
path: root/packages/desktop/src/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/desktop/src/index.tsx')
-rw-r--r--packages/desktop/src/index.tsx20
1 files changed, 8 insertions, 12 deletions
diff --git a/packages/desktop/src/index.tsx b/packages/desktop/src/index.tsx
index 505a00b16..2b4406162 100644
--- a/packages/desktop/src/index.tsx
+++ b/packages/desktop/src/index.tsx
@@ -7,7 +7,6 @@ import { getCurrent, onOpenUrl } from "@tauri-apps/plugin-deep-link"
import { open as shellOpen } from "@tauri-apps/plugin-shell"
import { type as ostype } from "@tauri-apps/plugin-os"
import { check, Update } from "@tauri-apps/plugin-updater"
-import { invoke } from "@tauri-apps/api/core"
import { getCurrentWindow } from "@tauri-apps/api/window"
import { isPermissionGranted, requestPermission } from "@tauri-apps/plugin-notification"
import { relaunch } from "@tauri-apps/plugin-process"
@@ -22,6 +21,7 @@ import { createMenu } from "./menu"
import { initI18n, t } from "./i18n"
import pkg from "../package.json"
import "./styles.css"
+import { commands } from "./bindings"
const root = document.getElementById("root")
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
@@ -274,12 +274,12 @@ const createPlatform = (password: Accessor<string | null>): Platform => ({
update: async () => {
if (!UPDATER_ENABLED || !update) return
- if (ostype() === "windows") await invoke("kill_sidecar").catch(() => undefined)
+ if (ostype() === "windows") await commands.killSidecar().catch(() => undefined)
await update.install().catch(() => undefined)
},
restart: async () => {
- await invoke("kill_sidecar").catch(() => undefined)
+ await commands.killSidecar().catch(() => undefined)
await relaunch()
},
@@ -335,17 +335,13 @@ const createPlatform = (password: Accessor<string | null>): Platform => ({
},
getDefaultServerUrl: async () => {
- const result = await invoke<string | null>("get_default_server_url").catch(() => null)
+ const result = await commands.getDefaultServerUrl().catch(() => null)
return result
},
- setDefaultServerUrl: async (url: string | null) => {
- await invoke("set_default_server_url", { url })
- },
+ setDefaultServerUrl: async (url: string | null) => { await commands.setDefaultServerUrl(url) },
- parseMarkdown: async (markdown: string) => {
- return invoke<string>("parse_markdown_command", { markdown })
- },
+ parseMarkdown: (markdown: string) => commands.parseMarkdownCommand(markdown),
webviewZoom,
})
@@ -394,7 +390,7 @@ type ServerReadyData = { url: string; password: string | null }
// Gate component that waits for the server to be ready
function ServerGate(props: { children: (data: Accessor<ServerReadyData>) => JSX.Element }) {
const [serverData] = createResource<ServerReadyData>(() =>
- invoke("ensure_server_ready").then((v) => {
+ commands.ensureServerReady().then((v) => {
return new Promise((res) => setTimeout(() => res(v as ServerReadyData), 2000))
}),
)
@@ -408,7 +404,7 @@ function ServerGate(props: { children: (data: Accessor<ServerReadyData>) => JSX.
}
const restartApp = async () => {
- await invoke("kill_sidecar").catch(() => undefined)
+ await commands.killSidecar().catch(() => undefined)
await relaunch().catch(() => undefined)
}