Simplify Client.roundtrip callback arg

This commit is contained in:
Simon Ser 2021-05-31 17:13:55 +02:00
parent 619f1db08f
commit 06ca812d06

View file

@ -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("+");