Skip to content

Commit

Permalink
quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
popaprozac committed Feb 23, 2025
1 parent 6d44068 commit ab9c460
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 5 additions & 3 deletions v3/examples/notifications/frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const notificationsElement = document.getElementById('notifications');
window.sendNotification = async () => {
const granted = await Notifications.RequestUserNotificationAuthorization();
if (granted) {
await Notifications.SendNotification("some-uuid-fronted", "Frontend Notificaiton", "", "Notificaiton sent through JS!");
const uuid = crypto.randomUUID();
await Notifications.SendNotification(uuid, "Frontend Notification", "", "Notification sent through JS!");
}
}

Expand All @@ -26,11 +27,12 @@ window.sendComplexNotification = async () => {
replyPlaceholder: "Reply to frontend...",
});

const uuid = crypto.randomUUID();
await Notifications.SendNotificationWithActions({
id: "some-uuid-complex",
id: uuid,
title: "Complex Frontend Notification",
subtitle: "From: Jane Doe",
body: "Is it rainging today where you are?",
body: "Is it raining today where you are?",
categoryId: "FRONTEND_NOTIF",
data: {
messageId: "msg-456",
Expand Down
6 changes: 1 addition & 5 deletions v3/pkg/application/context_application_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (c ApplicationEventContext) HasVisibleWindows() bool {
return c.getBool("hasVisibleWindows")
}

func (c *ApplicationEventContext) setData(data map[string]any) {
func (c ApplicationEventContext) setData(data map[string]any) {
c.data = data
}

Expand All @@ -72,10 +72,6 @@ func (c ApplicationEventContext) Filename() string {
return result
}

func (c *ApplicationEventContext) GetData() map[string]any {
return c.data
}

func newApplicationEventContext() *ApplicationEventContext {
return &ApplicationEventContext{
data: make(map[string]any),
Expand Down
8 changes: 7 additions & 1 deletion v3/pkg/services/notifications/notifications_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func (ns *Service) RemoveDeliveredNotification(_ string) error {
return nil
}

// Is there a better way for me to grab this from the Wails config?
func getExeName() string {
executable, err := os.Executable()
if err != nil {
Expand All @@ -178,6 +179,9 @@ func getExeName() string {

func saveCategoriesToRegistry() error {
appName := getExeName()
if appName == "" {
return fmt.Errorf("failed to save categories to registry: empty executable name")
}
registryPath := fmt.Sprintf(`SOFTWARE\%s\NotificationCategories`, appName)

key, _, err := registry.CreateKey(
Expand All @@ -200,7 +204,9 @@ func saveCategoriesToRegistry() error {

func loadCategoriesFromRegistry() error {
appName := getExeName()
println(appName)
if appName == "" {
return fmt.Errorf("failed to save categories to registry: empty executable name")
}
registryPath := fmt.Sprintf(`SOFTWARE\%s\NotificationCategories`, appName)

key, err := registry.OpenKey(
Expand Down

0 comments on commit ab9c460

Please sign in to comment.