inline email resync instead of job queue, refresh list on completion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-22 17:07:06 +00:00
co-authored by Claude Opus 4.6
parent ea8113e61d
commit b3f1d10bc1
7 changed files with 367 additions and 83 deletions
@@ -158,12 +158,16 @@ export const EmailAccounts = () => {
const handleSync = async (id: number) => {
setSyncing(id);
try {
await client.post(`/email/accounts/${id}/sync`, {});
toast.success('Sync started');
// Update local state immediately
setAccounts((prev) => prev.map((a) => (a.id === id ? { ...a, status: 'queued' } : a)));
const result = await client.post<{ ok: boolean; saved?: number }>(`/email/accounts/${id}/sync`, {});
if (result.saved !== undefined) {
toast.success(result.saved > 0 ? `${result.saved} new emails` : 'No new emails');
} else {
toast.success('Sync started');
setAccounts((prev) => prev.map((a) => (a.id === id ? { ...a, status: 'queued' } : a)));
}
fetchAccounts();
} catch (err) {
toast.error(err instanceof Error ? err.message : 'Failed to start sync');
toast.error(err instanceof Error ? err.message : 'Failed to sync');
} finally {
setSyncing(null);
}