Files
artcraft/app/utilities.ts
T
wilandwil c266db62c8 New Inference Jobs implementation and pre-loading user media (#423)
- separating the signals and disabled the code that introduced the bug
- setup job signals properly to manage completed and active jobs
- setup myMovies signals properly to load user's list of videos
- make new hook to manage polling for job signals
- make new hook to manage background polling for user videos
- finished the logic for toggling and repeating jobs polling
- finished the logic for triggering a background poll of user movies

Co-authored-by: wil <wil@storyteller.ai>
2024-05-28 16:43:02 -04:00

32 lines
756 B
TypeScript

import { Params } from "@remix-run/react";
import { JobStatus } from "./enums";
export const kebabCase = (str: string) =>
str
.replace(/([a-z])([A-Z])/g, "$1-$2")
.replace(/[\s_]+/g, "-")
.toLowerCase();
export const getCurrentLocationWithoutParams = (
path: string,
params: Readonly<Params<string>>,
) => {
let result = path;
Object.keys(params).forEach((key) => {
result = result.replace("/" + params[key] || "", "");
});
if (result[result.length - 1] !== "/") result = result + "/";
return result;
};
export const isJobStatusTerminal = (curr: JobStatus) => {
if (
curr === JobStatus.PENDING ||
curr === JobStatus.STARTED ||
curr === JobStatus.ATTEMPT_FAILED
) {
return false;
}
return true;
};