Better by Romain

pull/312/head
KnifMelti 2023-04-10 21:10:15 +02:00
parent 55c4efdc69
commit b9139542ce
2 changed files with 7 additions and 13 deletions

View File

@ -53,7 +53,7 @@ if ($Logs) {
#Not available yet
$Message = $NotifLocale.local.outputs.output[5].message
$MessageType = "warning"
Start-NotifTask -Message $Message -MessageType $MessageType
Start-NotifTask -Message $Message -MessageType $MessageType -UserRun
}
}
elseif ($Help) {
@ -65,7 +65,7 @@ else {
if (Test-WAUisRunning) {
$Message = $NotifLocale.local.outputs.output[8].message
$MessageType = "warning"
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
break
}
#Run scheduled task
@ -73,7 +73,7 @@ else {
#Starting check - Send notification
$Message = $NotifLocale.local.outputs.output[6].message
$MessageType = "info"
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
#Sleep until the task is done
While (Test-WAUisRunning) {
Start-Sleep 3
@ -91,12 +91,12 @@ else {
$MessageType = "success"
$Message = $NotifLocale.local.outputs.output[9].message
}
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
}
catch {
#Check failed - Just send notification
$Message = $NotifLocale.local.outputs.output[7].message
$MessageType = "error"
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
}
}

View File

@ -11,16 +11,10 @@ function Start-NotifTask {
[String]$Body,
[String]$Button1Text,
[String]$Button1Action,
[Switch]$ButtonDismiss = $false
[Switch]$ButtonDismiss = $false,
[Switch]$UserRun = $false
)
$caller = Get-ChildItem $MyInvocation.PSCommandPath | Select-Object -Expand Name
if ($caller -eq "User-Run.ps1") {
$Title = "Winget-AutoUpdate (WAU)"
$Balise = "Winget-AutoUpdate (WAU)"
$UserRun = $True
}
if (($WAUConfig.WAU_NotificationLevel -eq "Full") -or ($WAUConfig.WAU_NotificationLevel -eq "SuccessOnly" -and $MessageType -eq "Success") -or ($UserRun)) {
# XML Toast template creation