mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-07 07:53:33 +00:00
* prototype * `.normalise` helper + only `String` keys * implement it for 'search.paths' * redux devtools * fix * refactor backend * wip: upgrade to rspc fork * mega cursed * Upgrade Specta-related stuff * Upgrade Typescript * Cache debug page * bruh * Fix optimistic library setting * Cache clearing * better timeout * Fix tags page * bit of cleanup --------- Co-authored-by: Brendan Allan <brendonovich@outlook.com>
29 lines
760 B
TypeScript
29 lines
760 B
TypeScript
import { useLibraryQuery } from '@sd/client';
|
|
|
|
/*
|
|
This is a hook to check if a location is indexing and completed_task_count is 0.
|
|
We use this to display a loading indicator in the location page.
|
|
*/
|
|
|
|
export const useIsLocationIndexing = (locationId: number): boolean => {
|
|
const { data: jobGroups } = useLibraryQuery(['jobs.reports'], {
|
|
enabled: locationId != null,
|
|
refetchOnWindowFocus: false
|
|
});
|
|
|
|
const isLocationIndexing =
|
|
jobGroups?.some((group) =>
|
|
group.jobs.some((job) => {
|
|
if (
|
|
job.name === 'indexer' &&
|
|
(job.metadata as any)?.location.id === locationId &&
|
|
(job.status === 'Running' || job.status === 'Queued')
|
|
) {
|
|
return job.completed_task_count === 0;
|
|
}
|
|
})
|
|
) || false;
|
|
|
|
return isLocationIndexing;
|
|
};
|