refactor: extract shared utility functions to eliminate duplication
This commit is contained in:
parent
b720013a08
commit
1037ff164d
10 changed files with 85 additions and 110 deletions
|
|
@ -3,6 +3,7 @@ import type { AuthUser } from '@/auth/types';
|
|||
import type { TaskState, TaskStatusResponse, WSMessage } from '@/types';
|
||||
import { WS_TASKS_PATH } from '@/constants';
|
||||
import { fetchTasksForUser, fetchTaskStatus } from '@/services';
|
||||
import { isTerminalStatus } from '@/utils/taskUtils';
|
||||
|
||||
const KEEPALIVE_MS = 30_000;
|
||||
const MAX_RECONNECT_DELAY_MS = 30_000;
|
||||
|
|
@ -14,10 +15,6 @@ function wsUrl(token: string): string {
|
|||
return `${proto}://${window.location.host}${WS_TASKS_PATH}?token=${encodeURIComponent(token)}`;
|
||||
}
|
||||
|
||||
function isTerminalStatus(status: string): boolean {
|
||||
return status === 'SUCCESS' || status === 'FAILURE' || status === 'REVOKED';
|
||||
}
|
||||
|
||||
/** Convert an HTTP TaskStatusResponse into the canonical TaskState shape. */
|
||||
function httpResponseToTaskState(resp: TaskStatusResponse): TaskState {
|
||||
const state: TaskState = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue