Skip to content

Commit

Permalink
fix: don't overwrite isLive unless it is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed Apr 8, 2022
1 parent 9071443 commit 12cbe54
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/masterchat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 12cbe54

Please sign in to comment.