Update samy.ps1

This commit is contained in:
2025-12-20 22:26:49 -05:00
parent a9b6c1ba8a
commit 0754f0ce15

View File

@@ -691,46 +691,25 @@ function Get-SamyTasks {
foreach ($t in $tasks) {
# Grab Tooltip if it exists
$tooltipRaw = $null
if ($t.PSObject.Properties.Name -contains 'Tooltip') {
$tooltipRaw = $t.Tooltip
}
# Normalize tooltip to a single string
# Normalize tooltip to a single string (defensive)
$tooltip = if ($tooltipRaw -is [string]) {
$tooltipRaw
}
elseif ($tooltipRaw -is [System.Collections.IEnumerable] -and -not ($tooltipRaw -is [string])) {
$arr = @($tooltipRaw | ForEach-Object { [string]$_ } | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
if ($arr.Count -eq 1) {
$arr[0] # single tooltip item
}
else {
[string]$t.Label # array => treat as bad data, fallback to label
}
# If Tooltip is an array/list, treat as bad data and fall back to Label
[string]$t.Label
}
else {
[string]$tooltipRaw
}
# Fallback: tooltip defaults to label
if ([string]::IsNullOrWhiteSpace($tooltip)) {
$tooltip = [string]$t.Label
}
}
elseif ($tooltipRaw -is [System.Collections.IEnumerable] -and -not ($tooltipRaw -is [string])) {
# Tooltip was an array/list -> join it explicitly (or pick first)
(@($tooltipRaw) | ForEach-Object { [string]$_ }) -join ' '
# If you only want the first item instead, use:
# [string](@($tooltipRaw)[0])
}
else {
[string]$tooltipRaw
}
# Fallback: tooltip defaults to label
# Final fallback: tooltip defaults to label
if ([string]::IsNullOrWhiteSpace($tooltip)) {
$tooltip = [string]$t.Label
}
@@ -753,6 +732,7 @@ function Get-SamyTasks {
}
#endregion Remote Assets + Task Loading