5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-21 11:29:29 +08:00

quick fixes

This commit is contained in:
Zach Botterman 2025-02-23 11:40:39 -08:00
parent 6d44068ede
commit ab9c460088
3 changed files with 13 additions and 9 deletions

View File

@ -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!");
}
}
@ -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",

View File

@ -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
}
@ -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),

View File

@ -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 {
@ -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(
@ -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(