mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-04-05 22:28:31 +00:00
Fix import/export functionality (#4131)
* fix: cast selections to string to prevent PSCustomObject type issues * fix(presets): clear existing selections before importing to replace state instead of merging * refactor(impex): warn user when exporting empty selections or importing empty config
This commit is contained in:
@@ -14,7 +14,9 @@ function Update-WinUtilSelections {
|
||||
|
||||
Write-Debug "JSON to import: $($flatJson)"
|
||||
|
||||
foreach ($cbkey in $flatJson) {
|
||||
foreach ($item in $flatJson) {
|
||||
# Ensure each item is treated as a string to handle PSCustomObject from JSON deserialization
|
||||
$cbkey = [string]$item
|
||||
$group = if ($cbkey.StartsWith("WPFInstall")) { "Install" }
|
||||
elseif ($cbkey.StartsWith("WPFTweaks")) { "Tweaks" }
|
||||
elseif ($cbkey.StartsWith("WPFToggle")) { "Toggle" }
|
||||
@@ -26,7 +28,7 @@ function Update-WinUtilSelections {
|
||||
if (!$sync.selectedApps.Contains($cbkey)) {
|
||||
$sync.selectedApps.Add($cbkey)
|
||||
# The List type needs to be specified again, because otherwise Sort-Object will convert the list to a string if there is only a single entry
|
||||
[System.Collections.Generic.List[pscustomobject]]$sync.selectedApps = $sync.SelectedApps | Sort-Object
|
||||
[System.Collections.Generic.List[string]]$sync.selectedApps = $sync.SelectedApps | Sort-Object
|
||||
}
|
||||
}
|
||||
"Tweaks" {
|
||||
|
||||
Reference in New Issue
Block a user