mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-08-01 20:12:11 +00:00
fix issue with wrong body class being applied on load
This commit is contained in:
parent
b1307a64dd
commit
27e690b35f
1 changed files with 13 additions and 1 deletions
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
/* @ngInject */
|
||||
function Projects(LS_DEFAULTS, $localStorage, $rootScope, Uid, $window, SimpleToast) {
|
||||
const OMITTED_LS_FIELDS = ['currentProject', 'projects', '$$hashKey', '$$mdSelectId'];
|
||||
const OMITTED_LS_FIELDS = ['currentProject', 'projects', '$$hashKey', '$$mdSelectId', 'bodyClass'];
|
||||
|
||||
this.getList = () => {
|
||||
return $localStorage.projects;
|
||||
|
|
@ -91,6 +91,16 @@
|
|||
}
|
||||
};
|
||||
|
||||
this.removeOmittedFields = (newCurrentProject) => {
|
||||
if (newCurrentProject) {
|
||||
for (let property in newCurrentProject.data) {
|
||||
if (newCurrentProject.data.hasOwnProperty(property) && OMITTED_LS_FIELDS.indexOf(property) > -1) {
|
||||
delete newCurrentProject.data[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$rootScope.$watch('r.currentProject', (newCurrentProject, oldCurrentProject) => {
|
||||
if (newCurrentProject && newCurrentProject.id) {
|
||||
// when there is an old current project existing
|
||||
|
|
@ -100,6 +110,8 @@
|
|||
}
|
||||
// update with new model fields, if we change the model
|
||||
this.updateNewFields(newCurrentProject);
|
||||
// remove omitted fields if we saved them for some reason
|
||||
this.removeOmittedFields(newCurrentProject);
|
||||
|
||||
// update $rootScope data and ls for current project
|
||||
$rootScope.r.currentProject = $localStorage.currentProject = newCurrentProject;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue