// An app folder that is gone (moved, renamed, deleted, or an old worktree): say so, and offer Locate… (keeps the app's // id, accounts and saved reads) or Remove from the list (no files touched). Shown in the app view and the folder list. import { useState } from 'react'; import { api, errorText, type Project } from '../api'; import { t } from '../i18n'; import { useNav } from '../nav'; import { shortPath } from '../paths'; import { useData } from '../store'; import { Icon } from './icons'; import { Notice } from './kit'; export function useFolderActions(p: Project) { const d = useData(); const [busy, setBusy] = useState(false); const locate = async () => { setBusy(true); try { const found = await api.locateProject(p.id); if (found) { await d.reload(); d.toast({ kind: 'ok', title: t('folder.located', { name: found.name }) }); } } catch (e) { d.toast({ kind: 'bad', title: t('folder.locateFailed'), detail: errorText(e) }); } finally { setBusy(false); } }; const remove = async (after?: () => void) => { setBusy(true); try { await api.removeProject(p.id); await d.reload(); d.toast({ kind: 'ok', title: t('folder.removed', { name: p.name }) }); after?.(); } catch (e) { d.toast({ kind: 'bad', title: t('toast.saveFailed'), detail: errorText(e) }); } finally { setBusy(false); } }; return { busy, locate, remove }; } export function FolderMissing({ project }: { project: Project }) { const d = useData(); const nav = useNav(); const { busy, locate, remove } = useFolderActions(project); return ( }> {t('folder.missing')} {t('folder.missingText', { path: shortPath(project.path, d.info?.home) })} ); }