From 39178217ecf722fbd902e07a053e35fa290488f8 Mon Sep 17 00:00:00 2001 From: David Gay Date: Mon, 7 Jun 2021 21:24:02 -0400 Subject: Hook in new web worker stuff with finish activity POST retry stuff --- app/javascript/controllers/timer_controller.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/controllers/timer_controller.js b/app/javascript/controllers/timer_controller.js index f6ba4f3..1af1e10 100644 --- a/app/javascript/controllers/timer_controller.js +++ b/app/javascript/controllers/timer_controller.js @@ -38,13 +38,16 @@ export default class extends Controller { url: controller.postUrlValue, success: () => { this.postFailures = 0; + App.timerWorker.postMessage({ "set_timeout": 10 }); }, error: (e, xhr) => { this.postFailures++; if (this.postFailures < 3) { - setTimeout(controller.finishActivity, 1000); // 1 second - } else if (xhr === "") { - setTimeout(controller.finishActivity, 60000); // 1 minute + App.timerWorker.postMessage({ "run_flag": true }); + App.timerWorker.postMessage({ "set_timeout": 1000 }); + } else if (this.postFailures < 5 || xhr === "") { + App.timerWorker.postMessage({ "run_flag": true }); + App.timerWorker.postMessage({ "set_timeout": 60000 }); } }, }); -- cgit v1.2.3