commit 7388b443a90df3175ba5eb268d1777fc93f7bf85
parent 51d49c7d0c6f71e636f444b815f0832b75130c3f
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date: Mon, 7 Oct 2024 15:34:42 +1000
toast,wintoast: supply AppID directly
This will help us avoid overwriting the app data per push. We only need
access the AppID here.
Diffstat:
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/toast.go b/toast.go
@@ -188,7 +188,7 @@ func (n *Notification) Push() error {
}); err != nil {
return fmt.Errorf("configuring registry: %w", err)
}
- return wintoast.Push(xml, wintoast.PowershellFallback)
+ return wintoast.Push(n.AppID, xml, wintoast.PowershellFallback)
}
func (n *Notification) applyDefaults() {
diff --git a/wintoast/bind.go b/wintoast/bind.go
@@ -44,7 +44,7 @@ func SetActivationCallback(cb Callback) {
//
// If the powershell fallback is engaged, activation callbacks will not
// work as expected and the COM error will still be returned.
-func Push(xml string, op ...option) error {
+func Push(appID, xml string, op ...option) error {
var opts options
for _, opt := range op {
opt(&opts)
@@ -52,7 +52,7 @@ func Push(xml string, op ...option) error {
if opts.PowershellPreferred {
return pushPowershell(xml)
}
- if err := pushCOM(xml); err != nil {
+ if err := pushCOM(appID, xml); err != nil {
if opts.PowershellFallback {
return errors.Join(err, pushPowershell(xml))
}
diff --git a/wintoast/bind_noop.go b/wintoast/bind_noop.go
@@ -14,6 +14,6 @@ func pushPowershell(xml string) error {
return nil
}
-func pushCOM(xml string) error {
+func pushCOM(appID, xml string) error {
return nil
}
diff --git a/wintoast/bind_windows.go b/wintoast/bind_windows.go
@@ -58,7 +58,7 @@ func buildPowershell(xml string, w io.Writer) error {
return tmpl.ScriptTemplate.Execute(w, scriptData{AppID: appData.AppID, XML: xml})
}
-func pushCOM(xml string) error {
+func pushCOM(appID, xml string) error {
if err := initialize(); err != nil {
return err
}
@@ -85,9 +85,9 @@ func pushCOM(xml string) error {
defer manager.Release()
- notifier, err := manager.CreateToastNotifierWithId(appData.AppID)
+ notifier, err := manager.CreateToastNotifierWithId(appID)
if err != nil {
- return fmt.Errorf("manager.CreateToastNotifier(%q): %w", appData.AppID, err)
+ return fmt.Errorf("manager.CreateToastNotifier(%q): %w", appID, err)
}
defer notifier.Release()