mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
fix default complex action
This commit is contained in:
parent
fa498f1c5e
commit
050e4ef1a8
2 changed files with 8 additions and 19 deletions
|
|
@ -19,7 +19,7 @@ func main() {
|
|||
notificationService := notifications.New()
|
||||
|
||||
app := application.New(application.Options{
|
||||
Name: "notifications_demo",
|
||||
Name: "Notifications",
|
||||
Description: "A demo of using raw HTML & CSS",
|
||||
Services: []application.Service{
|
||||
application.NewService(notificationService),
|
||||
|
|
@ -33,7 +33,7 @@ func main() {
|
|||
})
|
||||
|
||||
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||
Title: "Window 1",
|
||||
Title: "Notifications",
|
||||
Mac: application.MacWindow{
|
||||
InvisibleTitleBarHeight: 50,
|
||||
Backdrop: application.MacBackdropTranslucent,
|
||||
|
|
@ -58,13 +58,8 @@ func main() {
|
|||
})
|
||||
time.Sleep(time.Second * 2)
|
||||
|
||||
var uuid1 string = "Wails Notification Demo"
|
||||
if application.Get().Environment().OS == "darwin" {
|
||||
uuid1 = "uuid1"
|
||||
}
|
||||
|
||||
notificationService.SendNotification(notifications.NotificationOptions{
|
||||
ID: uuid1,
|
||||
ID: "uuid1",
|
||||
Title: "Title!",
|
||||
Body: "Body!",
|
||||
Data: map[string]interface{}{
|
||||
|
|
@ -76,11 +71,6 @@ func main() {
|
|||
|
||||
time.Sleep(time.Second * 2)
|
||||
|
||||
var uuid2 string = "Wails Notification Demo"
|
||||
if application.Get().Environment().OS == "darwin" {
|
||||
uuid2 = "uuid2"
|
||||
}
|
||||
|
||||
notificationService.RegisterNotificationCategory(notifications.NotificationCategory{
|
||||
ID: "BACKEND_NOTIF",
|
||||
Actions: []notifications.NotificationAction{
|
||||
|
|
@ -94,9 +84,9 @@ func main() {
|
|||
})
|
||||
|
||||
notificationService.SendNotificationWithActions(notifications.NotificationOptions{
|
||||
ID: uuid2,
|
||||
ID: "uuid2",
|
||||
Title: "Complex Backend Notification",
|
||||
Subtitle: "Should not show on Windows",
|
||||
Subtitle: "From: Jane Doe",
|
||||
Body: "Is it raining today where you are?",
|
||||
CategoryID: "BACKEND_NOTIF",
|
||||
Data: map[string]interface{}{
|
||||
|
|
|
|||
|
|
@ -152,11 +152,10 @@ func (ns *Service) SendNotificationWithActions(options NotificationOptions) erro
|
|||
}
|
||||
|
||||
if options.Data != nil {
|
||||
n.ActivationArguments, _ = encodePayload(n.ActivationArguments, options.Data)
|
||||
|
||||
for index := range n.Actions {
|
||||
encodedPayload, err := encodePayload(n.Actions[index].Arguments, options.Data)
|
||||
if err == nil {
|
||||
n.Actions[index].Arguments = encodedPayload
|
||||
}
|
||||
n.Actions[index].Arguments, _ = encodePayload(n.Actions[index].Arguments, options.Data)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue