summary refs log tree commit diff
path: root/ui
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2025-02-22 20:23:43 -0700
committerAshelyn Rose <git@ashen.earth>2025-02-22 20:23:43 -0700
commitddbef5d475951dfd9157221b611e7d1ac06da86b (patch)
treef143f1dfc0b61c97aeb513c9bfa540260b3e753d /ui
parent5c6a049c4c962be7bf889897b16a1778bbe63819 (diff)
Incredibly messy persistence refactor
Stores account information in the app data folder, and account credentials in the OS keychain
Diffstat (limited to 'ui')
-rw-r--r--ui/src/root.tsx20
1 files changed, 18 insertions, 2 deletions
diff --git a/ui/src/root.tsx b/ui/src/root.tsx
index bb4b763..13b3021 100644
--- a/ui/src/root.tsx
+++ b/ui/src/root.tsx
@@ -1,7 +1,8 @@
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
 import { invoke } from '@tauri-apps/api/core';
 
 export default function Root() {
+  const [existingAccounts, setExistingAccounts] = useState<any>([])
   const [signedIn, setSignedIn] = useState<{serverDomain: string, username: string} | null>(null)
   const [accountData, setAccountData] = useState('')
 
@@ -17,10 +18,25 @@ export default function Root() {
     setAccountData(JSON.parse(result))
   }
 
+  useEffect(() => {
+    (async () => {
+      setExistingAccounts(await invoke('get_all_accounts'))
+    })()
+  }, [])
+
   return (
     <>
       {!signedIn ? (
-        <button onClick={signIn}>Sign in</button>
+        <>
+          <p>Existing accounts:</p>
+          {existingAccounts.map(({username, server_domain}: {username: string, server_domain: string}) => (
+            <>
+              <button key={username + server_domain} onClick={() => setSignedIn({serverDomain: server_domain, username})}>@{username}@{server_domain}</button>
+              <br/>
+            </>
+          ))}
+          <button onClick={signIn}>Add another account</button>
+        </>
       ) : (!accountData ? (
         <button onClick={getSelf}>Retrieve account data</button>
       ):(