mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 03:54:17 +02:00
fix(queue): optimize printer status polling and minor cleanup
- Only poll printer status for actively printing items - Fix indentation in useQuery block - Add trailing newline to utils/date.ts
This commit is contained in:
@@ -315,11 +315,11 @@ function SortableQueueItem({
|
||||
t: (key: string, options?: Record<string, unknown>) => string;
|
||||
}) {
|
||||
const { data: status } = useQuery({
|
||||
queryKey: ['printerStatus', item.printer_id],
|
||||
queryFn: () => api.getPrinterStatus(item.printer_id!),
|
||||
refetchInterval: 30000,
|
||||
enabled: item.printer_id !== undefined && item.printer_id !== null,
|
||||
});
|
||||
queryKey: ['printerStatus', item.printer_id],
|
||||
queryFn: () => api.getPrinterStatus(item.printer_id!),
|
||||
refetchInterval: 30000,
|
||||
enabled: item.printer_id != null && printerState === 'printing',
|
||||
});
|
||||
const canReorder = hasPermission('queue:reorder');
|
||||
const {
|
||||
attributes,
|
||||
|
||||
@@ -423,4 +423,4 @@ export function formatDuration(seconds: number | null | undefined): string {
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
|
||||
return hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user