From 12cbe544eaab3c999c0ab1ed056661b5cbf1a347 Mon Sep 17 00:00:00 2001 From: Yasuaki Uechi Date: Fri, 8 Apr 2022 15:21:58 +0900 Subject: [PATCH] fix: don't overwrite isLive unless it is undefined --- src/masterchat.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/masterchat.ts b/src/masterchat.ts index 60d7fefc..f39e9df1 100644 --- a/src/masterchat.ts +++ b/src/masterchat.ts @@ -130,9 +130,7 @@ export class Masterchat extends EventEmitter { ); } // set channelId "" as populateMetadata will fill out it anyways - const mc = new Masterchat(videoId, "", { - ...options, - }); + const mc = new Masterchat(videoId, "", options); await mc.populateMetadata(); return mc; } @@ -188,7 +186,8 @@ export class Masterchat extends EventEmitter { } /** - * Chat API + * (EventEmitter API) + * start listening live stream */ public listen(iterateOptions?: IterateChatOptions) { if (this.listener) return this.listener; @@ -269,6 +268,10 @@ export class Masterchat extends EventEmitter { return this.listener; } + /** + * (EventEmitter API) + * stop listening live stream + */ public stop(): void { if (!this.listener) return; this.listenerAbortion.abort(); @@ -540,7 +543,7 @@ export class Masterchat extends EventEmitter { this.title = metadata.title; this.channelId = metadata.channelId; this.channelName = metadata.channelName; - this.isLive = metadata.isLive; + this.isLive ??= metadata.isLive; } async fetchMetadataFromWatch(id: string) {