// // Notification helpers. Each notification uses a stable identifier so that // repeated failures replace one another rather than stacking up. // function notify(identifier, title, body, actions) { let request = new NotificationRequest(identifier); request.title = title; request.body = body; if (actions && actions.length > 0) { request.actions = actions.map((action) => action.title); } return nova.notifications.add(request).then((reply) => { if (!actions || reply.actionIdx === undefined || reply.actionIdx === null) { return reply; } let action = actions[reply.actionIdx]; if (action && action.handler) { action.handler(); } return reply; }); } // Reports a failed operation, logging the underlying error for the console. function failure(title, error, identifier) { let message = error instanceof Error ? error.message : String(error || ""); if (nova.inDevMode()) { console.error(title, message); } return notify(identifier || "apple-container-failure", title, message); } // Reports a failure with a shortcut to the extension's preferences. function configFailure(title, error, identifier) { let message = error instanceof Error ? error.message : String(error || ""); return notify(identifier || "apple-container-config", title, message, [ { title: "Preferences", handler: () => nova.openConfig() }, { title: "Dismiss" } ]); } function info(title, body, identifier) { return notify(identifier || "apple-container-info", title, body); } module.exports = { notify, failure, configFailure, info };