mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-18 05:02:15 +03:00
fix(cli): refresh runtime detection accurately (#7552)
Co-authored-by: nguyenha935 <208228297+nguyenha935@users.noreply.github.com>
This commit is contained in:
@@ -15,11 +15,12 @@ export function useToolBatchStatuses(): UseToolBatchStatusesResult {
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const fetchStatuses = useCallback(async () => {
|
||||
const fetchStatuses = useCallback(async (forceRefresh = false) => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const res = await fetch("/api/cli-tools/all-statuses");
|
||||
const url = `/api/cli-tools/all-statuses${forceRefresh ? "?refresh=true" : ""}`;
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => String(res.status));
|
||||
setError(`HTTP ${res.status}: ${text.slice(0, 200)}`);
|
||||
@@ -37,6 +38,10 @@ export function useToolBatchStatuses(): UseToolBatchStatusesResult {
|
||||
}
|
||||
}, []);
|
||||
|
||||
const refetch = useCallback(() => {
|
||||
void fetchStatuses(true);
|
||||
}, [fetchStatuses]);
|
||||
|
||||
useEffect(() => {
|
||||
void fetchStatuses();
|
||||
|
||||
@@ -50,5 +55,5 @@ export function useToolBatchStatuses(): UseToolBatchStatusesResult {
|
||||
};
|
||||
}, [fetchStatuses]);
|
||||
|
||||
return { statuses, loading, error, refetch: fetchStatuses };
|
||||
return { statuses, loading, error, refetch };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user