summary refs log tree commit diff
path: root/ui
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2025-02-19 15:51:28 -0700
committerAshelyn Rose <git@ashen.earth>2025-02-19 15:51:28 -0700
commite8314458ccdf4d3c68969b206cd29f2490fb6308 (patch)
tree3eac29d969edc813ae407f0b2e114b033c5d8164 /ui
parent5e8d3bc7008d29115bc520a75a9e49c00e2c270f (diff)
Refactor oauth into its own module
Diffstat (limited to 'ui')
-rw-r--r--ui/src/root.tsx10
1 files changed, 6 insertions, 4 deletions
diff --git a/ui/src/root.tsx b/ui/src/root.tsx
index bc87cd9..bb4b763 100644
--- a/ui/src/root.tsx
+++ b/ui/src/root.tsx
@@ -2,16 +2,18 @@ import { useState } from 'react';
 import { invoke } from '@tauri-apps/api/core';
 
 export default function Root() {
-  const [signedIn, setSignedIn] = useState(false)
+  const [signedIn, setSignedIn] = useState<{serverDomain: string, username: string} | null>(null)
   const [accountData, setAccountData] = useState('')
 
   async function signIn() {
-    await invoke('start_account_auth', {instanceDomain: 'social.tempest.dev'})
-    setSignedIn(true)
+    let [serverDomain, username] = await invoke('start_account_auth', {instanceDomain: 'social.tempest.dev'}) as string[]
+    setSignedIn({serverDomain, username})
   }
 
   async function getSelf() {
-    let result = await invoke('get_self') as string
+    if (!signedIn) throw new Error("Not signed in")
+    const {serverDomain, username} = signedIn;
+    let result = await invoke('get_self', {serverDomain, username}) as string
     setAccountData(JSON.parse(result))
   }