From e2f001f4c4abb83e7a9f7d12bd1652c634efdc47 Mon Sep 17 00:00:00 2001 From: alialaqrabawi3 Date: Wed, 3 Jul 2024 21:14:11 +0300 Subject: [PATCH] move state file to control --- .../js/AppState.js => control/content/controlState.js} | 2 +- src/control/content/index.html | 2 +- src/control/settings/index.html | 2 +- src/widget/global/js/repositories/Settings.js | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) rename src/{widget/global/js/AppState.js => control/content/controlState.js} (74%) diff --git a/src/widget/global/js/AppState.js b/src/control/content/controlState.js similarity index 74% rename from src/widget/global/js/AppState.js rename to src/control/content/controlState.js index 3eacb01..a3224f0 100644 --- a/src/widget/global/js/AppState.js +++ b/src/control/content/controlState.js @@ -1,4 +1,4 @@ // eslint-disable-next-line no-unused-vars -const AppState = { +const ControlState = { settings: null, }; diff --git a/src/control/content/index.html b/src/control/content/index.html index 7eef3fa..3f7c7e9 100644 --- a/src/control/content/index.html +++ b/src/control/content/index.html @@ -14,8 +14,8 @@ + - diff --git a/src/control/settings/index.html b/src/control/settings/index.html index 8932370..65c089f 100644 --- a/src/control/settings/index.html +++ b/src/control/settings/index.html @@ -7,8 +7,8 @@ + - diff --git a/src/widget/global/js/repositories/Settings.js b/src/widget/global/js/repositories/Settings.js index e94d5f7..8340f26 100644 --- a/src/widget/global/js/repositories/Settings.js +++ b/src/widget/global/js/repositories/Settings.js @@ -21,12 +21,12 @@ class Settings { const data = new Setting().toJSON(); data.createdBy = currentUser?._id ? currentUser._id : ""; Settings.save(data).then(()=>{ - AppState.settings = data; + ControlState.settings = data; resolve(data); }) } else { const data = new Setting(res.data).toJSON(); - AppState.settings = data; + ControlState.settings = data; resolve(data); } }); @@ -42,8 +42,8 @@ class Settings { return new Promise((resolve, reject) => { const currentUser = AuthManager.currentUser; data.lastUpdatedBy = currentUser?._id ? currentUser._id : ""; - data.createdBy = data.createdBy || AppState.settings?.createdBy; - data.createdOn = AppState.settings?.createdOn || new Date(); + data.createdBy = data.createdBy || ControlState.settings?.createdBy; + data.createdOn = ControlState.settings?.createdOn || new Date(); buildfire.datastore.save(new Setting(data).toJSON(), Settings.TAG, (err, res) => { if (err) return reject(err); return resolve(new Setting(res.data).toJSON());