From 1a2aa919730717f220e4e84c3bdb4feea41f025f Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Mon, 15 Apr 2024 16:25:12 -0400 Subject: [PATCH] proper fix for precache (#721) * proper fix for precache * wip --- lib/session/call-session.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 2cfa35b1..d5386de7 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -1606,15 +1606,15 @@ Duration=${duration} ` * to be confident we have some time before the say verb is executed, and the Config * does not give us that confidence since it returns immediately. */ - const allTasks = (this.tasks || []).concat(newTasks); - const skipFirst = allTasks.slice(1); - const idxFirstNotConfig = skipFirst.findIndex((t) => t.name !== TaskName.Config); - if (-1 === idxFirstNotConfig) return; + const haveQueuedNonConfig = this.tasks.findIndex((t) => t.name !== TaskName.Config) !== -1; + let tasks = haveQueuedNonConfig ? newTasks : []; + if (!haveQueuedNonConfig) { + const idxFirstNotConfig = newTasks.findIndex((t) => t.name !== TaskName.Config); + if (-1 === idxFirstNotConfig) return; + tasks = newTasks.slice(idxFirstNotConfig + 1); + } - const allTasksAfterFirstNotConfig = skipFirst.slice(idxFirstNotConfig); - - - for (const task of allTasksAfterFirstNotConfig) { + for (const task of tasks) { if (task.name === TaskName.Config && task.hasSynthesizer) { /* if they change synthesizer settings don't try to precache */ break;