@@ -187,8 +187,7 @@ <h3 class="font-bold text-lg">⚠️ Device Reset Required</h3>
187187
188188 // Update save button state
189189 function updateSaveButtonState ( ) {
190- const hasModifications = Object . values ( modifiedFields ) . some ( modified => modified ) ;
191- saveAllButton . disabled = ! hasModifications ;
190+ // Save button is always enabled when connected
192191 }
193192
194193 // display message
@@ -335,6 +334,7 @@ <h3 class="font-bold text-lg">⚠️ Device Reset Required</h3>
335334 // Enable all controls
336335 function enableControls ( ) {
337336 loadAllButton . disabled = false ;
337+ saveAllButton . disabled = false ;
338338 ssidInput . disabled = false ;
339339 passInput . disabled = false ;
340340 serverUrlInput . disabled = false ;
@@ -421,23 +421,33 @@ <h3 class="font-bold text-lg">⚠️ Device Reset Required</h3>
421421
422422 try {
423423 let savedCount = 0 ;
424+ const hasModifications = Object . values ( modifiedFields ) . some ( modified => modified ) ;
424425
425- if ( modifiedFields . ssid ) {
426+ // If no modifications, send all three parameters
427+ if ( ! hasModifications ) {
426428 await writeCharacteristic ( SSID_ID , ssidInput . value ) ;
427- clearFieldModification ( 'ssid' , ssidTitle ) ;
428- savedCount ++ ;
429- }
430-
431- if ( modifiedFields . pass ) {
432429 await writeCharacteristic ( PASS_ID , passInput . value ) ;
433- clearFieldModification ( 'pass' , passTitle ) ;
434- savedCount ++ ;
435- }
436-
437- if ( modifiedFields . url ) {
438430 await writeCharacteristic ( SERVER_URL_ID , serverUrlInput . value ) ;
439- clearFieldModification ( 'url' , urlTitle ) ;
440- savedCount ++ ;
431+ savedCount = 3 ;
432+ } else {
433+ // If there are modifications, only send modified fields
434+ if ( modifiedFields . ssid ) {
435+ await writeCharacteristic ( SSID_ID , ssidInput . value ) ;
436+ clearFieldModification ( 'ssid' , ssidTitle ) ;
437+ savedCount ++ ;
438+ }
439+
440+ if ( modifiedFields . pass ) {
441+ await writeCharacteristic ( PASS_ID , passInput . value ) ;
442+ clearFieldModification ( 'pass' , passTitle ) ;
443+ savedCount ++ ;
444+ }
445+
446+ if ( modifiedFields . url ) {
447+ await writeCharacteristic ( SERVER_URL_ID , serverUrlInput . value ) ;
448+ clearFieldModification ( 'url' , urlTitle ) ;
449+ savedCount ++ ;
450+ }
441451 }
442452
443453 showNotification ( 'Success' , `Saved ${ savedCount } changes` ) ;
@@ -458,7 +468,7 @@ <h3 class="font-bold text-lg">⚠️ Device Reset Required</h3>
458468 console . error ( 'Save modifications failed:' , error ) ;
459469 showNotification ( 'Error' , 'Save modifications failed' , true ) ;
460470 } finally {
461- saveAllButton . disabled = true ;
471+ saveAllButton . disabled = false ;
462472 saveAllButton . textContent = '💾 Save Changes' ;
463473 }
464474 }
0 commit comments