File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 1+ Ensure channel.users is an accurate representation of the NAMES response after updates, removing stale users.
Original file line number Diff line number Diff line change @@ -683,25 +683,29 @@ export class Client extends (EventEmitter as unknown as new () => TypedEmitter<C
683683 }
684684 }
685685 if ( knownPrefixes . length > 0 ) {
686- channel . users . set ( match [ 2 ] , knownPrefixes ) ;
686+ channel . tmpUsers . set ( match [ 2 ] , knownPrefixes ) ;
687687 }
688688 else {
689689 // recombine just in case this server allows weird chars in the nick.
690690 // We know it isn't a mode char.
691- channel . users . set ( match [ 1 ] + match [ 2 ] , '' ) ;
691+ channel . tmpUsers . set ( match [ 1 ] + match [ 2 ] , '' ) ;
692692 }
693693 }
694694 } ) ;
695- // If the channel user list was modified, flush.
696- if ( users . length ) {
697- this . state . flush ?.( )
698- }
699695 }
700696
701697 private onReplyNameEnd ( message : Message ) {
702698 this . _casemap ( message , 1 ) ;
703699 const channel = this . chanData ( message . args [ 1 ] ) ;
704700 if ( channel ) {
701+ channel . users . clear ( ) ;
702+ channel . tmpUsers . forEach ( ( modes , user ) => {
703+ channel . users . set ( user , modes ) ;
704+ } ) ;
705+ channel . tmpUsers . clear ( ) ;
706+
707+ this . state . flush ?.( ) ;
708+
705709 this . emit ( 'names' , message . args [ 1 ] , channel . users ) ;
706710 this . _send ( 'MODE' , message . args [ 1 ] ) ;
707711 }
@@ -1165,6 +1169,7 @@ export class Client extends (EventEmitter as unknown as new () => TypedEmitter<C
11651169 key : key ,
11661170 serverName : name ,
11671171 users : new Map ( ) ,
1172+ tmpUsers : new Map ( ) ,
11681173 mode : '' ,
11691174 modeParams : new Map ( ) ,
11701175 } ) ;
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ export interface ChanData {
9090 * nick => mode
9191 */
9292 users : Map < string , string > ,
93+ tmpUsers : Map < string , string > , // used while processing NAMES replies
9394 mode : string ;
9495 modeParams : Map < string , string [ ] > ,
9596 topic ?: string ;
You can’t perform that action at this time.
0 commit comments