From bca380fcf242208e375dd509cbd7bcb4d643a400 Mon Sep 17 00:00:00 2001 From: Ashelyn Rose Date: Tue, 25 Feb 2025 23:48:46 -0700 Subject: TS bindings for Tauri commands --- ui/src/root.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'ui/src') diff --git a/ui/src/root.tsx b/ui/src/root.tsx index 13b3021..2026dde 100644 --- a/ui/src/root.tsx +++ b/ui/src/root.tsx @@ -1,26 +1,29 @@ import { useEffect, useState } from 'react'; -import { invoke } from '@tauri-apps/api/core'; +import { Accounts } from '../bindings/' +import { Account } from '../bindings/Account'; export default function Root() { - const [existingAccounts, setExistingAccounts] = useState([]) + const [existingAccounts, setExistingAccounts] = useState([]) const [signedIn, setSignedIn] = useState<{serverDomain: string, username: string} | null>(null) const [accountData, setAccountData] = useState('') async function signIn() { - let [serverDomain, username] = await invoke('start_account_auth', {instanceDomain: 'social.tempest.dev'}) as string[] + let [serverDomain, username] = await Accounts.startAccountAuth('social.tempest.dev') + setSignedIn({serverDomain, username}) } async function getSelf() { if (!signedIn) throw new Error("Not signed in") const {serverDomain, username} = signedIn; - let result = await invoke('get_self', {serverDomain, username}) as string + let result = await Accounts.getSelf(serverDomain, username) setAccountData(JSON.parse(result)) } useEffect(() => { (async () => { - setExistingAccounts(await invoke('get_all_accounts')) + const result = await Accounts.getAllAccounts() + setExistingAccounts(result) })() }, []) @@ -29,9 +32,9 @@ export default function Root() { {!signedIn ? ( <>

Existing accounts:

- {existingAccounts.map(({username, server_domain}: {username: string, server_domain: string}) => ( + {existingAccounts.map(({username, domain}) => ( <> - +
))} -- cgit 1.4.1