feat: add automatic identity synchronization (#167)

This commit is contained in:
Linus Rath
2026-04-09 19:39:04 +02:00
parent f42f57b8d0
commit d0cc439fd1
4 changed files with 59 additions and 0 deletions
+13
View File
@@ -47,6 +47,7 @@ interface AuthState {
checkAuth: () => Promise<void>;
clearError: () => void;
syncIdentities: () => void;
refreshIdentities: () => Promise<void>;
getClientForAccount: (accountId: string) => JMAPClient | undefined;
}
@@ -1513,6 +1514,18 @@ export const useAuthStore = create<AuthState>()(
set({ identities, primaryIdentity });
},
refreshIdentities: async () => {
const { client, username } = get();
if (!client || !username) return;
try {
const rawIdentities = await client.getIdentities();
const { identities, primaryIdentity } = loadIdentities(rawIdentities, username);
set({ identities, primaryIdentity });
} catch {
// Silently fail — background sync should not surface errors to the user
}
},
getClientForAccount: (accountId: string) => {
return clients.get(accountId);
},