Improve sync

This commit is contained in:
syuilo
2019-06-21 15:08:17 +09:00
parent 26f4c038f3
commit aec5911821
9 changed files with 262 additions and 255 deletions

View File

@@ -84,6 +84,7 @@ import XWelcome from '../pages/welcome.vue';
export default Vue.extend({
i18n: i18n('desktop/views/components/home.vue'),
components: {
XDraggable,
XWelcome
@@ -102,11 +103,7 @@ export default Vue.extend({
computed: {
home(): any[] {
if (this.$store.getters.isSignedIn) {
if (this.$store.state.device.homeProfile) {
return this.$store.state.settings.homeProfiles[this.$store.state.device.homeProfile] || this.$store.state.device.home || [];
} else {
return this.$store.state.device.home || [];
}
return this.$store.getters.home || [];
} else {
return [{
name: 'instance',
@@ -142,7 +139,9 @@ export default Vue.extend({
},
created() {
if (this.$store.getters.isSignedIn) {
if (!this.$store.getters.isSignedIn) return;
if (this.$store.getters.home == null) {
const defaultDesktopHomeWidgets = {
left: [
'profile',
@@ -187,17 +186,7 @@ export default Vue.extend({
}
//#endregion
if (this.$store.state.device.home == null) {
this.$store.commit('device/setHome', _defaultDesktopHomeWidgets);
}
if (this.$store.state.device.homeProfile) {
this.$watch('$store.state.device.home', () => {
this.$store.dispatch('settings/updateHomeProfile');
}, {
deep: true
});
}
this.$store.commit('setHome', _defaultDesktopHomeWidgets);
}
},
@@ -235,7 +224,7 @@ export default Vue.extend({
},
addWidget() {
this.$store.commit('device/addHomeWidget', {
this.$store.commit('addHomeWidget', {
name: this.widgetAdderSelected,
id: uuid(),
place: 'left',
@@ -246,7 +235,7 @@ export default Vue.extend({
saveHome() {
const left = this.widgets.left;
const right = this.widgets.right;
this.$store.commit('device/setHome', left.concat(right));
this.$store.commit('setHome', left.concat(right));
for (const w of left) w.place = 'left';
for (const w of right) w.place = 'right';
},