Skip to content

Commit

Permalink
Merge pull request #74 from NenoR96/losingdata
Browse files Browse the repository at this point in the history
prevent losing data and fix corrupted instances
  • Loading branch information
NenoR96 authored Jul 3, 2023
2 parents a53593a + 32857d7 commit 3faa2f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/control/content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
}

if (result && result.data && !angular.equals({}, result.data) && result.id) {
if(!result.data.design) result.data.design = $scope.data.design;
$scope.data = result.data;
$scope.id = result.id;
if($scope.data.content && $scope.data.content.carouselImages)
Expand Down Expand Up @@ -142,6 +143,9 @@
return;
}

if(!newObj.content || !newObj.design)
return;

buildfire.datastore.save(newObj, function (err, result) {
if (err || !result) {
console.error('Error saving the widget details: ', err);
Expand Down
4 changes: 4 additions & 0 deletions src/control/design/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
}

if (result && result.data && !angular.equals({}, result.data)) {
if(!result.data.design) result.data.design = $scope.data.design;
$scope.data = result.data;
$scope.id = result.id;
}
Expand Down Expand Up @@ -111,6 +112,9 @@
return;
}

if(!newObj.content || !newObj.design)
return;

buildfire.datastore.save(newObj, function (err, result) {
if (err || !result) {
console.error('Error saving the widget details: ', err);
Expand Down
2 changes: 2 additions & 0 deletions src/widget/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ function init() {
state.data = result.data && result.data.content
? result.data
: defaultData;
!state.data.design ? state.data.design = defaultData.design : null;
render();
});

// Keep state up to date with control changes
buildfire.datastore.onUpdate((result) => {
state.data = result.data;
!state.data.design ? state.data.design = defaultData.design : null;
render();
});
}
Expand Down

0 comments on commit 3faa2f8

Please sign in to comment.