forked from FoundKeyGang/FoundKey
Improve sync
This commit is contained in:
parent
26f4c038f3
commit
aec5911821
9 changed files with 262 additions and 255 deletions
|
@ -60,9 +60,9 @@ export default function <T extends object>(data: {
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
if (this.platform == 'deck') {
|
if (this.platform == 'deck') {
|
||||||
this.$store.commit('device/updateDeckColumn', this.column);
|
this.$store.commit('updateDeckColumn', this.column);
|
||||||
} else {
|
} else {
|
||||||
this.$store.commit('device/updateWidget', this.widget);
|
this.$store.commit('updateWidget', this.widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,8 +133,8 @@
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<header>{{ $t('@._settings.sync') }}</header>
|
<header>{{ $t('@._settings.sync') }}</header>
|
||||||
<ui-input v-if="$root.isMobile" v-model="homeProfile">{{ $t('@._settings.home-profile') }}</ui-input>
|
<ui-input v-if="$root.isMobile" v-model="mobileHomeProfile">{{ $t('@._settings.home-profile') }}</ui-input>
|
||||||
<ui-input v-else v-model="mobileHomeProfile">{{ $t('@._settings.home-profile') }}</ui-input>
|
<ui-input v-else v-model="homeProfile">{{ $t('@._settings.home-profile') }}</ui-input>
|
||||||
<ui-input v-model="deckProfile">{{ $t('@._settings.deck-profile') }}</ui-input>
|
<ui-input v-model="deckProfile">{{ $t('@._settings.deck-profile') }}</ui-input>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -180,50 +180,50 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
}).then(({ canceled, result: name }) => {
|
}).then(({ canceled, result: name }) => {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
this.$store.commit('device/renameDeckColumn', { id: this.column.id, name });
|
this.$store.commit('renameDeckColumn', { id: this.column.id, name });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, null, {
|
}, null, {
|
||||||
icon: 'arrow-left',
|
icon: 'arrow-left',
|
||||||
text: this.$t('swap-left'),
|
text: this.$t('swap-left'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/swapLeftDeckColumn', this.column.id);
|
this.$store.commit('swapLeftDeckColumn', this.column.id);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: 'arrow-right',
|
icon: 'arrow-right',
|
||||||
text: this.$t('swap-right'),
|
text: this.$t('swap-right'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/swapRightDeckColumn', this.column.id);
|
this.$store.commit('swapRightDeckColumn', this.column.id);
|
||||||
}
|
}
|
||||||
}, this.isStacked ? {
|
}, this.isStacked ? {
|
||||||
icon: faArrowUp,
|
icon: faArrowUp,
|
||||||
text: this.$t('swap-up'),
|
text: this.$t('swap-up'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/swapUpDeckColumn', this.column.id);
|
this.$store.commit('swapUpDeckColumn', this.column.id);
|
||||||
}
|
}
|
||||||
} : undefined, this.isStacked ? {
|
} : undefined, this.isStacked ? {
|
||||||
icon: faArrowDown,
|
icon: faArrowDown,
|
||||||
text: this.$t('swap-down'),
|
text: this.$t('swap-down'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/swapDownDeckColumn', this.column.id);
|
this.$store.commit('swapDownDeckColumn', this.column.id);
|
||||||
}
|
}
|
||||||
} : undefined, null, {
|
} : undefined, null, {
|
||||||
icon: ['far', 'window-restore'],
|
icon: ['far', 'window-restore'],
|
||||||
text: this.$t('stack-left'),
|
text: this.$t('stack-left'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/stackLeftDeckColumn', this.column.id);
|
this.$store.commit('stackLeftDeckColumn', this.column.id);
|
||||||
}
|
}
|
||||||
}, this.isStacked ? {
|
}, this.isStacked ? {
|
||||||
icon: faWindowMaximize,
|
icon: faWindowMaximize,
|
||||||
text: this.$t('pop-right'),
|
text: this.$t('pop-right'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/popRightDeckColumn', this.column.id);
|
this.$store.commit('popRightDeckColumn', this.column.id);
|
||||||
}
|
}
|
||||||
} : undefined, null, {
|
} : undefined, null, {
|
||||||
icon: ['far', 'trash-alt'],
|
icon: ['far', 'trash-alt'],
|
||||||
text: this.$t('remove'),
|
text: this.$t('remove'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/removeDeckColumn', this.column.id);
|
this.$store.commit('removeDeckColumn', this.column.id);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
const id = e.dataTransfer.getData('mk-deck-column');
|
const id = e.dataTransfer.getData('mk-deck-column');
|
||||||
if (id != null && id != '') {
|
if (id != null && id != '') {
|
||||||
this.$store.commit('device/swapDeckColumn', {
|
this.$store.commit('swapDeckColumn', {
|
||||||
a: this.column.id,
|
a: this.column.id,
|
||||||
b: id
|
b: id
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,7 +90,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onChangeSettings(v) {
|
onChangeSettings(v) {
|
||||||
this.$store.commit('device/updateDeckColumn', this.column);
|
this.$store.commit('updateDeckColumn', this.column);
|
||||||
},
|
},
|
||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
|
|
|
@ -32,11 +32,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
deck() {
|
deck() {
|
||||||
if (this.$store.state.device.deckProfile) {
|
return this.$store.getters.deck;
|
||||||
return this.$store.state.settings.deckProfiles[this.$store.state.device.deckProfile] || this.$store.state.device.deck;
|
|
||||||
} else {
|
|
||||||
return this.$store.state.device.deck;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
columns(): any[] {
|
columns(): any[] {
|
||||||
|
@ -115,14 +111,6 @@ export default Vue.extend({
|
||||||
value: deck
|
value: deck
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.$store.state.device.deckProfile) {
|
|
||||||
this.$watch('$store.state.device.deck', () => {
|
|
||||||
this.$store.dispatch('settings/updateDeckProfile');
|
|
||||||
}, {
|
|
||||||
deep: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -146,7 +134,7 @@ export default Vue.extend({
|
||||||
icon: 'home',
|
icon: 'home',
|
||||||
text: this.$t('@deck.home'),
|
text: this.$t('@deck.home'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'home'
|
type: 'home'
|
||||||
});
|
});
|
||||||
|
@ -155,7 +143,7 @@ export default Vue.extend({
|
||||||
icon: ['far', 'comments'],
|
icon: ['far', 'comments'],
|
||||||
text: this.$t('@deck.local'),
|
text: this.$t('@deck.local'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'local'
|
type: 'local'
|
||||||
});
|
});
|
||||||
|
@ -164,7 +152,7 @@ export default Vue.extend({
|
||||||
icon: 'share-alt',
|
icon: 'share-alt',
|
||||||
text: this.$t('@deck.hybrid'),
|
text: this.$t('@deck.hybrid'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'hybrid'
|
type: 'hybrid'
|
||||||
});
|
});
|
||||||
|
@ -173,7 +161,7 @@ export default Vue.extend({
|
||||||
icon: 'globe',
|
icon: 'globe',
|
||||||
text: this.$t('@deck.global'),
|
text: this.$t('@deck.global'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'global'
|
type: 'global'
|
||||||
});
|
});
|
||||||
|
@ -182,7 +170,7 @@ export default Vue.extend({
|
||||||
icon: 'at',
|
icon: 'at',
|
||||||
text: this.$t('@deck.mentions'),
|
text: this.$t('@deck.mentions'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'mentions'
|
type: 'mentions'
|
||||||
});
|
});
|
||||||
|
@ -191,7 +179,7 @@ export default Vue.extend({
|
||||||
icon: ['far', 'envelope'],
|
icon: ['far', 'envelope'],
|
||||||
text: this.$t('@deck.direct'),
|
text: this.$t('@deck.direct'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'direct'
|
type: 'direct'
|
||||||
});
|
});
|
||||||
|
@ -212,7 +200,7 @@ export default Vue.extend({
|
||||||
showCancelButton: true
|
showCancelButton: true
|
||||||
});
|
});
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'list',
|
type: 'list',
|
||||||
list: lists.find(l => l.id === listId)
|
list: lists.find(l => l.id === listId)
|
||||||
|
@ -227,7 +215,7 @@ export default Vue.extend({
|
||||||
input: true
|
input: true
|
||||||
}).then(({ canceled, result: title }) => {
|
}).then(({ canceled, result: title }) => {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'hashtag',
|
type: 'hashtag',
|
||||||
tagTlId: this.$store.state.settings.tagTimelines.find(x => x.title == title).id
|
tagTlId: this.$store.state.settings.tagTimelines.find(x => x.title == title).id
|
||||||
|
@ -238,7 +226,7 @@ export default Vue.extend({
|
||||||
icon: ['far', 'bell'],
|
icon: ['far', 'bell'],
|
||||||
text: this.$t('@deck.notifications'),
|
text: this.$t('@deck.notifications'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'notifications'
|
type: 'notifications'
|
||||||
});
|
});
|
||||||
|
@ -247,7 +235,7 @@ export default Vue.extend({
|
||||||
icon: 'calculator',
|
icon: 'calculator',
|
||||||
text: this.$t('@deck.widgets'),
|
text: this.$t('@deck.widgets'),
|
||||||
action: () => {
|
action: () => {
|
||||||
this.$store.commit('device/addDeckColumn', {
|
this.$store.commit('addDeckColumn', {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
type: 'widgets',
|
type: 'widgets',
|
||||||
widgets: []
|
widgets: []
|
||||||
|
|
|
@ -110,7 +110,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
addWidget() {
|
addWidget() {
|
||||||
this.$store.commit('device/addDeckWidget', {
|
this.$store.commit('addDeckWidget', {
|
||||||
id: this.column.id,
|
id: this.column.id,
|
||||||
widget: {
|
widget: {
|
||||||
name: this.widgetAdderSelected,
|
name: this.widgetAdderSelected,
|
||||||
|
@ -123,14 +123,14 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
removeWidget(widget) {
|
removeWidget(widget) {
|
||||||
this.$store.commit('device/removeDeckWidget', {
|
this.$store.commit('removeDeckWidget', {
|
||||||
id: this.column.id,
|
id: this.column.id,
|
||||||
widget
|
widget
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
saveWidgets() {
|
saveWidgets() {
|
||||||
this.$store.commit('device/updateDeckColumn', this.column);
|
this.$store.commit('updateDeckColumn', this.column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -84,6 +84,7 @@ import XWelcome from '../pages/welcome.vue';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
i18n: i18n('desktop/views/components/home.vue'),
|
i18n: i18n('desktop/views/components/home.vue'),
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
XDraggable,
|
XDraggable,
|
||||||
XWelcome
|
XWelcome
|
||||||
|
@ -102,11 +103,7 @@ export default Vue.extend({
|
||||||
computed: {
|
computed: {
|
||||||
home(): any[] {
|
home(): any[] {
|
||||||
if (this.$store.getters.isSignedIn) {
|
if (this.$store.getters.isSignedIn) {
|
||||||
if (this.$store.state.device.homeProfile) {
|
return this.$store.getters.home || [];
|
||||||
return this.$store.state.settings.homeProfiles[this.$store.state.device.homeProfile] || this.$store.state.device.home || [];
|
|
||||||
} else {
|
|
||||||
return this.$store.state.device.home || [];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return [{
|
return [{
|
||||||
name: 'instance',
|
name: 'instance',
|
||||||
|
@ -142,7 +139,9 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
if (this.$store.getters.isSignedIn) {
|
if (!this.$store.getters.isSignedIn) return;
|
||||||
|
|
||||||
|
if (this.$store.getters.home == null) {
|
||||||
const defaultDesktopHomeWidgets = {
|
const defaultDesktopHomeWidgets = {
|
||||||
left: [
|
left: [
|
||||||
'profile',
|
'profile',
|
||||||
|
@ -187,17 +186,7 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
if (this.$store.state.device.home == null) {
|
this.$store.commit('setHome', _defaultDesktopHomeWidgets);
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -235,7 +224,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
addWidget() {
|
addWidget() {
|
||||||
this.$store.commit('device/addHomeWidget', {
|
this.$store.commit('addHomeWidget', {
|
||||||
name: this.widgetAdderSelected,
|
name: this.widgetAdderSelected,
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
place: 'left',
|
place: 'left',
|
||||||
|
@ -246,7 +235,7 @@ export default Vue.extend({
|
||||||
saveHome() {
|
saveHome() {
|
||||||
const left = this.widgets.left;
|
const left = this.widgets.left;
|
||||||
const right = this.widgets.right;
|
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 left) w.place = 'left';
|
||||||
for (const w of right) w.place = 'right';
|
for (const w of right) w.place = 'right';
|
||||||
},
|
},
|
||||||
|
|
|
@ -72,17 +72,13 @@ export default Vue.extend({
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
widgets(): any[] {
|
widgets(): any[] {
|
||||||
if (this.$store.state.device.mobileHomeProfile) {
|
return this.$store.getters.mobileHome || [];
|
||||||
return this.$store.state.settings.mobileHomeProfiles[this.$store.state.device.mobileHomeProfile] || this.$store.state.device.mobileHome;
|
|
||||||
} else {
|
|
||||||
return this.$store.state.device.mobileHome;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
if (this.widgets.length == 0) {
|
if (this.widgets.length == 0) {
|
||||||
this.$store.commit('device/setMobileHome', [{
|
this.$store.commit('setMobileHome', [{
|
||||||
name: 'calendar',
|
name: 'calendar',
|
||||||
id: 'a', data: {}
|
id: 'a', data: {}
|
||||||
}, {
|
}, {
|
||||||
|
@ -103,13 +99,11 @@ export default Vue.extend({
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.$store.state.device.mobileHomeProfile) {
|
this.$watch('$store.getters.mobileHome', () => {
|
||||||
this.$watch('$store.state.device.mobileHome', () => {
|
this.$store.dispatch('settings/updateMobileHomeProfile');
|
||||||
this.$store.dispatch('settings/updateMobileHomeProfile');
|
}, {
|
||||||
}, {
|
deep: true
|
||||||
deep: true
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -134,7 +128,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
addWidget() {
|
addWidget() {
|
||||||
this.$store.commit('device/addMobileHomeWidget', {
|
this.$store.commit('addMobileHomeWidget', {
|
||||||
name: this.widgetAdderSelected,
|
name: this.widgetAdderSelected,
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
data: {}
|
data: {}
|
||||||
|
@ -142,11 +136,11 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
removeWidget(widget) {
|
removeWidget(widget) {
|
||||||
this.$store.commit('device/removeMobileHomeWidget', widget);
|
this.$store.commit('removeMobileHomeWidget', widget);
|
||||||
},
|
},
|
||||||
|
|
||||||
saveHome() {
|
saveHome() {
|
||||||
this.$store.commit('device/setMobileHome', this.widgets);
|
this.$store.commit('setMobileHome', this.widgets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import Vue from 'vue';
|
||||||
import Vuex from 'vuex';
|
import Vuex from 'vuex';
|
||||||
import createPersistedState from 'vuex-persistedstate';
|
import createPersistedState from 'vuex-persistedstate';
|
||||||
import * as nestedProperty from 'nested-property';
|
import * as nestedProperty from 'nested-property';
|
||||||
|
@ -40,12 +41,9 @@ const defaultSettings = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultDeviceSettings = {
|
const defaultDeviceSettings = {
|
||||||
home: null,
|
homeProfile: 'Default',
|
||||||
homeProfile: null,
|
mobileHomeProfile: 'Default',
|
||||||
mobileHomeProfile: null,
|
deckProfile: 'Default',
|
||||||
mobileHome: [],
|
|
||||||
deck: null,
|
|
||||||
deckProfile: null,
|
|
||||||
deckMode: false,
|
deckMode: false,
|
||||||
deckColumnAlign: 'center',
|
deckColumnAlign: 'center',
|
||||||
deckColumnWidth: 'normal',
|
deckColumnWidth: 'normal',
|
||||||
|
@ -88,7 +86,13 @@ export default (os: MiOS) => new Vuex.Store({
|
||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
isSignedIn: state => state.i != null
|
isSignedIn: state => state.i != null,
|
||||||
|
|
||||||
|
home: state => state.settings.homeProfiles[state.device.homeProfile],
|
||||||
|
|
||||||
|
mobileHome: state => state.settings.mobileHomeProfiles[state.device.mobileHomeProfile],
|
||||||
|
|
||||||
|
deck: state => state.settings.deckProfiles[state.device.deckProfile],
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
|
@ -118,6 +122,211 @@ export default (os: MiOS) => new Vuex.Store({
|
||||||
clearBehindNotes(state) {
|
clearBehindNotes(state) {
|
||||||
state.behindNotes = [];
|
state.behindNotes = [];
|
||||||
document.title = os.instanceName;
|
document.title = os.instanceName;
|
||||||
|
},
|
||||||
|
|
||||||
|
setHome(state, data) {
|
||||||
|
Vue.set(state.settings.homeProfiles, state.device.homeProfile, data);
|
||||||
|
os.store.dispatch('settings/updateHomeProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
addHomeWidget(state, widget) {
|
||||||
|
state.settings.homeProfiles[state.device.homeProfile].unshift(widget);
|
||||||
|
os.store.dispatch('settings/updateHomeProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
setMobileHome(state, data) {
|
||||||
|
Vue.set(state.settings.mobileHomeProfiles, state.device.mobileHomeProfile, data);
|
||||||
|
os.store.dispatch('settings/updateMobileHomeProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
updateWidget(state, x) {
|
||||||
|
let w;
|
||||||
|
|
||||||
|
//#region Desktop home
|
||||||
|
const home = state.settings.homeProfiles[state.device.homeProfile];
|
||||||
|
if (home) {
|
||||||
|
w = home.find(w => w.id == x.id);
|
||||||
|
if (w) {
|
||||||
|
w.data = x.data;
|
||||||
|
os.store.dispatch('settings/updateHomeProfile');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region Mobile home
|
||||||
|
const mobileHome = state.settings.mobileHomeProfiles[state.device.mobileHomeProfile];
|
||||||
|
if (mobileHome) {
|
||||||
|
w = mobileHome.find(w => w.id == x.id);
|
||||||
|
if (w) {
|
||||||
|
w.data = x.data;
|
||||||
|
os.store.dispatch('settings/updateMobileHomeProfile');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
},
|
||||||
|
|
||||||
|
addMobileHomeWidget(state, widget) {
|
||||||
|
state.settings.mobileHomeProfiles[state.device.mobileHomeProfile].unshift(widget);
|
||||||
|
os.store.dispatch('settings/updateMobileHomeProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
removeMobileHomeWidget(state, widget) {
|
||||||
|
Vue.set('state.settings.mobileHomeProfiles', state.device.mobileHomeProfile, state.settings.mobileHomeProfiles[state.device.mobileHomeProfile].filter(w => w.id != widget.id));
|
||||||
|
os.store.dispatch('settings/updateMobileHomeProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
addDeckColumn(state, column) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
if (column.name == undefined) column.name = null;
|
||||||
|
deck.columns.push(column);
|
||||||
|
deck.layout.push([column.id]);
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
removeDeckColumn(state, id) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
deck.columns = deck.columns.filter(c => c.id != id);
|
||||||
|
deck.layout = deck.layout.map(ids => erase(id, ids));
|
||||||
|
deck.layout = deck.layout.filter(ids => ids.length > 0);
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
swapDeckColumn(state, x) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
const a = x.a;
|
||||||
|
const b = x.b;
|
||||||
|
const aX = deck.layout.findIndex(ids => ids.indexOf(a) != -1);
|
||||||
|
const aY = deck.layout[aX].findIndex(id => id == a);
|
||||||
|
const bX = deck.layout.findIndex(ids => ids.indexOf(b) != -1);
|
||||||
|
const bY = deck.layout[bX].findIndex(id => id == b);
|
||||||
|
deck.layout[aX][aY] = b;
|
||||||
|
deck.layout[bX][bY] = a;
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
swapLeftDeckColumn(state, id) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
deck.layout.some((ids, i) => {
|
||||||
|
if (ids.indexOf(id) != -1) {
|
||||||
|
const left = deck.layout[i - 1];
|
||||||
|
if (left) {
|
||||||
|
// https://vuejs.org/v2/guide/list.html#Caveats
|
||||||
|
//state.deck.layout[i - 1] = state.deck.layout[i];
|
||||||
|
//state.deck.layout[i] = left;
|
||||||
|
deck.layout.splice(i - 1, 1, deck.layout[i]);
|
||||||
|
deck.layout.splice(i, 1, left);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
swapRightDeckColumn(state, id) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
deck.layout.some((ids, i) => {
|
||||||
|
if (ids.indexOf(id) != -1) {
|
||||||
|
const right = deck.layout[i + 1];
|
||||||
|
if (right) {
|
||||||
|
// https://vuejs.org/v2/guide/list.html#Caveats
|
||||||
|
//state.deck.layout[i + 1] = state.deck.layout[i];
|
||||||
|
//state.deck.layout[i] = right;
|
||||||
|
deck.layout.splice(i + 1, 1, deck.layout[i]);
|
||||||
|
deck.layout.splice(i, 1, right);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
swapUpDeckColumn(state, id) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
const ids = deck.layout.find(ids => ids.indexOf(id) != -1);
|
||||||
|
ids.some((x, i) => {
|
||||||
|
if (x == id) {
|
||||||
|
const up = ids[i - 1];
|
||||||
|
if (up) {
|
||||||
|
// https://vuejs.org/v2/guide/list.html#Caveats
|
||||||
|
//ids[i - 1] = id;
|
||||||
|
//ids[i] = up;
|
||||||
|
ids.splice(i - 1, 1, id);
|
||||||
|
ids.splice(i, 1, up);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
swapDownDeckColumn(state, id) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
const ids = deck.layout.find(ids => ids.indexOf(id) != -1);
|
||||||
|
ids.some((x, i) => {
|
||||||
|
if (x == id) {
|
||||||
|
const down = ids[i + 1];
|
||||||
|
if (down) {
|
||||||
|
// https://vuejs.org/v2/guide/list.html#Caveats
|
||||||
|
//ids[i + 1] = id;
|
||||||
|
//ids[i] = down;
|
||||||
|
ids.splice(i + 1, 1, id);
|
||||||
|
ids.splice(i, 1, down);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
stackLeftDeckColumn(state, id) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
const i = deck.layout.findIndex(ids => ids.indexOf(id) != -1);
|
||||||
|
deck.layout = deck.layout.map(ids => erase(id, ids));
|
||||||
|
const left = deck.layout[i - 1];
|
||||||
|
if (left) deck.layout[i - 1].push(id);
|
||||||
|
deck.layout = deck.layout.filter(ids => ids.length > 0);
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
popRightDeckColumn(state, id) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
const i = deck.layout.findIndex(ids => ids.indexOf(id) != -1);
|
||||||
|
deck.layout = deck.layout.map(ids => erase(id, ids));
|
||||||
|
deck.layout.splice(i + 1, 0, [id]);
|
||||||
|
deck.layout = deck.layout.filter(ids => ids.length > 0);
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
addDeckWidget(state, x) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
const column = deck.columns.find(c => c.id == x.id);
|
||||||
|
if (column == null) return;
|
||||||
|
column.widgets.unshift(x.widget);
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
removeDeckWidget(state, x) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
const column = deck.columns.find(c => c.id == x.id);
|
||||||
|
if (column == null) return;
|
||||||
|
column.widgets = column.widgets.filter(w => w.id != x.widget.id);
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
renameDeckColumn(state, x) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
const column = deck.columns.find(c => c.id == x.id);
|
||||||
|
if (column == null) return;
|
||||||
|
column.name = x.name;
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
|
},
|
||||||
|
|
||||||
|
updateDeckColumn(state, x) {
|
||||||
|
const deck = state.settings.deckProfiles[state.device.deckProfile];
|
||||||
|
let column = deck.columns.find(c => c.id == x.id);
|
||||||
|
if (column == null) return;
|
||||||
|
column = x;
|
||||||
|
os.store.dispatch('settings/updateDeckProfile');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -165,176 +374,6 @@ export default (os: MiOS) => new Vuex.Store({
|
||||||
setVisibility(state, visibility) {
|
setVisibility(state, visibility) {
|
||||||
state.visibility = visibility;
|
state.visibility = visibility;
|
||||||
},
|
},
|
||||||
|
|
||||||
setHome(state, data) {
|
|
||||||
state.home = data;
|
|
||||||
},
|
|
||||||
|
|
||||||
addHomeWidget(state, widget) {
|
|
||||||
state.home.unshift(widget);
|
|
||||||
},
|
|
||||||
|
|
||||||
setMobileHome(state, data) {
|
|
||||||
state.mobileHome = data;
|
|
||||||
},
|
|
||||||
|
|
||||||
updateWidget(state, x) {
|
|
||||||
let w;
|
|
||||||
|
|
||||||
//#region Desktop home
|
|
||||||
if (state.home) {
|
|
||||||
w = state.home.find(w => w.id == x.id);
|
|
||||||
if (w) {
|
|
||||||
w.data = x.data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
//#region Mobile home
|
|
||||||
if (state.mobileHome) {
|
|
||||||
w = state.mobileHome.find(w => w.id == x.id);
|
|
||||||
if (w) {
|
|
||||||
w.data = x.data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//#endregion
|
|
||||||
},
|
|
||||||
|
|
||||||
addMobileHomeWidget(state, widget) {
|
|
||||||
state.mobileHome.unshift(widget);
|
|
||||||
},
|
|
||||||
|
|
||||||
removeMobileHomeWidget(state, widget) {
|
|
||||||
state.mobileHome = state.mobileHome.filter(w => w.id != widget.id);
|
|
||||||
},
|
|
||||||
|
|
||||||
addDeckColumn(state, column) {
|
|
||||||
if (column.name == undefined) column.name = null;
|
|
||||||
state.deck.columns.push(column);
|
|
||||||
state.deck.layout.push([column.id]);
|
|
||||||
},
|
|
||||||
|
|
||||||
removeDeckColumn(state, id) {
|
|
||||||
state.deck.columns = state.deck.columns.filter(c => c.id != id);
|
|
||||||
state.deck.layout = state.deck.layout.map(ids => erase(id, ids));
|
|
||||||
state.deck.layout = state.deck.layout.filter(ids => ids.length > 0);
|
|
||||||
},
|
|
||||||
|
|
||||||
swapDeckColumn(state, x) {
|
|
||||||
const a = x.a;
|
|
||||||
const b = x.b;
|
|
||||||
const aX = state.deck.layout.findIndex(ids => ids.indexOf(a) != -1);
|
|
||||||
const aY = state.deck.layout[aX].findIndex(id => id == a);
|
|
||||||
const bX = state.deck.layout.findIndex(ids => ids.indexOf(b) != -1);
|
|
||||||
const bY = state.deck.layout[bX].findIndex(id => id == b);
|
|
||||||
state.deck.layout[aX][aY] = b;
|
|
||||||
state.deck.layout[bX][bY] = a;
|
|
||||||
},
|
|
||||||
|
|
||||||
swapLeftDeckColumn(state, id) {
|
|
||||||
state.deck.layout.some((ids, i) => {
|
|
||||||
if (ids.indexOf(id) != -1) {
|
|
||||||
const left = state.deck.layout[i - 1];
|
|
||||||
if (left) {
|
|
||||||
// https://vuejs.org/v2/guide/list.html#Caveats
|
|
||||||
//state.deck.layout[i - 1] = state.deck.layout[i];
|
|
||||||
//state.deck.layout[i] = left;
|
|
||||||
state.deck.layout.splice(i - 1, 1, state.deck.layout[i]);
|
|
||||||
state.deck.layout.splice(i, 1, left);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
swapRightDeckColumn(state, id) {
|
|
||||||
state.deck.layout.some((ids, i) => {
|
|
||||||
if (ids.indexOf(id) != -1) {
|
|
||||||
const right = state.deck.layout[i + 1];
|
|
||||||
if (right) {
|
|
||||||
// https://vuejs.org/v2/guide/list.html#Caveats
|
|
||||||
//state.deck.layout[i + 1] = state.deck.layout[i];
|
|
||||||
//state.deck.layout[i] = right;
|
|
||||||
state.deck.layout.splice(i + 1, 1, state.deck.layout[i]);
|
|
||||||
state.deck.layout.splice(i, 1, right);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
swapUpDeckColumn(state, id) {
|
|
||||||
const ids = state.deck.layout.find(ids => ids.indexOf(id) != -1);
|
|
||||||
ids.some((x, i) => {
|
|
||||||
if (x == id) {
|
|
||||||
const up = ids[i - 1];
|
|
||||||
if (up) {
|
|
||||||
// https://vuejs.org/v2/guide/list.html#Caveats
|
|
||||||
//ids[i - 1] = id;
|
|
||||||
//ids[i] = up;
|
|
||||||
ids.splice(i - 1, 1, id);
|
|
||||||
ids.splice(i, 1, up);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
swapDownDeckColumn(state, id) {
|
|
||||||
const ids = state.deck.layout.find(ids => ids.indexOf(id) != -1);
|
|
||||||
ids.some((x, i) => {
|
|
||||||
if (x == id) {
|
|
||||||
const down = ids[i + 1];
|
|
||||||
if (down) {
|
|
||||||
// https://vuejs.org/v2/guide/list.html#Caveats
|
|
||||||
//ids[i + 1] = id;
|
|
||||||
//ids[i] = down;
|
|
||||||
ids.splice(i + 1, 1, id);
|
|
||||||
ids.splice(i, 1, down);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
stackLeftDeckColumn(state, id) {
|
|
||||||
const i = state.deck.layout.findIndex(ids => ids.indexOf(id) != -1);
|
|
||||||
state.deck.layout = state.deck.layout.map(ids => erase(id, ids));
|
|
||||||
const left = state.deck.layout[i - 1];
|
|
||||||
if (left) state.deck.layout[i - 1].push(id);
|
|
||||||
state.deck.layout = state.deck.layout.filter(ids => ids.length > 0);
|
|
||||||
},
|
|
||||||
|
|
||||||
popRightDeckColumn(state, id) {
|
|
||||||
const i = state.deck.layout.findIndex(ids => ids.indexOf(id) != -1);
|
|
||||||
state.deck.layout = state.deck.layout.map(ids => erase(id, ids));
|
|
||||||
state.deck.layout.splice(i + 1, 0, [id]);
|
|
||||||
state.deck.layout = state.deck.layout.filter(ids => ids.length > 0);
|
|
||||||
},
|
|
||||||
|
|
||||||
addDeckWidget(state, x) {
|
|
||||||
const column = state.deck.columns.find(c => c.id == x.id);
|
|
||||||
if (column == null) return;
|
|
||||||
column.widgets.unshift(x.widget);
|
|
||||||
},
|
|
||||||
|
|
||||||
removeDeckWidget(state, x) {
|
|
||||||
const column = state.deck.columns.find(c => c.id == x.id);
|
|
||||||
if (column == null) return;
|
|
||||||
column.widgets = column.widgets.filter(w => w.id != x.widget.id);
|
|
||||||
},
|
|
||||||
|
|
||||||
renameDeckColumn(state, x) {
|
|
||||||
const column = state.deck.columns.find(c => c.id == x.id);
|
|
||||||
if (column == null) return;
|
|
||||||
column.name = x.name;
|
|
||||||
},
|
|
||||||
|
|
||||||
updateDeckColumn(state, x) {
|
|
||||||
let column = state.deck.columns.find(c => c.id == x.id);
|
|
||||||
if (column == null) return;
|
|
||||||
column = x;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -370,7 +409,6 @@ export default (os: MiOS) => new Vuex.Store({
|
||||||
|
|
||||||
updateHomeProfile(ctx) {
|
updateHomeProfile(ctx) {
|
||||||
const profiles = ctx.state.homeProfiles;
|
const profiles = ctx.state.homeProfiles;
|
||||||
profiles[ctx.rootState.device.homeProfile] = ctx.rootState.device.home;
|
|
||||||
ctx.commit('set', {
|
ctx.commit('set', {
|
||||||
key: 'homeProfiles',
|
key: 'homeProfiles',
|
||||||
value: profiles
|
value: profiles
|
||||||
|
@ -383,7 +421,6 @@ export default (os: MiOS) => new Vuex.Store({
|
||||||
|
|
||||||
updateMobileHomeProfile(ctx) {
|
updateMobileHomeProfile(ctx) {
|
||||||
const profiles = ctx.state.mobileHomeProfiles;
|
const profiles = ctx.state.mobileHomeProfiles;
|
||||||
profiles[ctx.rootState.device.mobileHomeProfile] = ctx.rootState.device.mobileHome;
|
|
||||||
ctx.commit('set', {
|
ctx.commit('set', {
|
||||||
key: 'mobileHomeProfiles',
|
key: 'mobileHomeProfiles',
|
||||||
value: profiles
|
value: profiles
|
||||||
|
@ -396,7 +433,6 @@ export default (os: MiOS) => new Vuex.Store({
|
||||||
|
|
||||||
updateDeckProfile(ctx) {
|
updateDeckProfile(ctx) {
|
||||||
const profiles = ctx.state.deckProfiles;
|
const profiles = ctx.state.deckProfiles;
|
||||||
profiles[ctx.rootState.device.deckProfile] = ctx.rootState.device.deck;
|
|
||||||
ctx.commit('set', {
|
ctx.commit('set', {
|
||||||
key: 'deckProfiles',
|
key: 'deckProfiles',
|
||||||
value: profiles
|
value: profiles
|
||||||
|
|
Loading…
Reference in a new issue