mirror of
https://codeberg.org/emersion/gamja
synced 2025-03-15 08:53:30 +01:00
lib/client: rename whoisDB to pendingWHOIS, garbage collect
This commit is contained in:
parent
49a59077b7
commit
b059e034e2
@ -79,7 +79,7 @@ export default class Client extends EventTarget {
|
|||||||
pendingHistory = Promise.resolve(null);
|
pendingHistory = 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);
|
||||||
whoisDB = new irc.CaseMapMap(null, irc.CaseMapping.RFC1459);
|
pendingWHOIS = new irc.CaseMapMap(null, irc.CaseMapping.RFC1459);
|
||||||
whoxQueries = new Map();
|
whoxQueries = new Map();
|
||||||
|
|
||||||
constructor(params) {
|
constructor(params) {
|
||||||
@ -273,10 +273,16 @@ export default class Client extends EventTarget {
|
|||||||
case irc.RPL_WHOISCHANNELS:
|
case irc.RPL_WHOISCHANNELS:
|
||||||
case irc.RPL_ENDOFWHOIS:
|
case irc.RPL_ENDOFWHOIS:
|
||||||
let nick = msg.params[1];
|
let nick = msg.params[1];
|
||||||
if (!this.whoisDB.has(nick)) {
|
let whois = this.pendingWHOIS.get(nick);
|
||||||
this.whoisDB.set(nick, {});
|
if (!whois) {
|
||||||
|
whois = {};
|
||||||
|
this.pendingWHOIS.set(nick, whois);
|
||||||
|
}
|
||||||
|
whois[msg.command] = msg;
|
||||||
|
if (msg.command == irc.RPL_ENDOFWHOIS) {
|
||||||
|
this.pendingWHOIS.delete(nick);
|
||||||
|
msg.whois = whois;
|
||||||
}
|
}
|
||||||
this.whoisDB.get(nick)[msg.command] = msg;
|
|
||||||
break;
|
break;
|
||||||
case irc.ERR_NICKLOCKED:
|
case irc.ERR_NICKLOCKED:
|
||||||
case irc.ERR_SASLFAIL:
|
case irc.ERR_SASLFAIL:
|
||||||
@ -440,7 +446,7 @@ export default class Client extends EventTarget {
|
|||||||
case irc.RPL_ENDOFWHOIS:
|
case irc.RPL_ENDOFWHOIS:
|
||||||
nick = msg.params[1];
|
nick = msg.params[1];
|
||||||
if (this.cm(nick) === targetCM) {
|
if (this.cm(nick) === targetCM) {
|
||||||
return this.whoisDB.get(nick);
|
return msg.whois;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case irc.ERR_NOSUCHNICK:
|
case irc.ERR_NOSUCHNICK:
|
||||||
@ -587,7 +593,7 @@ export default class Client extends EventTarget {
|
|||||||
this.cm = irc.CaseMapping.RFC1459;
|
this.cm = irc.CaseMapping.RFC1459;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.whoisDB = new irc.CaseMapMap(this.whoisDB, this.cm);
|
this.pendingWHOIS = new irc.CaseMapMap(this.pendingWHOIS, this.cm);
|
||||||
this.monitored = new irc.CaseMapMap(this.monitored, this.cm);
|
this.monitored = new irc.CaseMapMap(this.monitored, this.cm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user