Improve sync
This commit is contained in:
@@ -72,17 +72,13 @@ export default Vue.extend({
|
||||
|
||||
computed: {
|
||||
widgets(): any[] {
|
||||
if (this.$store.state.device.mobileHomeProfile) {
|
||||
return this.$store.state.settings.mobileHomeProfiles[this.$store.state.device.mobileHomeProfile] || this.$store.state.device.mobileHome;
|
||||
} else {
|
||||
return this.$store.state.device.mobileHome;
|
||||
}
|
||||
return this.$store.getters.mobileHome || [];
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.widgets.length == 0) {
|
||||
this.$store.commit('device/setMobileHome', [{
|
||||
this.$store.commit('setMobileHome', [{
|
||||
name: 'calendar',
|
||||
id: 'a', data: {}
|
||||
}, {
|
||||
@@ -103,13 +99,11 @@ export default Vue.extend({
|
||||
}]);
|
||||
}
|
||||
|
||||
if (this.$store.state.device.mobileHomeProfile) {
|
||||
this.$watch('$store.state.device.mobileHome', () => {
|
||||
this.$store.dispatch('settings/updateMobileHomeProfile');
|
||||
}, {
|
||||
deep: true
|
||||
});
|
||||
}
|
||||
this.$watch('$store.getters.mobileHome', () => {
|
||||
this.$store.dispatch('settings/updateMobileHomeProfile');
|
||||
}, {
|
||||
deep: true
|
||||
});
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@@ -134,7 +128,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
addWidget() {
|
||||
this.$store.commit('device/addMobileHomeWidget', {
|
||||
this.$store.commit('addMobileHomeWidget', {
|
||||
name: this.widgetAdderSelected,
|
||||
id: uuid(),
|
||||
data: {}
|
||||
@@ -142,11 +136,11 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
removeWidget(widget) {
|
||||
this.$store.commit('device/removeMobileHomeWidget', widget);
|
||||
this.$store.commit('removeMobileHomeWidget', widget);
|
||||
},
|
||||
|
||||
saveHome() {
|
||||
this.$store.commit('device/setMobileHome', this.widgets);
|
||||
this.$store.commit('setMobileHome', this.widgets);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user