mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 06:59:17 -04:00
* d * wip * Nit: margin and padding tweak * UI design tweaks * Update Job.tsx * Improve UI * [WIP] - Refactor job manager * remove invalidate explorer event on thumb generation. the event above performs atomic updates on the front end when new thumbnails are generated, now just need to make that work * prettier formatting + removed unused imports * UI tweaks * progress bar width adjustment * tweaks * fix em * fix thumbnail generation * fix progress bar * fix time --------- Co-authored-by: Jamie Pine <ijamespine@me.com> Co-authored-by: Brendan Allan <brendonovich@outlook.com> Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
26 lines
637 B
TypeScript
26 lines
637 B
TypeScript
import { useMemo } from 'react';
|
|
import { JobReport } from '@sd/client';
|
|
|
|
export interface IJobGroup extends JobReport {
|
|
childJobs: JobReport[];
|
|
runningJobs: JobReport[];
|
|
}
|
|
|
|
export function useGroupedJobs(jobs: JobReport[] = [], runningJobs: JobReport[] = []) {
|
|
return useMemo(() => {
|
|
return jobs.reduce((arr, job) => {
|
|
const childJobs = jobs.filter((j) => j.parent_id === job.id);
|
|
|
|
if (!jobs.some((j) => j.id === job.parent_id)) {
|
|
arr.push({
|
|
...job,
|
|
childJobs,
|
|
runningJobs: runningJobs.filter((j) => j.parent_id === job.id)
|
|
});
|
|
}
|
|
|
|
return arr;
|
|
}, [] as IJobGroup[]);
|
|
}, [jobs, runningJobs]);
|
|
}
|