From c946e56a41d817a9e79815725f5e0cc59e1cf338 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Thu, 19 Jun 2025 18:12:06 -0700 Subject: [PATCH] Refactors CU checkbox initialization logic Moves the initial state logic for the "Latest CU" and "Preview CU" checkboxes from the main UI script to the core initialization module. This change centralizes UI default settings into the `Initialize-UIDefaults` function, improving code organization and maintainability. --- FFUDevelopment/BuildFFUVM_UI.ps1 | 6 ------ FFUDevelopment/FFUUI.Core/FFUUI.Core.Initialize.psm1 | 5 ++++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/FFUDevelopment/BuildFFUVM_UI.ps1 b/FFUDevelopment/BuildFFUVM_UI.ps1 index 70e3758..d8eb6cb 100644 --- a/FFUDevelopment/BuildFFUVM_UI.ps1 +++ b/FFUDevelopment/BuildFFUVM_UI.ps1 @@ -135,12 +135,6 @@ $window.Add_Loaded({ Register-EventHandlers -State $script:uiState - # CU interplay (Keep existing logic) - # Set initial state based on defaults - $script:uiState.Controls.chkPreviewCU.IsEnabled = -not $script:uiState.Controls.chkLatestCU.IsChecked - $script:uiState.Controls.chkLatestCU.IsEnabled = -not $script:uiState.Controls.chkPreviewCU.IsChecked - - # APPLICATIONS tab UI logic (Keep existing logic) $script:uiState.Controls.chkInstallWingetApps.Visibility = if ($script:uiState.Controls.chkInstallApps.IsChecked) { 'Visible' } else { 'Collapsed' } $script:uiState.Controls.applicationPathPanel.Visibility = if ($script:uiState.Controls.chkInstallApps.IsChecked) { 'Visible' } else { 'Collapsed' } diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Initialize.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Initialize.psm1 index 0bdab62..24c9b5d 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Initialize.psm1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Initialize.psm1 @@ -216,6 +216,9 @@ function Initialize-UIDefaults { $State.Controls.chkUpdateLatestMSRT.IsChecked = $State.Defaults.generalDefaults.UpdateLatestMSRT $State.Controls.chkUpdateLatestMicrocode.IsChecked = $State.Defaults.generalDefaults.UpdateLatestMicrocode $State.Controls.chkUpdatePreviewCU.IsChecked = $State.Defaults.generalDefaults.UpdatePreviewCU + # Set initial state for CU checkbox interplay + $State.Controls.chkPreviewCU.IsEnabled = -not $State.Controls.chkLatestCU.IsChecked + $State.Controls.chkLatestCU.IsEnabled = -not $State.Controls.chkPreviewCU.IsChecked # Applications tab defaults from General Defaults $State.Controls.chkInstallApps.IsChecked = $State.Defaults.generalDefaults.InstallApps @@ -249,7 +252,7 @@ function Initialize-UIDefaults { $State.Controls.cmbMake.SelectedIndex = 0 } Update-DriverDownloadPanelVisibility -State $State - + # Set initial state for driver checkbox interplay Update-DriverCheckboxStates -State $State