removeFunctionHook method
void
removeFunctionHook({})
Remove a function hook by ID from the session.
Implementation
void removeFunctionHook({
required String sessionId,
required HookEvent event,
required String hookId,
}) {
final store = _stores[sessionId];
if (store == null) return;
final eventMatchers = store.hooks[event] ?? [];
final updatedMatchers = <SessionHookMatcher>[];
for (final m in eventMatchers) {
final updatedHooks = m.hooks.where((h) {
if (h.hook is FunctionHook) {
return (h.hook as FunctionHook).id != hookId;
}
return true;
}).toList();
if (updatedHooks.isNotEmpty) {
updatedMatchers.add(
SessionHookMatcher(
matcher: m.matcher,
skillRoot: m.skillRoot,
hooks: updatedHooks,
),
);
}
}
if (updatedMatchers.isNotEmpty) {
store.hooks[event] = updatedMatchers;
} else {
store.hooks.remove(event);
}
}