commit d1b15c7028877de4e826be767f6f830f82ce06eb
parent a09f8f0fe30b5971d8c0a855c41ff0dfe6b18b6e
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date: Tue, 21 Mar 2023 17:57:11 +0800
bind: use the global app.ID if set
As the comment acknowledges, this is not generally a good way
to write this code. However, we want some peculiar flexibility
when using this API. We need support the global SetAppData
along side supplying the data within toast.Notification.
Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Diffstat:
2 files changed, 7 insertions(+), 24 deletions(-)
diff --git a/internal/bind/bind.go b/internal/bind/bind.go
@@ -42,6 +42,13 @@ func GenerateToast(appID, xml string) error {
return err
}
+ // If appID is already set via SetAppData, use that.
+ // It's a bit of a side-channel hack, however it's necessary for some of
+ // the API flexibility that's being employed.
+ if appID == "" {
+ appID = appData.ID
+ }
+
// 1. allocate ClassFactory implementation.
// 2. register ClassFactory implementation (provides our ActivationCallback to the runtime)
// 3. load noti manager (statics impl)
diff --git a/internal/bind/bind_test.go b/internal/bind/bind_test.go
@@ -80,30 +80,6 @@ func TestSetAppData(t *testing.T) {
t.Run("expect registry keys", func(t *testing.T) {
- t.Run("error on empty ID", func(t *testing.T) {
- setAppData = setAppDataImpl
-
- record := map[string]string{}
-
- // Capture what would be written out to the registry.
- writeStringValue = func(path, name, value string) error {
- record[filepath.Join(path, name)] = value
- return nil
- }
-
- input := AppData{
- ExePath: "test.exe",
- }
-
- if err := SetAppData(input); err == nil {
- t.Fatalf("expected error, got nil")
- }
-
- if len(record) > 0 {
- t.Fatalf("wanted empty map, got value: %v", record)
- }
- })
-
t.Run("minimal keys", func(t *testing.T) {
setAppData = setAppDataImpl