Refactor code structure for improved readability and maintainability (#473)

* Add ToolTips to Tweaks
This commit is contained in:
Jeffrey
2026-02-15 23:08:54 +01:00
committed by GitHub
parent 95dc490b6e
commit 65aabbc050
31 changed files with 2877 additions and 2813 deletions

View File

@@ -0,0 +1,44 @@
# Read Apps.json and return list of app objects with optional filtering
function LoadAppsDetailsFromJson {
param (
[switch]$OnlyInstalled,
[string]$InstalledList = "",
[switch]$InitialCheckedFromJson
)
$apps = @()
try {
$jsonContent = Get-Content -Path $script:AppsListFilePath -Raw | ConvertFrom-Json
}
catch {
Write-Error "Failed to read Apps.json: $_"
return $apps
}
foreach ($appData in $jsonContent.Apps) {
$appId = $appData.AppId.Trim()
if ($appId.length -eq 0) { continue }
if ($OnlyInstalled) {
if (-not ($InstalledList -like ("*$appId*")) -and -not (Get-AppxPackage -Name $appId)) {
continue
}
if (($appId -eq "Microsoft.Edge") -and -not ($InstalledList -like "* Microsoft.Edge *")) {
continue
}
}
$displayName = if ($appData.FriendlyName) { "$($appData.FriendlyName) ($appId)" } else { $appId }
$isChecked = if ($InitialCheckedFromJson) { $appData.SelectedByDefault } else { $false }
$apps += [PSCustomObject]@{
AppId = $appId
DisplayName = $displayName
IsChecked = $isChecked
Description = $appData.Description
SelectedByDefault = $appData.SelectedByDefault
}
}
return $apps
}