From ddbef5d475951dfd9157221b611e7d1ac06da86b Mon Sep 17 00:00:00 2001 From: Ashelyn Rose Date: Sat, 22 Feb 2025 20:23:43 -0700 Subject: Incredibly messy persistence refactor Stores account information in the app data folder, and account credentials in the OS keychain --- ui/src/root.tsx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'ui/src') 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([]) 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 ? ( - + <> +

Existing accounts:

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