@@ -97,9 +97,9 @@ const Config = function () {
9797 api_base : ( value ) =>
9898 value . length > 0 ? null : "Please enter api base" ,
9999 cumstom_api_base : ( value , values ) =>
100- values . providers . devchat . api_base === "custom" && value . length > 0
101- ? null
102- : "Please enter custom api base" ,
100+ values . providers . devchat . api_base === "custom" && value . length <= 0
101+ ? "Please enter custom api base"
102+ : null ,
103103 } ,
104104 } ,
105105 } ,
@@ -127,16 +127,6 @@ const Config = function () {
127127 useEffect ( ( ) => {
128128 if ( router . currentRoute !== "config" ) return ;
129129 const cloneConfig = cloneDeep ( config . config ) ;
130- if (
131- cloneConfig ?. providers ?. devchat ?. api_base !== apiSelection [ 0 ] . value ||
132- cloneConfig ?. providers ?. devchat ?. api_base !== apiSelection [ 1 ] . value
133- ) {
134- cloneConfig . providers . devchat . api_base = "custom" ;
135- }
136- console . log (
137- "cloneConfig.providers.devchat.api_base: " ,
138- cloneConfig . providers . devchat . api_base
139- ) ;
140130 form . setValues ( cloneConfig ) ;
141131 if ( config . settle && loading ) {
142132 setTimeout ( ( ) => {
@@ -149,12 +139,15 @@ const Config = function () {
149139 const onSave = ( values ) => {
150140 config . updateSettle ( false ) ;
151141 startLoading ( ) ;
152- const writeConfig = cloneDeep ( self . config ) ;
153- if ( writeConfig . providers . devchat . cumstom_api_base ) {
142+ const writeConfig = cloneDeep ( values ) ;
143+ if (
144+ writeConfig . providers . devchat . api_base === "custom" &&
145+ writeConfig . providers . devchat . cumstom_api_base
146+ ) {
154147 writeConfig . providers . devchat . api_base =
155148 writeConfig . providers . devchat . cumstom_api_base ;
156- delete writeConfig . providers . devchat . cumstom_api_base ;
157149 }
150+ delete writeConfig . providers . devchat . cumstom_api_base ;
158151 MessageUtil . sendMessage ( {
159152 command : "writeConfig" ,
160153 value : writeConfig ,
0 commit comments