Skip to content

Commit 52115dc

Browse files
committed
Only check for support of events once, avoid multiple warnings
1 parent a3707e1 commit 52115dc

File tree

5 files changed

+18
-28
lines changed

5 files changed

+18
-28
lines changed

BurntToast/BurntToast.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
4747
* Fix: Error when running Update-BTNotification on PowerShell 6.0+ (#120)
4848
* Fix: Error when using actionable toast parameters on any version (#122)
49+
* Fix: Multiple warnings about events not being supported when specifying multiple event types.
4950
5051
# 0.8.2
5152

BurntToast/Public/New-BurntToastNotification.ps1

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,20 +268,13 @@
268268
$ToastSplat.Add('DataBinding', $DataBinding)
269269
}
270270

271+
# Toast events may not be supported, this check happens inside Submit-BTNotification
271272
if ($ActivatedAction) {
272-
if ($Script:ActionsSupported) {
273-
$ToastSplat.Add('ActivatedAction', $ActivatedAction)
274-
} else {
275-
Write-Warning $Script:UnsupportedEvents
276-
}
273+
$ToastSplat.Add('ActivatedAction', $ActivatedAction)
277274
}
278275

279276
if ($DismissedAction) {
280-
if ($Script:ActionsSupported) {
281-
$ToastSplat.Add('DismissedAction', $DismissedAction)
282-
} else {
283-
Write-Warning $Script:UnsupportedEvents
284-
}
277+
$ToastSplat.Add('DismissedAction', $DismissedAction)
285278
}
286279

287280
if($PSCmdlet.ShouldProcess( "submitting: $($Content.GetContent())" )) {

BurntToast/Public/Submit-BTNotification.ps1

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,17 @@
149149
$Toast.Data.SequenceNumber = $SequenceNumber
150150
}
151151

152-
if ($ActivatedAction) {
152+
if ($ActivatedAction -or $DismissedAction -or $FailedAction) {
153153
if ($Script:ActionsSupported) {
154-
Register-ObjectEvent -InputObject $Toast -EventName Activated -Action $ActivatedAction |Out-Null
155-
} else {
156-
Write-Warning $Script:UnsupportedEvents
157-
}
158-
}
159-
160-
if ($DismissedAction) {
161-
if ($Script:ActionsSupported) {
162-
Register-ObjectEvent -InputObject $Toast -EventName Dismissed -Action $DismissedAction | Out-Null
163-
} else {
164-
Write-Warning $Script:UnsupportedEvents
165-
}
166-
}
167-
168-
if ($FailedAction) {
169-
if ($Script:ActionsSupported) {
170-
Register-ObjectEvent -InputObject $Toast -EventName Failed -Action $FailedAction | Out-Null
154+
if ($ActivatedAction) {
155+
Register-ObjectEvent -InputObject $Toast -EventName Activated -Action $ActivatedAction |Out-Null
156+
}
157+
if ($DismissedAction) {
158+
Register-ObjectEvent -InputObject $Toast -EventName Dismissed -Action $DismissedAction | Out-Null
159+
}
160+
if ($FailedAction) {
161+
Register-ObjectEvent -InputObject $Toast -EventName Failed -Action $FailedAction | Out-Null
162+
}
171163
} else {
172164
Write-Warning $Script:UnsupportedEvents
173165
}

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- Fix: Error when using actionable toast parameters on any version ([#122](https://github.com/Windos/BurntToast/issues/122))
88

9+
- Fix: Multiple warnings about events not being supported when specifying multiple event types.
10+
911
- [v0.8.2](https://github.com/Windos/BurntToast/releases/download/v0.8.2/BurntToast.zip)
1012

1113
- Add: AdaptiveGroups are now usable via New-BTColumn

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ if you using Powershell 6 or later, extract into `$env:userprofile\Documents\Pow
6666

6767
- Fix: Error when using actionable toast parameters on any version ([#122](https://github.com/Windos/BurntToast/issues/122))
6868

69+
- Fix: Multiple warnings about events not being supported when specifying multiple event types.
70+
6971
- [v0.8.2](https://github.com/Windos/BurntToast/releases/download/v0.8.2/BurntToast.zip)
7072

7173
- Add: AdaptiveGroups are now usable via New-BTColumn

0 commit comments

Comments
 (0)