mirror of
https://codeberg.org/emersion/gamja
synced 2025-04-22 01:23:56 +02:00
Only allow one WHO command at a time
Closes: https://todo.sr.ht/~emersion/gamja/120
This commit is contained in:
parent
195e4ca371
commit
c11bf6508a
@ -77,7 +77,10 @@ export default class Client extends EventTarget {
|
|||||||
autoReconnect = true;
|
autoReconnect = true;
|
||||||
reconnectTimeoutID = null;
|
reconnectTimeoutID = null;
|
||||||
pingIntervalID = null;
|
pingIntervalID = null;
|
||||||
pendingHistory = Promise.resolve(null);
|
pendingCmds = {
|
||||||
|
WHO: Promise.resolve(null),
|
||||||
|
CHATHISTORY: Promise.resolve(null),
|
||||||
|
};
|
||||||
cm = irc.CaseMapping.RFC1459;
|
cm = irc.CaseMapping.RFC1459;
|
||||||
monitored = new irc.CaseMapMap(null, irc.CaseMapping.RFC1459);
|
monitored = new irc.CaseMapMap(null, irc.CaseMapping.RFC1459);
|
||||||
pendingLists = new irc.CaseMapMap(null, irc.CaseMapping.RFC1459);
|
pendingLists = new irc.CaseMapMap(null, irc.CaseMapping.RFC1459);
|
||||||
@ -126,7 +129,9 @@ export default class Client extends EventTarget {
|
|||||||
this.availableCaps = {};
|
this.availableCaps = {};
|
||||||
this.enabledCaps = {};
|
this.enabledCaps = {};
|
||||||
this.batches = new Map();
|
this.batches = new Map();
|
||||||
this.pendingHistory = Promise.resolve(null);
|
Object.keys(this.pendingCmds).forEach((k) => {
|
||||||
|
this.pendingCmds[k] = Promise.resolve(null);
|
||||||
|
});
|
||||||
this.isupport = new Map();
|
this.isupport = new Map();
|
||||||
this.monitored = new irc.CaseMapMap(null, irc.CaseMapping.RFC1459);
|
this.monitored = new irc.CaseMapMap(null, irc.CaseMapping.RFC1459);
|
||||||
|
|
||||||
@ -394,10 +399,10 @@ export default class Client extends EventTarget {
|
|||||||
|
|
||||||
let msg = { command: "WHO", params };
|
let msg = { command: "WHO", params };
|
||||||
let l = [];
|
let l = [];
|
||||||
|
let promise = this.pendingCmds.WHO.then(() => {
|
||||||
return this.roundtrip(msg, (msg) => {
|
return this.roundtrip(msg, (msg) => {
|
||||||
switch (msg.command) {
|
switch (msg.command) {
|
||||||
case irc.RPL_WHOREPLY:
|
case irc.RPL_WHOREPLY:
|
||||||
// TODO: match with mask
|
|
||||||
l.push(this.parseWhoReply(msg));
|
l.push(this.parseWhoReply(msg));
|
||||||
break;
|
break;
|
||||||
case irc.RPL_WHOSPCRPL:
|
case irc.RPL_WHOSPCRPL:
|
||||||
@ -415,6 +420,9 @@ export default class Client extends EventTarget {
|
|||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.whoxQueries.delete(token);
|
this.whoxQueries.delete(token);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
this.pendingCmds.WHO = promise.catch(() => {});
|
||||||
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
parseWhoReply(msg) {
|
parseWhoReply(msg) {
|
||||||
@ -741,14 +749,15 @@ export default class Client extends EventTarget {
|
|||||||
roundtripChatHistory(params) {
|
roundtripChatHistory(params) {
|
||||||
// Don't send multiple CHATHISTORY commands in parallel, we can't
|
// Don't send multiple CHATHISTORY commands in parallel, we can't
|
||||||
// properly handle batches and errors.
|
// properly handle batches and errors.
|
||||||
this.pendingHistory = this.pendingHistory.catch(() => {}).then(() => {
|
let promise = this.pendingCmds.CHATHISTORY.then(() => {
|
||||||
let msg = {
|
let msg = {
|
||||||
command: "CHATHISTORY",
|
command: "CHATHISTORY",
|
||||||
params,
|
params,
|
||||||
};
|
};
|
||||||
return this.fetchBatch(msg, "chathistory").then((batch) => batch.messages);
|
return this.fetchBatch(msg, "chathistory").then((batch) => batch.messages);
|
||||||
});
|
});
|
||||||
return this.pendingHistory;
|
this.pendingCmds.CHATHISTORY = promise.catch(() => {});
|
||||||
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
chatHistoryPageSize() {
|
chatHistoryPageSize() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user