Skip to content

Commit

Permalink
Refactor: use a set for progress bar waiting messages (#925)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Feb 10, 2024
1 parent f1b90c8 commit 77b7c3b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/console/progressBarCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class ProgressBarCLI extends ProgressBar {

private waitingMessageTimeout?: NodeJS.Timeout;

private waitingMessages: string[] = [];
private readonly waitingMessages: Set<string> = new Set();

private constructor(
logger: Logger,
Expand Down Expand Up @@ -200,15 +200,15 @@ export default class ProgressBarCLI extends ProgressBar {
* user know that there is still something processing.
*/
addWaitingMessage(waitingMessage: string): void {
this.waitingMessages.push(waitingMessage);
this.waitingMessages.add(waitingMessage);
this.setWaitingMessageTimeout();
}

/**
* Remove a waiting message to let the user know some processing has finished.
*/
removeWaitingMessage(waitingMessage: string): void {
this.waitingMessages = this.waitingMessages.filter((msg) => msg !== waitingMessage);
this.waitingMessages.delete(waitingMessage);

if (this.payload.waitingMessage) {
// Render immediately if the output could change
Expand Down

0 comments on commit 77b7c3b

Please sign in to comment.