Commit
Fix history action failures
commit
4378dd7
1 changed file with +9 and −7
modified src/components/history-list.tsx +9 −7
| @@ -24,14 +24,16 @@export function HistoryList({ debates }: { debates: DebateSummary[] }) { | ||
| 24 | 24 | |
| 25 | 25 | const remove = async (id: string) => { |
| 26 | 26 | setDeleting(id); |
| 27 | - const res = await fetch(`/api/debates/${id}`, { method: 'DELETE' }); | |
| 28 | - if (res.ok) { | |
| 27 | + try { | |
| 28 | + const res = await fetch(`/api/debates/${id}`, { method: 'DELETE' }); | |
| 29 | + if (!res.ok) throw new Error('Delete request failed'); | |
| 29 | 30 | toast.success('Question deleted'); |
| 30 | 31 | router.refresh(); |
| 31 | - } else { | |
| 32 | + } catch { | |
| 32 | 33 | toast.error('Could not delete'); |
| 34 | + } finally { | |
| 35 | + setDeleting(null); | |
| 33 | 36 | } |
| 34 | - setDeleting(null); | |
| 35 | 37 | }; |
| 36 | 38 | |
| 37 | 39 | return ( |
| @@ -82,7 +84,7 @@export function HistoryList({ debates }: { debates: DebateSummary[] }) { | ||
| 82 | 84 | <Button |
| 83 | 85 | variant="ghost" |
| 84 | 86 | size="icon" |
| 85 | - className="opacity-0 transition-opacity group-hover:opacity-100" | |
| 87 | + className="transition-opacity sm:opacity-0 sm:group-focus-within:opacity-100 sm:group-hover:opacity-100" | |
| 86 | 88 | asChild |
| 87 | 89 | aria-label="Ask this question again with the same models" |
| 88 | 90 | > |
| @@ -93,8 +95,8 @@export function HistoryList({ debates }: { debates: DebateSummary[] }) { | ||
| 93 | 95 | <Button |
| 94 | 96 | variant="ghost" |
| 95 | 97 | size="icon" |
| 96 | - className="opacity-0 transition-opacity group-hover:opacity-100" | |
| 97 | - disabled={deleting === d.id} | |
| 98 | + className="transition-opacity sm:opacity-0 sm:group-focus-within:opacity-100 sm:group-hover:opacity-100" | |
| 99 | + disabled={deleting !== null} | |
| 98 | 100 | onClick={() => remove(d.id)} |
| 99 | 101 | aria-label="Delete question" |
| 100 | 102 | > |