Live worker counts and an e621 request-history dropdown
- Status polling drops from 30s to 5s, and download start/finish/cancel invalidates it immediately, so the footer's Active Workers reflects running download tasks in near real time - The e621 time in the status pill is now a button: it opens a dropdown with the session's request history (clock time, endpoint, duration, colour-coded) plus totals; closes on outside click or Escape - Metrics store keeps the last 50 requests
This commit is contained in:
@@ -129,7 +129,10 @@ export function OnlineDetail({ postId }: { postId: number }) {
|
||||
post: target,
|
||||
},
|
||||
}),
|
||||
onSuccess: (task) => setDownloadTaskId(task.task_id),
|
||||
onSuccess: (task) => {
|
||||
setDownloadTaskId(task.task_id);
|
||||
void queryClient.invalidateQueries({ queryKey: ["status"] });
|
||||
},
|
||||
});
|
||||
|
||||
const taskQuery = useQuery({
|
||||
@@ -143,20 +146,31 @@ export function OnlineDetail({ postId }: { postId: number }) {
|
||||
},
|
||||
});
|
||||
const downloadTask = taskQuery.data;
|
||||
const downloadStatus = downloadTask?.status;
|
||||
const downloadActive =
|
||||
downloadTask?.status === "pending" || downloadTask?.status === "downloading";
|
||||
downloadStatus === "pending" || downloadStatus === "downloading";
|
||||
|
||||
useEffect(() => {
|
||||
if (downloadTask?.status === "complete") {
|
||||
if (!downloadStatus) return;
|
||||
if (
|
||||
downloadStatus === "complete" ||
|
||||
downloadStatus === "error" ||
|
||||
downloadStatus === "cancelled"
|
||||
) {
|
||||
void queryClient.invalidateQueries({ queryKey: ["status"] });
|
||||
}
|
||||
if (downloadStatus === "complete") {
|
||||
void queryClient.invalidateQueries({ queryKey: ["library-lookup"] });
|
||||
void queryClient.invalidateQueries({ queryKey: ["files"] });
|
||||
}
|
||||
}, [downloadTask?.status, queryClient]);
|
||||
}, [downloadStatus, queryClient]);
|
||||
|
||||
function cancelDownload() {
|
||||
if (!downloadTaskId) return;
|
||||
void api(`/api/online/downloads/${downloadTaskId}/cancel/`, {
|
||||
method: "POST",
|
||||
}).then(() => {
|
||||
void queryClient.invalidateQueries({ queryKey: ["status"] });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user