diff --git a/lib/client.js b/lib/client.js index f3d1042..aabc695 100644 --- a/lib/client.js +++ b/lib/client.js @@ -163,7 +163,6 @@ export default class Client extends EventTarget { if (msg.tags["batch"]) { msgBatch = this.batches.get(msg.tags["batch"]); if (msgBatch) { - msgBatch.messages.push(msg); msg.batch = msgBatch; } } @@ -259,7 +258,6 @@ export default class Client extends EventTarget { params: msg.params.slice(2), tags: msg.tags, parent: msgBatch, - messages: [], }; this.batches.set(name, batch); } else { @@ -539,17 +537,30 @@ export default class Client extends EventTarget { } fetchBatch(msg, batchType) { + var batchName = null; + var messages = []; return this.roundtrip(msg, (msg) => { + if (batchName) { + var batch = msg.batch; + while (batch) { + if (batch.name === batchName) { + messages.push(msg); + break; + } + batch = batch.parent; + } + } + switch (msg.command) { case "BATCH": var enter = msg.params[0].startsWith("+"); var name = msg.params[0].slice(1); - if (enter) { + if (enter && msg.params[1] === batchType) { + batchName = name; break; } - var batch = this.batches.get(name); - if (batch.type === batchType) { - return batch; + if (!enter && name === batchName) { + return { ...this.batches.get(name), messages }; } break; case "FAIL":