From 06ca812d061fddb3838a0985370738cc0f500cf7 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 31 May 2021 17:13:55 +0200 Subject: [PATCH] Simplify Client.roundtrip callback arg --- lib/client.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/client.js b/lib/client.js index 3be4d26..39ca4d3 100644 --- a/lib/client.js +++ b/lib/client.js @@ -296,8 +296,7 @@ export default class Client extends EventTarget { who(mask) { var msg = { command: "WHO", params: [mask] }; var l = []; - return this.roundtrip(msg, (event) => { - var msg = event.detail.message; + return this.roundtrip(msg, (msg) => { switch (msg.command) { case irc.RPL_WHOREPLY: // TODO: match with mask @@ -315,8 +314,7 @@ export default class Client extends EventTarget { whois(target) { var targetCM = this.cm(target); var msg = { command: "WHOIS", params: [target] }; - return this.roundtrip(msg, (event) => { - var msg = event.detail.message; + return this.roundtrip(msg, (msg) => { switch (msg.command) { case irc.RPL_ENDOFWHOIS: var nick = msg.params[1]; @@ -488,7 +486,7 @@ export default class Client extends EventTarget { return new Promise((resolve, reject) => { var handleMessage = (event) => { try { - var result = done(event); + var result = done(event.detail.message); if (result) { this.removeEventListener("message", handleMessage); resolve(result); @@ -505,9 +503,7 @@ export default class Client extends EventTarget { } fetchBatch(msg, batchType) { - return this.roundtrip(msg, (event) => { - var msg = event.detail.message; - + return this.roundtrip(msg, (msg) => { switch (msg.command) { case "BATCH": var enter = msg.params[0].startsWith("+");