address comments

This commit is contained in:
DaKheera47 2026-01-23 12:08:17 +00:00
parent a268bfdd59
commit 3f37029dfd
3 changed files with 26 additions and 9 deletions

View File

@ -168,8 +168,20 @@ export async function importManualJob(input: {
}
// Settings & Profile API
let settingsPromise: Promise<AppSettings> | null = null;
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[]> {
@ -260,9 +272,10 @@ export async function getRxResumes(): Promise<{ id: string; name: string }[]> {
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[] }>(
`/settings/rx-resumes/${encodeURIComponent(resumeId)}/projects`
`/settings/rx-resumes/${encodeURIComponent(resumeId)}/projects`,
{ signal }
);
return data.projects;
}

View File

@ -165,13 +165,13 @@ export const OnboardingGate: React.FC = () => {
const message = reason instanceof Error ? reason.message : "Validation checks failed"
toast.error(message)
}
}, [settings, validateOpenrouter, validateRxresume])
}, [settings, validateOpenrouter, validateRxresume, validateBaseResume])
useEffect(() => {
if (!settings || settingsLoading) return
if (openrouterValidation.checked || rxresumeValidation.checked) return
if (openrouterValidation.checked || rxresumeValidation.checked || baseResumeValidation.checked) return
void runAllValidations()
}, [settings, settingsLoading, openrouterValidation.checked, rxresumeValidation.checked, runAllValidations])
}, [settings, settingsLoading, openrouterValidation.checked, rxresumeValidation.checked, baseResumeValidation.checked, runAllValidations])
const handleRefresh = async () => {
const results = await Promise.allSettled([refreshSettings(), runAllValidations()])

View File

@ -156,7 +156,7 @@ const normalizeResumeProjectsForCatalog = (
const lockedProjectIds = base.lockedProjectIds.filter((id) => allowed.has(id))
const lockedSet = new Set(lockedProjectIds)
const aiSelectableProjectIds = (base.aiSelectableProjectIds.length
const aiSelectableProjectIds = (current
? base.aiSelectableProjectIds
: catalog.map((project) => project.id)
)
@ -320,21 +320,24 @@ export const SettingsPage: React.FC = () => {
useEffect(() => {
let isMounted = true
const controller = new AbortController()
if (!rxResumeBaseResumeIdDraft) {
setRxResumeProjectsOverride(null)
return () => {
isMounted = false
controller.abort()
}
}
if (!hasRxResumeAccess) return () => {
isMounted = false
controller.abort()
}
setIsFetchingRxResumeProjects(true)
api
.getRxResumeProjects(rxResumeBaseResumeIdDraft)
.getRxResumeProjects(rxResumeBaseResumeIdDraft, controller.signal)
.then((projects) => {
if (!isMounted) return
setRxResumeProjectsOverride(projects)
@ -347,7 +350,7 @@ export const SettingsPage: React.FC = () => {
}
})
.catch((error) => {
if (!isMounted) return
if (!isMounted || error.name === 'AbortError') return
const message = error instanceof Error ? error.message : "Failed to load RxResume projects"
toast.error(message)
setRxResumeProjectsOverride(null)
@ -359,6 +362,7 @@ export const SettingsPage: React.FC = () => {
return () => {
isMounted = false
controller.abort()
}
}, [rxResumeBaseResumeIdDraft, hasRxResumeAccess, getValues, setValue])