Spaces:
Running
Running
File size: 869 Bytes
fc69895 |
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 |
export type BackgroundGeneration = {
id: string;
startedAt: number;
};
export const backgroundGenerationEntries = $state<BackgroundGeneration[]>([]);
export function addBackgroundGeneration(entry: BackgroundGeneration) {
const index = backgroundGenerationEntries.findIndex(({ id }) => id === entry.id);
if (index === -1) {
backgroundGenerationEntries.push(entry);
return;
}
backgroundGenerationEntries[index] = entry;
}
export function removeBackgroundGeneration(id: string) {
const index = backgroundGenerationEntries.findIndex((entry) => entry.id === id);
if (index === -1) return;
backgroundGenerationEntries.splice(index, 1);
}
export function clearBackgroundGenerations() {
backgroundGenerationEntries.length = 0;
}
export function hasBackgroundGeneration(id: string) {
return backgroundGenerationEntries.some((entry) => entry.id === id);
}
|