From 38c4a6a644348d5ffe760868ee095fccf60591b1 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 22 Jan 2023 23:12:21 -0500 Subject: [PATCH] refresh config on every response --- modules/_server.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/_server.js b/modules/_server.js index a66f9cb..ac3c702 100644 --- a/modules/_server.js +++ b/modules/_server.js @@ -37,13 +37,19 @@ app.get('/', (req, res) => { app.post('/', (req, response) => { if (req.body.start != undefined) { fn.commands.startup(); - response.render('index', { config: JSON.stringify(config) }); - return; + fn.commands.refreshConfig().then(res => { + config = res.config; + response.render('index', { config: JSON.stringify(config) }); + return; + }); } if (req.body.shutdown != undefined) { fn.commands.shutdown(); - response.render('index', { config: JSON.stringify(config) }); - return; + fn.commands.refreshConfig().then(res => { + config = res.config; + response.render('index', { config: JSON.stringify(config) }); + return; + }); } if (req.body.reload != undefined) { const updateAugerOffIntervalQuery = `UPDATE intervals SET value = '${2000 - req.body.feedRate}' WHERE key = 'auger_off'`; @@ -62,8 +68,11 @@ app.post('/', (req, response) => { } if (req.body.quit != undefined) { fn.commands.quit(); - response.render('index', { config: JSON.stringify(config) }); - return; + fn.commands.refreshConfig().then(res => { + config = res.config; + response.render('index', { config: JSON.stringify(config) }); + return; + }); } });