From 00ec1f56407a79c6ddbff4956c77d8da7ae5ba6f Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Mon, 22 Jan 2024 16:53:42 -0500 Subject: [PATCH] Make force-loaded channels stay open when all participants leave --- src/channel/Channel.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/channel/Channel.ts b/src/channel/Channel.ts index 32a57cb..d9d075c 100644 --- a/src/channel/Channel.ts +++ b/src/channel/Channel.ts @@ -53,14 +53,14 @@ export class Channel extends EventEmitter { public logger: Logger; public chatHistory = new Array(); - // TODO Add the crown public crown?: Crown; constructor( private _id: string, set?: Partial, creator?: Socket, - owner_id?: string + owner_id?: string, + public stays: boolean = false ) { super(); @@ -120,7 +120,7 @@ export class Channel extends EventEmitter { } } - if (this.ppl.length == 0) { + if (this.ppl.length == 0 && !this.stays) { this.destroy(); } }); @@ -562,10 +562,10 @@ export default Channel; let hasFullChannel = false; for (const id of config.forceLoad) { - new Channel(id); + new Channel(id, undefined, undefined, undefined, true); if (id == config.fullChannel) hasFullChannel = true; } if (!hasFullChannel) { - new Channel(config.fullChannel); + new Channel(config.fullChannel, undefined, undefined, undefined, true); }