Skip to content

Commit

Permalink
move state file to control
Browse files Browse the repository at this point in the history
  • Loading branch information
AliAlaqrabawi3 committed Jul 3, 2024
1 parent 90bae26 commit e2f001f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// eslint-disable-next-line no-unused-vars
const AppState = {
const ControlState = {
settings: null,
};
2 changes: 1 addition & 1 deletion src/control/content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<script src="../../../../scripts/sortable.min.js"></script>
<script src="../../../../scripts/buildfire/components/carousel/carousel.js"></script>

<script src="./controlState.js"></script>
<script src="../../widget/global/js/services/AuthManager.js"></script>
<script src="../../widget/global/js/AppState.js"></script>
<script src="../../widget/global/js/models/Setting.js"></script>
<script src="../../widget/global/js/repositories/Settings.js"></script>
<script src="../../widget/global/js/utils.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion src/control/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<script src="../../../../scripts/angular/angular.min.js"></script>
<script src="../../../../scripts/buildfire/services/searchEngine/searchEngine.js"></script>

<script src="../content/controlState.js"></script>
<script src="../../widget/global/js/services/AuthManager.js"></script>
<script src="../../widget/global/js/AppState.js"></script>
<script src="../../widget/global/js/models/Setting.js"></script>
<script src="../../widget/global/js/repositories/Settings.js"></script>
<script src="../../widget/global/js/repositories/Content.js"></script>
Expand Down
8 changes: 4 additions & 4 deletions src/widget/global/js/repositories/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand All @@ -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());
Expand Down

0 comments on commit e2f001f

Please sign in to comment.