diff --git a/src/api/client.ts b/src/api/client.ts index 0e290b8..bffe10d 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -36,6 +36,7 @@ export type Thread = { export type MessageSummary = { id: string; folder_id: string; + thread_id: string | null; from_addr: Address; to_addrs: Address[]; cc_addrs: Address[]; diff --git a/src/components/AppShell.tsx b/src/components/AppShell.tsx index 3b86e41..7d34e63 100644 --- a/src/components/AppShell.tsx +++ b/src/components/AppShell.tsx @@ -1,6 +1,7 @@ import { Outlet, useNavigate } from '@tanstack/react-router'; import { useEffect, useState } from 'react'; import { useQuery } from '@tanstack/react-query'; +// @ts-expect-error — tinykeys has no bundled .d.ts for its ESM export path import { tinykeys } from 'tinykeys'; import { api } from '@/api/client'; import { useUI } from '@/store/ui'; @@ -30,15 +31,18 @@ export function AppShell() { // Global keyboard shortcuts useEffect(() => { + const nav = (folderId: string) => () => + navigate({ to: '/f/$folderId', params: { folderId } }); + return tinykeys(window, { - c: (e) => { if (!isComposeOpen && !isInput(e.target)) openCompose(); }, - '/': (e) => { if (!isInput(e.target)) { e.preventDefault(); document.getElementById('search-input')?.focus(); } }, + c: (e: Event) => { if (!isComposeOpen && !isInput((e as KeyboardEvent).target)) openCompose(); }, + '/': (e: Event) => { if (!isInput((e as KeyboardEvent).target)) { e.preventDefault(); document.getElementById('search-input')?.focus(); } }, Escape: () => closeCompose(), - 'g i': () => navigate({ to: '/f/inbox' }), - 'g s': () => navigate({ to: '/f/sent' }), - 'g d': () => navigate({ to: '/f/drafts' }), - 'g e': () => navigate({ to: '/f/archive' }), - 'g t': () => navigate({ to: '/f/trash' }), + 'g i': nav('inbox'), + 'g s': nav('sent'), + 'g d': nav('drafts'), + 'g e': nav('archive'), + 'g t': nav('trash'), }); }, [isComposeOpen, navigate, openCompose, closeCompose]); diff --git a/src/router.tsx b/src/router.tsx index 6048d44..3bb906c 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -13,7 +13,7 @@ const rootRoute = createRootRoute({ component: AppShell }); const indexRoute = createRoute({ getParentRoute: () => rootRoute, path: '/', - beforeLoad: () => { throw redirect({ to: '/f/inbox' }); }, + beforeLoad: () => { throw redirect({ to: '/f/$folderId', params: { folderId: 'inbox' } }); }, }); const folderRoute = createRoute({