mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 11:56:01 +02:00
Fix queue badge showing on printers without matching filament (#486)
The purple queue counter badge in the printer card header used the raw unfiltered queue item count, so it appeared on ALL printers of the same model when a job was scheduled for "any [model]" — even printers without the matching filament color. The PrinterQueueWidget below it (which shows "Clear Plate & Start") already filtered by filament type + color. Apply the same filament compatibility filter (type check + color override check) to the badge count so it only shows on printers that can actually run the queued jobs.
This commit is contained in:
@@ -1672,7 +1672,27 @@ function PrinterCard({
|
||||
queryKey: ['queue', printer.id, 'pending'],
|
||||
queryFn: () => api.getQueue(printer.id, 'pending'),
|
||||
});
|
||||
const queueCount = queueItems?.length || 0;
|
||||
// Filter queue items by filament compatibility (same logic as PrinterQueueWidget)
|
||||
// so the badge only shows on printers that can actually run the queued jobs.
|
||||
const queueCount = useMemo(() => {
|
||||
if (!queueItems?.length) return 0;
|
||||
return queueItems.filter(item => {
|
||||
if (item.required_filament_types?.length && loadedFilamentTypes?.size) {
|
||||
if (!item.required_filament_types.every((t: string) => loadedFilamentTypes.has(t.toUpperCase()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (item.filament_overrides?.length && loadedFilaments?.size) {
|
||||
const hasColorMatch = item.filament_overrides.some((o: { type?: string; color?: string }) => {
|
||||
const oType = (o.type || '').toUpperCase();
|
||||
const oColor = (o.color || '').replace('#', '').toLowerCase().slice(0, 6);
|
||||
return loadedFilaments.has(`${oType}:${oColor}`);
|
||||
});
|
||||
if (!hasColorMatch) return false;
|
||||
}
|
||||
return true;
|
||||
}).length;
|
||||
}, [queueItems, loadedFilamentTypes, loadedFilaments]);
|
||||
|
||||
// Fetch currently printing queue item to show who started it (Issue #206)
|
||||
const { data: printingQueueItems } = useQuery({
|
||||
|
||||
Reference in New Issue
Block a user