MCPcopy
hub / github.com/CookSleep/gpt_image_playground / commitSettings

Function commitSettings

src/components/SettingsModal.tsx:542–572  ·  view source on GitHub ↗
(nextDraft: AppSettings)

Source from the content-addressed store, hash-verified

540 }
541
542 const commitSettings = (nextDraft: AppSettings) => {
543 const normalizedProfiles = nextDraft.profiles.map((profile) => {
544 const nextApiProxy = isProfileApiProxyEligible(nextDraft, profile) && apiProxyAvailable ? (apiProxyLocked || profile.apiProxy) : false
545 const shouldKeepEmptyBaseUrl = profile.provider !== 'fal' && nextApiProxy && !profile.baseUrl.trim()
546 const normalizedBaseUrl = profile.provider === 'fal'
547 ? profile.baseUrl.trim().replace(/\/+$/, '') || DEFAULT_FAL_BASE_URL
548 : shouldKeepEmptyBaseUrl ? '' : normalizeBaseUrl(profile.baseUrl.trim() || DEFAULT_SETTINGS.baseUrl)
549 const defaultModel = profile.provider === 'fal' ? DEFAULT_FAL_MODEL : getDefaultModelForMode(profile.apiMode)
550 return {
551 ...profile,
552 name: profile.name.trim() || (profile.id === DEFAULT_OPENAI_PROFILE_ID ? '默认' : '新配置'),
553 baseUrl: normalizedBaseUrl,
554 model: profile.model.trim() || defaultModel,
555 timeout: Number(profile.timeout) || DEFAULT_SETTINGS.timeout,
556 apiProxy: nextApiProxy,
557 codexCli: profile.provider === 'openai' ? profile.codexCli : false,
558 streamImages: profile.provider === 'openai' ? profile.streamImages : false,
559 streamPartialImages: profile.provider === 'openai' ? normalizeStreamPartialImages(profile.streamPartialImages) : DEFAULT_STREAM_PARTIAL_IMAGES,
560 }
561 })
562 const fallbackProfile = createDefaultOpenAIProfile({ id: newId('openai') })
563 const normalizedDraft = normalizeSettings({
564 ...nextDraft,
565 profiles: normalizedProfiles.length ? normalizedProfiles : [fallbackProfile],
566 activeProfileId: normalizedProfiles.some((profile) => profile.id === nextDraft.activeProfileId)
567 ? nextDraft.activeProfileId
568 : (normalizedProfiles[0]?.id ?? fallbackProfile.id),
569 })
570 setDraft(normalizedDraft)
571 setSettings(normalizedDraft)
572 }
573
574 const setZipDownloadRouteEnabled = (route: ZipDownloadRoute, enabled: boolean) => {
575 const nextRoutes = enabled

Callers 15

updateActiveProfileFunction · 0.85
commitActiveProfilePatchFunction · 0.85
handleCloseFunction · 0.85
SettingsModalFunction · 0.85
createNewProfileFunction · 0.85
updateAgentApiConfigModeFunction · 0.85
duplicateActiveProfileFunction · 0.85
switchProfileFunction · 0.85
moveProfileToDropTargetFunction · 0.85
deleteProfileFunction · 0.85

Calls 7

normalizeSettingsFunction · 0.90
normalizeBaseUrlFunction · 0.85
getDefaultModelForModeFunction · 0.85
newIdFunction · 0.85

Tested by

no test coverage detected