diff --git a/docs/api/routes/events.md b/docs/api/routes/events.md index eaf3350..d818dba 100644 --- a/docs/api/routes/events.md +++ b/docs/api/routes/events.md @@ -47,7 +47,7 @@ emits `{ sender, brandId }`. | `labeltemplate` | `{}` | `POST /labeltemplate`, `PUT /labeltemplate/{id}`, `PATCH /labeltemplate/{id}`, `DELETE /labeltemplate/{id}` | | `printer` | `{}` | `POST /printer`, `PUT /printer/{id}`, `PATCH /printer/{id}`, `DELETE /printer/{id}` | | `printeragent` | `{}` | `PUT /printeragent`, `PATCH /printeragent/{id}`, `DELETE /printeragent/{id}`, printer agent connect/disconnect/state | -| `agentprinter` | `{}` | `PATCH /agentprinter/{id}`, `PUT /agentprinter/order`, `DELETE /agentprinter/{id}`, new printer discovery | +| `agentprinter` | `{ printers }` or `{}` | `PATCH /agentprinter/{id}`, `PUT /agentprinter/order`, `DELETE /agentprinter/{id}`, agent state updates / printer discovery | | `warehouse` | `{}` | `POST /warehouse`, `PUT /warehouse/{id}`, `PATCH /warehouse/{id}`, `DELETE /warehouse/{id}` | | `supplier` | `{}` | `POST /supplier`, `PATCH /supplier/{id}`, `DELETE /supplier/{id}` | | `vfs` | `{}` | VFS uploads and filesystem mutations such as `POST /vfs/upload`, `POST /vfs/mkdir`, `POST /vfs/rename`, `PUT /vfs/{*path}`, `DELETE /vfs/{*path}` | diff --git a/src/api/agent/index.js b/src/api/agent/index.js index 916f685..8a2fb9b 100644 --- a/src/api/agent/index.js +++ b/src/api/agent/index.js @@ -357,9 +357,7 @@ async function handleState(req, res) { if (rawPrinters && req.agent.companyId) { updateAgentPrinters(req.agent.companyId, req.agent.id, req.agent.name, rawPrinters); - } - - if (anyAgentPrinterCreated && req.agent.companyId) { + } else if (anyAgentPrinterCreated && req.agent.companyId) { emit('agentprinter', { companyId: req.agent.companyId }); } diff --git a/src/api/routes/events.js b/src/api/routes/events.js index 62820ea..b609e08 100644 --- a/src/api/routes/events.js +++ b/src/api/routes/events.js @@ -56,7 +56,7 @@ export function register(app, basePath = '') { * | `labeltemplate` | `{}` | `POST /labeltemplate`, `PUT /labeltemplate/{id}`, `PATCH /labeltemplate/{id}`, `DELETE /labeltemplate/{id}` | * | `printer` | `{}` | `POST /printer`, `PUT /printer/{id}`, `PATCH /printer/{id}`, `DELETE /printer/{id}` | * | `printeragent` | `{}` | `PUT /printeragent`, `PATCH /printeragent/{id}`, `DELETE /printeragent/{id}`, printer agent connect/disconnect/state | - * | `agentprinter` | `{}` | `PATCH /agentprinter/{id}`, `PUT /agentprinter/order`, `DELETE /agentprinter/{id}`, new printer discovery | + * | `agentprinter` | `{ printers }` or `{}` | `PATCH /agentprinter/{id}`, `PUT /agentprinter/order`, `DELETE /agentprinter/{id}`, agent state updates / printer discovery | * | `warehouse` | `{}` | `POST /warehouse`, `PUT /warehouse/{id}`, `PATCH /warehouse/{id}`, `DELETE /warehouse/{id}` | * | `supplier` | `{}` | `POST /supplier`, `PATCH /supplier/{id}`, `DELETE /supplier/{id}` | * | `vfs` | `{}` | VFS uploads and filesystem mutations such as `POST /vfs/upload`, `POST /vfs/mkdir`, `POST /vfs/rename`, `PUT /vfs/{*path}`, `DELETE /vfs/{*path}` | diff --git a/src/services/companyPrinterService.js b/src/services/companyPrinterService.js index 713d0dd..de6f508 100644 --- a/src/services/companyPrinterService.js +++ b/src/services/companyPrinterService.js @@ -140,7 +140,7 @@ export function getCompanyPrinter(companyId, identifier) { /** * Broadcasts the current live printer list for a company to all connected subscribers via SSE. - * Emits both `printer` (with data `{ printers }`) and `printerstate`. + * Emits `agentprinter` with data `{ printers }`. * * @param {number} companyId * @param {LivePrinter[]} [printers] @@ -152,8 +152,7 @@ export function broadcastCompanyPrinters(companyId, printers) { const list = printers ?? getCompanyPrinters(cId); const payload = { printers: list }; - emit('printer', { companyId: cId, data: payload }); - emit('printerstate', { companyId: cId, data: payload }); + emit('agentprinter', { companyId: cId, data: payload }); } /**