Skip to content

Commit

Permalink
refac(invoke-wpfinstall.ps1): remove null assignments and simplify ta…
Browse files Browse the repository at this point in the history
…skbaritem invocation
  • Loading branch information
momcilovicluka committed Sep 22, 2024
1 parent 662139c commit dba0087
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions functions/public/Invoke-WPFInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ function Invoke-WPFInstall {
$ChocoPreference = $($sync.WPFpreferChocolatey.IsChecked)
$installHandle = Invoke-WPFRunspace -ParameterList @(("PackagesToInstall", $PackagesToInstall),("ChocoPreference", $ChocoPreference)) -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToInstall, $ChocoPreference, $DebugPreference)
if ($PackagesToInstall.count -eq 1) {
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
} else {
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
}

$taskbarItemState = if ($PackagesToInstall.Count -eq 1) { "Indeterminate" } else { "Normal" }
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state $taskbarItemState -value 0.01 -overlay "logo" })

$packagesWinget, $packagesChoco = {
$packagesWinget = [System.Collections.ArrayList]::new()
$packagesChoco = [System.Collections.ArrayList]::new()
Expand All @@ -37,7 +36,7 @@ function Invoke-WPFInstall {
$packagesWinget.add($package.winget)
Write-Host "Queueing $($package.winget) for Winget install"
} else {
$null = $packagesChoco.add($package.choco)
$packagesChoco.add($package.choco)
Write-Host "Queueing $($package.choco) for Chocolatey install"
}
}
Expand All @@ -46,7 +45,7 @@ function Invoke-WPFInstall {
$packagesChoco.add($package.choco)
Write-Host "Queueing $($package.choco) for Chocolatey install"
} else {
$null = $packagesWinget.add($($package.winget))
$packagesWinget.add($($package.winget))
Write-Host "Queueing $($package.winget) for Winget install"
}
}
Expand Down

0 comments on commit dba0087

Please sign in to comment.