From 35a20479fedeac5da8bb8d79728086f4a2143270 Mon Sep 17 00:00:00 2001 From: Ro Date: Wed, 24 Jun 2020 15:19:54 -0700 Subject: [PATCH] found and fixed navigation order updating bug. whew. --- brain/data/Navigation.js | 29 ++++++++++++++++++++--------- src/com/controllers/NavIndex.js | 3 +-- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/brain/data/Navigation.js b/brain/data/Navigation.js index 995429d..1d1b55c 100644 --- a/brain/data/Navigation.js +++ b/brain/data/Navigation.js @@ -14,16 +14,27 @@ export default class Navigation { //-------------------------- sync(body) { return new Promise((resolve, reject) => { - let payload = body; - settings.menu = payload; let response = []; - fs.writeJson('site/settings.json', settings) - .then(() => { - response = { - type: DataEvent.SETTINGS_UPDATED, - message: 'Menu order saved, champ' - }; - resolve(response); + settings + .load(SETTINGS_FILE) + .then(settings => { + let payload = body; + settings.menu = payload; + fs.writeJson('site/settings.json', settings) + .then(() => { + response = { + type: DataEvent.SETTINGS_UPDATED, + message: 'Menu order saved, champ' + }; + resolve(response); + }) + .catch(err => { + response = { + type: DataEvent.REQUEST_LAME, + message: err + }; + reject(response); + }); }) .catch(err => { response = { diff --git a/src/com/controllers/NavIndex.js b/src/com/controllers/NavIndex.js index 9a38176..6bcc155 100644 --- a/src/com/controllers/NavIndex.js +++ b/src/com/controllers/NavIndex.js @@ -28,8 +28,7 @@ export default class NavIndex { REQUEST_TYPE_POST, CONTENT_TYPE_JSON, data - ).then(response => { - let r = response.response; + ).then(r => { if (r.type == DataEvent.MENU_UPDATED) { notify.alert(r.message, true); } else {