fix: fix filter race condition and dedup filter source logic
This commit is contained in:
parent
d7cbf81808
commit
b2c42fadef
@ -137,11 +137,11 @@ export const OrchestratorPage: React.FC = () => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (sourceFilter === "all") return;
|
||||
if (isLoading || sourceFilter === "all") return;
|
||||
if (!sourcesWithJobs.includes(sourceFilter)) {
|
||||
setSourceFilter("all");
|
||||
}
|
||||
}, [sourceFilter, setSourceFilter, sourcesWithJobs]);
|
||||
}, [isLoading, sourceFilter, setSourceFilter, sourcesWithJobs]);
|
||||
|
||||
const handleManualImported = useCallback(
|
||||
async (importedJobId: string) => {
|
||||
|
||||
@ -17,7 +17,7 @@ import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
|
||||
import { sourceLabel } from "@/lib/utils";
|
||||
import type { JobSource } from "../../../shared/types";
|
||||
import { defaultSortDirection, orderedSources, sortLabels, tabs } from "./constants";
|
||||
import { defaultSortDirection, orderedFilterSources, sortLabels, tabs } from "./constants";
|
||||
import type { FilterTab, JobSort } from "./constants";
|
||||
|
||||
interface OrchestratorFiltersProps {
|
||||
@ -45,7 +45,6 @@ export const OrchestratorFilters: React.FC<OrchestratorFiltersProps> = ({
|
||||
sort,
|
||||
onSortChange,
|
||||
}) => {
|
||||
const orderedFilterSources: JobSource[] = [...orderedSources, "manual"];
|
||||
const visibleSources = orderedFilterSources.filter((source) => sourcesWithJobs.includes(source));
|
||||
|
||||
return (
|
||||
|
||||
@ -4,6 +4,7 @@ export const DEFAULT_PIPELINE_SOURCES: JobSource[] = ["gradcracker", "indeed", "
|
||||
export const PIPELINE_SOURCES_STORAGE_KEY = "jobops.pipeline.sources";
|
||||
|
||||
export const orderedSources: JobSource[] = ["gradcracker", "indeed", "linkedin", "ukvisajobs"];
|
||||
export const orderedFilterSources: JobSource[] = [...orderedSources, "manual"];
|
||||
|
||||
export const statusTokens: Record<JobStatus, { label: string; badge: string; dot: string }> = {
|
||||
discovered: {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { AppSettings, Job, JobSource } from "../../../shared/types";
|
||||
import { orderedSources } from "./constants";
|
||||
import { orderedFilterSources, orderedSources } from "./constants";
|
||||
import type { FilterTab, JobSort } from "./constants";
|
||||
|
||||
const dateValue = (value: string | null) => {
|
||||
@ -89,14 +89,12 @@ export const getJobCounts = (jobs: Job[]): Record<FilterTab, number> => {
|
||||
return byTab;
|
||||
};
|
||||
|
||||
const orderedSourceFilters: JobSource[] = [...orderedSources, "manual"];
|
||||
|
||||
export const getSourcesWithJobs = (jobs: Job[]): JobSource[] => {
|
||||
const seen = new Set<JobSource>();
|
||||
for (const job of jobs) {
|
||||
seen.add(job.source);
|
||||
}
|
||||
return orderedSourceFilters.filter((source) => seen.has(source));
|
||||
return orderedFilterSources.filter((source) => seen.has(source));
|
||||
};
|
||||
|
||||
export const getEnabledSources = (settings: AppSettings | null): JobSource[] => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user