From 90210b0491209532723cbc6fe9f568c9d47fb357 Mon Sep 17 00:00:00 2001 From: Bunyanuch Saengnet Date: Mon, 2 Sep 2019 17:04:41 +0000 Subject: [PATCH 1/4] added suspending for rendering --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 58d92f2..d6a5002 100644 --- a/index.js +++ b/index.js @@ -44,8 +44,18 @@ const renderHelper = (tasks, options, level) => { return output.join('\n'); }; +const shouldSuspendUpdateRenderer = (tasks) => { + + for(const task of tasks){ + if(task.isEnabled() && task.isPending() && !task.isCompleted()){ + return task.shouldSuspendUpdateRenderer(); + } + } +} + const render = (tasks, options) => { - logUpdate(renderHelper(tasks, options)); + if(!shouldSuspendUpdateRenderer(tasks)) + logUpdate(renderHelper(tasks, options)); }; class UpdateRenderer { From c7e7fa23e697961388032e338dc0fcb8c095c360 Mon Sep 17 00:00:00 2001 From: Bunyanuch Saengnet Date: Sat, 14 Sep 2019 11:56:14 +0000 Subject: [PATCH 2/4] fixed linter issues --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index d6a5002..229d9e9 100644 --- a/index.js +++ b/index.js @@ -44,18 +44,18 @@ const renderHelper = (tasks, options, level) => { return output.join('\n'); }; -const shouldSuspendUpdateRenderer = (tasks) => { - - for(const task of tasks){ - if(task.isEnabled() && task.isPending() && !task.isCompleted()){ +const shouldSuspendUpdateRenderer = tasks => { + for (const task of tasks) { + if (task.isEnabled() && task.isPending() && !task.isCompleted()) { return task.shouldSuspendUpdateRenderer(); } } -} +}; const render = (tasks, options) => { - if(!shouldSuspendUpdateRenderer(tasks)) + if (!shouldSuspendUpdateRenderer(tasks)) { logUpdate(renderHelper(tasks, options)); + } }; class UpdateRenderer { From 4685274ffa8c529d5a404ad89d778c3a9f7b56a9 Mon Sep 17 00:00:00 2001 From: Bunyanuch Saengnet Date: Wed, 18 Sep 2019 16:25:49 +0000 Subject: [PATCH 3/4] Moved feature from listr-update-renderer to listr according to comment https://github.com/SamVerschueren/listr-update-renderer/pull/23/files/90210b0491209532723cbc6fe9f568c9d47fb357#r324416643 --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 229d9e9..e932403 100644 --- a/index.js +++ b/index.js @@ -46,10 +46,11 @@ const renderHelper = (tasks, options, level) => { const shouldSuspendUpdateRenderer = tasks => { for (const task of tasks) { - if (task.isEnabled() && task.isPending() && !task.isCompleted()) { - return task.shouldSuspendUpdateRenderer(); + if (task.shouldSuspendUpdateRenderer()) { + return true; } } + return false; }; const render = (tasks, options) => { From c72639dc31d69eee0dd53215e046c4838a53ed29 Mon Sep 17 00:00:00 2001 From: Bunyanuch Saengnet Date: Tue, 18 Feb 2020 18:51:41 +0000 Subject: [PATCH 4/4] Refactoring suspension --- index.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/index.js b/index.js index e932403..7934791 100644 --- a/index.js +++ b/index.js @@ -45,12 +45,7 @@ const renderHelper = (tasks, options, level) => { }; const shouldSuspendUpdateRenderer = tasks => { - for (const task of tasks) { - if (task.shouldSuspendUpdateRenderer()) { - return true; - } - } - return false; + return tasks.some(task => task.shouldSuspendUpdateRenderer()); }; const render = (tasks, options) => {