address comments
This commit is contained in:
parent
a268bfdd59
commit
3f37029dfd
@ -168,8 +168,20 @@ export async function importManualJob(input: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Settings & Profile API
|
// Settings & Profile API
|
||||||
|
let settingsPromise: Promise<AppSettings> | null = null;
|
||||||
|
|
||||||
export async function getSettings(): Promise<AppSettings> {
|
export async function getSettings(): Promise<AppSettings> {
|
||||||
return fetchApi<AppSettings>('/settings');
|
if (settingsPromise) return settingsPromise;
|
||||||
|
|
||||||
|
settingsPromise = fetchApi<AppSettings>('/settings').finally(() => {
|
||||||
|
// Clear the promise after a short delay to allow subsequent fresh fetches
|
||||||
|
// but coalesce simultaneous requests.
|
||||||
|
setTimeout(() => {
|
||||||
|
settingsPromise = null;
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
|
||||||
|
return settingsPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProfileProjects(): Promise<ResumeProjectCatalogItem[]> {
|
export async function getProfileProjects(): Promise<ResumeProjectCatalogItem[]> {
|
||||||
@ -260,9 +272,10 @@ export async function getRxResumes(): Promise<{ id: string; name: string }[]> {
|
|||||||
return data.resumes;
|
return data.resumes;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getRxResumeProjects(resumeId: string): Promise<ResumeProjectCatalogItem[]> {
|
export async function getRxResumeProjects(resumeId: string, signal?: AbortSignal): Promise<ResumeProjectCatalogItem[]> {
|
||||||
const data = await fetchApi<{ projects: ResumeProjectCatalogItem[] }>(
|
const data = await fetchApi<{ projects: ResumeProjectCatalogItem[] }>(
|
||||||
`/settings/rx-resumes/${encodeURIComponent(resumeId)}/projects`
|
`/settings/rx-resumes/${encodeURIComponent(resumeId)}/projects`,
|
||||||
|
{ signal }
|
||||||
);
|
);
|
||||||
return data.projects;
|
return data.projects;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -165,13 +165,13 @@ export const OnboardingGate: React.FC = () => {
|
|||||||
const message = reason instanceof Error ? reason.message : "Validation checks failed"
|
const message = reason instanceof Error ? reason.message : "Validation checks failed"
|
||||||
toast.error(message)
|
toast.error(message)
|
||||||
}
|
}
|
||||||
}, [settings, validateOpenrouter, validateRxresume])
|
}, [settings, validateOpenrouter, validateRxresume, validateBaseResume])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!settings || settingsLoading) return
|
if (!settings || settingsLoading) return
|
||||||
if (openrouterValidation.checked || rxresumeValidation.checked) return
|
if (openrouterValidation.checked || rxresumeValidation.checked || baseResumeValidation.checked) return
|
||||||
void runAllValidations()
|
void runAllValidations()
|
||||||
}, [settings, settingsLoading, openrouterValidation.checked, rxresumeValidation.checked, runAllValidations])
|
}, [settings, settingsLoading, openrouterValidation.checked, rxresumeValidation.checked, baseResumeValidation.checked, runAllValidations])
|
||||||
|
|
||||||
const handleRefresh = async () => {
|
const handleRefresh = async () => {
|
||||||
const results = await Promise.allSettled([refreshSettings(), runAllValidations()])
|
const results = await Promise.allSettled([refreshSettings(), runAllValidations()])
|
||||||
|
|||||||
@ -156,7 +156,7 @@ const normalizeResumeProjectsForCatalog = (
|
|||||||
|
|
||||||
const lockedProjectIds = base.lockedProjectIds.filter((id) => allowed.has(id))
|
const lockedProjectIds = base.lockedProjectIds.filter((id) => allowed.has(id))
|
||||||
const lockedSet = new Set(lockedProjectIds)
|
const lockedSet = new Set(lockedProjectIds)
|
||||||
const aiSelectableProjectIds = (base.aiSelectableProjectIds.length
|
const aiSelectableProjectIds = (current
|
||||||
? base.aiSelectableProjectIds
|
? base.aiSelectableProjectIds
|
||||||
: catalog.map((project) => project.id)
|
: catalog.map((project) => project.id)
|
||||||
)
|
)
|
||||||
@ -320,21 +320,24 @@ export const SettingsPage: React.FC = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let isMounted = true
|
let isMounted = true
|
||||||
|
const controller = new AbortController()
|
||||||
|
|
||||||
if (!rxResumeBaseResumeIdDraft) {
|
if (!rxResumeBaseResumeIdDraft) {
|
||||||
setRxResumeProjectsOverride(null)
|
setRxResumeProjectsOverride(null)
|
||||||
return () => {
|
return () => {
|
||||||
isMounted = false
|
isMounted = false
|
||||||
|
controller.abort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasRxResumeAccess) return () => {
|
if (!hasRxResumeAccess) return () => {
|
||||||
isMounted = false
|
isMounted = false
|
||||||
|
controller.abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsFetchingRxResumeProjects(true)
|
setIsFetchingRxResumeProjects(true)
|
||||||
api
|
api
|
||||||
.getRxResumeProjects(rxResumeBaseResumeIdDraft)
|
.getRxResumeProjects(rxResumeBaseResumeIdDraft, controller.signal)
|
||||||
.then((projects) => {
|
.then((projects) => {
|
||||||
if (!isMounted) return
|
if (!isMounted) return
|
||||||
setRxResumeProjectsOverride(projects)
|
setRxResumeProjectsOverride(projects)
|
||||||
@ -347,7 +350,7 @@ export const SettingsPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (!isMounted) return
|
if (!isMounted || error.name === 'AbortError') return
|
||||||
const message = error instanceof Error ? error.message : "Failed to load RxResume projects"
|
const message = error instanceof Error ? error.message : "Failed to load RxResume projects"
|
||||||
toast.error(message)
|
toast.error(message)
|
||||||
setRxResumeProjectsOverride(null)
|
setRxResumeProjectsOverride(null)
|
||||||
@ -359,6 +362,7 @@ export const SettingsPage: React.FC = () => {
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
isMounted = false
|
isMounted = false
|
||||||
|
controller.abort()
|
||||||
}
|
}
|
||||||
}, [rxResumeBaseResumeIdDraft, hasRxResumeAccess, getValues, setValue])
|
}, [rxResumeBaseResumeIdDraft, hasRxResumeAccess, getValues, setValue])
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user