Fix plate-clear button unclickable after second print (#912)

The clearPlateMutation.isSuccess state from React Query persisted after
  the first successful plate clear. When the next print finished, the
  stale isSuccess rendered the static confirmation instead of the clickable
  button. Reset mutation state when printer leaves FINISH/FAILED.
This commit is contained in:
maziggy
2026-04-09 08:00:58 +02:00
parent 100610a1ef
commit 502959a0df
4 changed files with 14 additions and 2 deletions
@@ -1,3 +1,4 @@
import { useEffect } from 'react';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { Clock, Calendar, ChevronRight, Loader2, CircleCheck } from 'lucide-react';
import { Link } from 'react-router-dom';
@@ -41,6 +42,14 @@ export function PrinterQueueWidget({ printerId, printerModel, printerState, plat
},
});
// Reset mutation state when printer starts a new print cycle so the button
// is clickable again when the next print finishes (fixes #912)
useEffect(() => {
if (printerState !== 'FINISH' && printerState !== 'FAILED') {
clearPlateMutation.reset();
}
}, [printerState]);
// Filter queue to items this printer can actually print (filament type + color check)
const compatibleQueue = queue ? filterCompatibleQueueItems(queue, loadedFilamentTypes, loadedFilaments) : undefined;