Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Curly Braces when "Reminder" pops up #72
I'm digging into this awesome tool at the moment and I came around a bug.
I'm triggering a reminder, that the device hasn't rebooted for a specifc time with a Snooze Button.
Then I press the Snooze Button and wait for it to appear again. This time the text has curly braces around the text:
I am using Windows 10 1903 for my tests but it also happens on 1809.
Here is my code:
[int]$Uptime_hours = ((get-date) - (gcim Win32_OperatingSystem).LastBootUpTime).TotalHours
Just found a "workaround"!
I converted my toast to an XML and "toasted" it like you described here:
The curly braces are gone :) Sadly, I have to come up with another placeholder for language specifics :/
PS: I had to alter your "CleanContent a little because "Header" and "Body" styles were not cleaned up:
OT: Can I easily define the amount of time a Toast is snoozed? I think 10min is too disturbing. Otherwise I have to create a selection box along with pre defined times.
Ah, good call. That used to built directly into the module, but it was removed in order to make updatable toasts work... going to need to figure out how to ensure snoozed toasts work without manually having to clean them up!
Unless it's mysteriously working on your system and not mine, those styles aren't doing anything (see this issue, conveniently the one where the updatable toasts were also sorted out). Your first text object will always be your heading automatically and any extra text will automatically be the body, all specifying a style does is add extra crud to the XML (as you've seen).
Unfortunately it's not possible to set the snooze time without a selectionbox, otherwise it uses the stock standard system standard.
Here's a sample for how to set up the selection box and tie it through to your button:
$15mins = New-BTSelectionBoxItem -Id 30 -Content '30 Minutes' $60mins = New-BTSelectionBoxItem -Id 60 -Content '1 Hour' $240mins = New-BTSelectionBoxItem -Id 240 -Content '4 Hours' $1440mins = New-BTSelectionBoxItem -Id 1440 -Content '1 Day' $Input = New-BTInput -DefaultSelectionBoxItemId 30 -Id 'SnoozeSelection' -Items $15mins, $60mins, $240mins, $1440mins $Text1 = New-BTText -Content "It's time for a reboot" $Text2 = New-BTText -Content "Your device is running for: $Uptime_Hours hours" $Image1 = New-BTImage -Source 'C:\Temp\Images\BurntToast.png' -AppLogoOverride -Crop Circle $Binding = New-BTBinding -Children $Text1, $Text2 -AppLogoOverride $Image1 $Visual = New-BTVisual -BindingGeneric $Binding $Button1 = New-BTButton -Snooze -Content "Snooze" -Id 'SnoozeSelection' $Action1 = New-BTAction -Buttons $Button1 -Inputs $Input $Content = New-BTContent -Visual $Visual -Actions $Action1 Submit-BTNotification -Content $Content -UniqueIdentifier "Toast_Uptime"
Key is that the ID for each selection box item is the number of minute to snooze if that option is selected.
Bundle those up into an "Input" through which you can define the default and then give the group and Id.
When it comes to your button, give it the same Id as what you gave the Input / group of selection box items.
Finally, the inputs added to your action.
Will aim to have an "official" solution in place for the next release for the curly braces. Thanks again for the report!
@Ig3l what's the output of your $PSVersionTable?
Notes to myself: it looks like the snooze is stripping a lot of metadata from the original toast.
Thanks for the input! :) really appreciate your work!
For the Styles - no, they don't seem to work but that's not a big deal. The Toast work as intended!
Well, thanks for the code! That makes it easy to understand :)
Here is the info of my $Psversiontable
PS: Rergarding you to-dos: The issue is happening on both Win10 1903 and 1809 (+ 1809 has the Snooze button in the bottom right of the toast whereas 1903 uses the whole space available)
Couple things to be aware of...
If you're going to include the system uptime in the notification, then the snooze button will result in inaccurate snoozed notifications since the actual uptime will not get recalculated. For instance, a notification says "uptime is 100 hours" and you snooze it for 4 hours. When it comes back, it will still say "uptime is 100 hours" even though the actual uptime is now 104 hours. While you dynamically created the content for the initial toast, the scheduled toast created by the snooze button is a static copy of that original toast.
Also, if the user snoozes the notification for 4 hours, but then they reboot 1 hour later, you'll get another erroneous behavior. 3 hours after the reboot (4 hours since the initial snooze), the snooze duration will expire and the 100 hour uptime notification will display again reminding them to reboot, even though they just rebooted. The only way to prevent something like this is to have a logon script that checks for any reboot reminder scheduled toasts and programmatically deletes them.
For these reasons, I chose to omit snooze buttons from my reboot reminders.