Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 1714x 1714x 1714x 1714x 1714x 125x 125x 55x 54x 1x 1x 55x 55x 1714x 1x 1x 1x 1x 1714x | import { useSolveRefresh } from "@/hooks/cache/useSolveRefresh.ts";
import { useMLTrainRefresh } from "@/hooks/cache/useMLTrainRefresh.ts";
import { useUpdateTaskCache } from "@/hooks/cache/useUpdateTaskCache.ts";
import {
useTaskCancelledSubscription,
useTaskCompletedSubscription,
useTaskUpdatedSubscription,
} from "@/hooks/notifications/notificationSubscriptions.ts";
import { StatusEnum, TaskTypeEnum } from "@/api/apiStore.gen.ts";
import { toast } from "sonner";
import { useSearchParam } from "../searchParams";
import { ContentTypes } from "../../pages/flowsheet-page/flowsheet/LeftSideBar/LeftSideBarTabDefinitions";
export function useFlowsheetSubscriptions() {
const { refreshSolveDependencies } = useSolveRefresh();
const { refreshMLTrainDependencies } = useMLTrainRefresh();
const updateTaskCache = useUpdateTaskCache();
const [, setContent] = useSearchParam("content");
useTaskCompletedSubscription((completedTask) => {
updateTaskCache(completedTask);
// Process completion for non-child tasks
if (completedTask.parent == null) {
if (completedTask.task_type == TaskTypeEnum.Solve) {
refreshSolveDependencies(completedTask.id);
} else if (completedTask.task_type == TaskTypeEnum.MlTraining) {
refreshMLTrainDependencies();
}
if (completedTask.status == StatusEnum.Completed)
toast.success(`${completedTask.task_type} completed successfully`);
else E{
Iif (completedTask.task_type == TaskTypeEnum.Solve){
setContent(ContentTypes.solverLogs); // so the user can see the logs immediately
}
toast.error(`${completedTask.task_type} failed`, {
description:
`The ${completedTask.task_type} task did not complete successfully. See the logs for more details.`,
});
}
}
});
useTaskCancelledSubscription((cancelledTask) => {
updateTaskCache(cancelledTask);
// Process completion for non-child tasks
if (cancelledTask.parent == null) {
refreshSolveDependencies(cancelledTask.id);
toast.error("Solve cancelled", {
description:
"The solve task is cancelled. See the logs for more details.",
});
}
})
useTaskUpdatedSubscription(updateTaskCache);
}
|