Skip to content

Commit 3faa2f8

Browse files
authored
Merge pull request #74 from NenoR96/losingdata
prevent losing data and fix corrupted instances
2 parents a53593a + 32857d7 commit 3faa2f8

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/control/content/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
}
8282

8383
if (result && result.data && !angular.equals({}, result.data) && result.id) {
84+
if(!result.data.design) result.data.design = $scope.data.design;
8485
$scope.data = result.data;
8586
$scope.id = result.id;
8687
if($scope.data.content && $scope.data.content.carouselImages)
@@ -142,6 +143,9 @@
142143
return;
143144
}
144145

146+
if(!newObj.content || !newObj.design)
147+
return;
148+
145149
buildfire.datastore.save(newObj, function (err, result) {
146150
if (err || !result) {
147151
console.error('Error saving the widget details: ', err);

src/control/design/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
}
7474

7575
if (result && result.data && !angular.equals({}, result.data)) {
76+
if(!result.data.design) result.data.design = $scope.data.design;
7677
$scope.data = result.data;
7778
$scope.id = result.id;
7879
}
@@ -111,6 +112,9 @@
111112
return;
112113
}
113114

115+
if(!newObj.content || !newObj.design)
116+
return;
117+
114118
buildfire.datastore.save(newObj, function (err, result) {
115119
if (err || !result) {
116120
console.error('Error saving the widget details: ', err);

src/widget/widget.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ function init() {
5454
state.data = result.data && result.data.content
5555
? result.data
5656
: defaultData;
57+
!state.data.design ? state.data.design = defaultData.design : null;
5758
render();
5859
});
5960

6061
// Keep state up to date with control changes
6162
buildfire.datastore.onUpdate((result) => {
6263
state.data = result.data;
64+
!state.data.design ? state.data.design = defaultData.design : null;
6365
render();
6466
});
6567
}

0 commit comments

Comments
 (0)