node build fixed
This commit is contained in:
36
seanime-2.9.10/internal/plugin/ui/notification.go
Normal file
36
seanime-2.9.10/internal/plugin/ui/notification.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package plugin_ui
|
||||
|
||||
import (
|
||||
"seanime/internal/notifier"
|
||||
|
||||
"github.com/dop251/goja"
|
||||
)
|
||||
|
||||
type NotificationManager struct {
|
||||
ctx *Context
|
||||
}
|
||||
|
||||
func NewNotificationManager(ctx *Context) *NotificationManager {
|
||||
return &NotificationManager{
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
func (n *NotificationManager) bind(contextObj *goja.Object) {
|
||||
notificationObj := n.ctx.vm.NewObject()
|
||||
_ = notificationObj.Set("send", n.jsNotify)
|
||||
|
||||
_ = contextObj.Set("notification", notificationObj)
|
||||
}
|
||||
|
||||
func (n *NotificationManager) jsNotify(call goja.FunctionCall) goja.Value {
|
||||
message, ok := call.Argument(0).Export().(string)
|
||||
if !ok {
|
||||
n.ctx.handleTypeError("notification: notify requires a string message")
|
||||
return goja.Undefined()
|
||||
}
|
||||
|
||||
notifier.GlobalNotifier.Notify(notifier.Notification(n.ctx.ext.Name), message)
|
||||
|
||||
return goja.Undefined()
|
||||
}
|
||||
Reference in New Issue
Block a user