@@ -2561,18 +2561,8 @@ const SettingsForms = {
2561
2561
window . notificationsUnsavedChanges = false ;
2562
2562
this . removeUnsavedChangesWarning ( ) ;
2563
2563
2564
- // Ensure originalSettings has the same defaults used in form generation
2565
- // This prevents mismatches between form display values and change detection
2566
- const normalizedSettings = {
2567
- enable_notifications : originalSettings . enable_notifications !== undefined ? originalSettings . enable_notifications : false ,
2568
- notification_level : originalSettings . notification_level || 'warning' ,
2569
- apprise_urls : originalSettings . apprise_urls || [ ] ,
2570
- notify_on_missing : originalSettings . notify_on_missing !== undefined ? originalSettings . notify_on_missing : true ,
2571
- notify_on_upgrade : originalSettings . notify_on_upgrade !== undefined ? originalSettings . notify_on_upgrade : true ,
2572
- notification_include_instance : originalSettings . notification_include_instance !== undefined ? originalSettings . notification_include_instance : true ,
2573
- notification_include_app : originalSettings . notification_include_app !== undefined ? originalSettings . notification_include_app : true ,
2574
- ...originalSettings // Keep any other settings that might exist
2575
- } ;
2564
+ // Capture the actual form state as baseline instead of guessing defaults
2565
+ let normalizedSettings = { } ;
2576
2566
2577
2567
// Initialize button in disabled/grey state immediately
2578
2568
saveButton . disabled = true ;
@@ -2717,10 +2707,30 @@ const SettingsForms = {
2717
2707
}
2718
2708
} ) ;
2719
2709
2720
- // Initial change detection - ensure form is fully loaded before checking
2710
+ // Initial setup - capture actual form state as baseline
2721
2711
// Use a longer timeout to ensure all form elements are properly initialized
2722
2712
setTimeout ( ( ) => {
2723
- console . log ( '[SettingsForms] Initializing notifications form baseline' ) ;
2713
+ console . log ( '[SettingsForms] Capturing actual form state as notifications baseline' ) ;
2714
+
2715
+ // Capture the current form state as our baseline instead of guessing defaults
2716
+ const inputs = container . querySelectorAll ( 'input, select, textarea' ) ;
2717
+ inputs . forEach ( input => {
2718
+ if ( ! input . id || input . disabled ) return ;
2719
+
2720
+ let value ;
2721
+ if ( input . type === 'checkbox' ) {
2722
+ value = input . checked ;
2723
+ } else if ( input . type === 'number' ) {
2724
+ value = parseInt ( input . value ) || 0 ;
2725
+ } else if ( input . id === 'apprise_urls' ) {
2726
+ // Special handling for textarea - convert to array for comparison
2727
+ value = input . value . split ( '\n' ) . map ( url => url . trim ( ) ) . filter ( url => url . length > 0 ) ;
2728
+ } else {
2729
+ value = input . value . trim ( ) ;
2730
+ }
2731
+
2732
+ normalizedSettings [ input . id ] = value ;
2733
+ } ) ;
2724
2734
2725
2735
// Force button to grey state and clear any changes
2726
2736
saveButton . disabled = true ;
@@ -2731,12 +2741,9 @@ const SettingsForms = {
2731
2741
window . notificationsUnsavedChanges = false ;
2732
2742
hasChanges = false ;
2733
2743
2734
- // Enable change detection now that form is properly initialized
2744
+ // Enable change detection now that baseline is captured
2735
2745
suppressInitialDetection = false ;
2736
- console . log ( '[SettingsForms] Notifications change detection enabled - button should remain grey unless changes made' ) ;
2737
-
2738
- // Run one final change detection to confirm no changes detected
2739
- detectChanges ( ) ;
2746
+ console . log ( '[SettingsForms] Notifications baseline captured, change detection enabled' ) ;
2740
2747
} , 500 ) ;
2741
2748
} ,
2742
2749
0 commit comments