mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 17:38:10 +00:00
- 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>
32 lines
756 B
TypeScript
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;
|
|
};
|