mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 01:32:33 +02:00
Make on_start run when the plugin is toggled
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -184,6 +184,28 @@ func (m *Manager) TogglePlugin(name string) {
|
||||
if m.db != nil {
|
||||
_ = m.db.SavePluginState(name, enabled, configText)
|
||||
}
|
||||
if !enabled {
|
||||
return
|
||||
}
|
||||
hc, ok := found.hooks["on_start"]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if hc.Sync {
|
||||
found.mu.Lock()
|
||||
if _, err := callHook(found, "on_start"); err != nil {
|
||||
log.Printf("plugin %s on_start: %v", found.Name, err)
|
||||
}
|
||||
found.mu.Unlock()
|
||||
} else {
|
||||
go func() {
|
||||
found.mu.Lock()
|
||||
if _, err := callHook(found, "on_start"); err != nil {
|
||||
log.Printf("plugin %s on_start: %v", found.Name, err)
|
||||
}
|
||||
found.mu.Unlock()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) SaveConfig(name, configText string) {
|
||||
|
||||
Reference in New Issue
Block a user