mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
fix(settings): per-fact pending state on coach-memory forget
A single shared forgetOne mutation meant forgetOne.isPending disabled every per-fact forget button during one delete, so the whole list read as frozen. Track the in-flight fact id via the mutation variables so only the row being deleted disables and shows the spinner. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2763a64b83
commit
9c39afa352
1 file changed
+18
-2
@@ -251,10 +251,26 @@ export function CoachMemorySection({
|
||||
size="sm"
|
||||
data-testid="settings-coach-memory-forget"
|
||||
aria-label={t("settings.ai.coachMemory.forgetAria")}
|
||||
disabled={!isAuthenticated || forgetOne.isPending}
|
||||
// v1.11.2 — per-id pending: only the row being
|
||||
// deleted disables/spins. `forgetOne.variables` holds
|
||||
// the id passed to the in-flight `mutate()`, so a
|
||||
// single shared mutation no longer greys out every
|
||||
// other row's forget button during one delete.
|
||||
disabled={
|
||||
!isAuthenticated ||
|
||||
(forgetOne.isPending && forgetOne.variables === fact.id)
|
||||
}
|
||||
onClick={() => forgetOne.mutate(fact.id)}
|
||||
>
|
||||
<Trash2 className="size-4" aria-hidden />
|
||||
{forgetOne.isPending &&
|
||||
forgetOne.variables === fact.id ? (
|
||||
<Loader2
|
||||
className="size-4 animate-spin motion-reduce:animate-none"
|
||||
aria-hidden
|
||||
/>
|
||||
) : (
|
||||
<Trash2 className="size-4" aria-hidden />
|
||||
)}
|
||||
{t("settings.ai.coachMemory.forget")}
|
||||
</Button>
|
||||
</li>
|
||||
|
||||
Reference in new issue
Block a user