2020-10-17 13:12:00 +02:00
|
|
|
import { createStore } from 'vuex';
|
2020-01-29 20:37:25 +01:00
|
|
|
import createPersistedState from 'vuex-persistedstate';
|
|
|
|
import * as nestedProperty from 'nested-property';
|
2020-10-17 13:12:00 +02:00
|
|
|
import { api } from '@/os';
|
2020-07-11 03:13:11 +02:00
|
|
|
import { erase } from '../prelude/array';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2020-05-06 02:40:07 +02:00
|
|
|
export const defaultSettings = {
|
2020-02-09 13:31:17 +01:00
|
|
|
tutorial: 0,
|
2020-01-29 20:37:25 +01:00
|
|
|
keepCw: false,
|
|
|
|
showFullAcct: false,
|
|
|
|
rememberNoteVisibility: false,
|
|
|
|
defaultNoteVisibility: 'public',
|
2020-02-08 12:02:15 +01:00
|
|
|
defaultNoteLocalOnly: false,
|
2020-01-29 20:37:25 +01:00
|
|
|
uploadFolder: null,
|
|
|
|
pastedFileName: 'yyyy-MM-dd HH-mm-ss [{{number}}]',
|
|
|
|
memo: null,
|
|
|
|
reactions: ['👍', '❤️', '😆', '🤔', '😮', '🎉', '💢', '😥', '😇', '🍮'],
|
2020-07-27 06:34:20 +02:00
|
|
|
mutedWords: [],
|
2020-02-09 23:23:43 +01:00
|
|
|
};
|
|
|
|
|
2020-05-06 04:41:44 +02:00
|
|
|
export const defaultDeviceUserSettings = {
|
2020-02-09 23:23:43 +01:00
|
|
|
visibility: 'public',
|
|
|
|
localOnly: false,
|
|
|
|
widgets: [],
|
|
|
|
tl: {
|
|
|
|
src: 'home'
|
|
|
|
},
|
2020-05-06 04:41:44 +02:00
|
|
|
menu: [
|
|
|
|
'notifications',
|
|
|
|
'messaging',
|
|
|
|
'drive',
|
|
|
|
'-',
|
|
|
|
'followRequests',
|
|
|
|
'featured',
|
|
|
|
'explore',
|
|
|
|
'announcements',
|
|
|
|
'search',
|
2020-07-11 03:13:11 +02:00
|
|
|
'-',
|
2020-11-03 09:00:47 +01:00
|
|
|
'ui',
|
2020-05-06 04:41:44 +02:00
|
|
|
],
|
2020-07-11 03:13:11 +02:00
|
|
|
deck: {
|
|
|
|
columns: [],
|
|
|
|
layout: [],
|
|
|
|
},
|
2020-07-28 12:02:28 +02:00
|
|
|
plugins: [] as {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
|
|
|
active: boolean;
|
|
|
|
configData: Record<string, any>;
|
|
|
|
token: string;
|
|
|
|
ast: any[];
|
|
|
|
}[],
|
2020-01-29 20:37:25 +01:00
|
|
|
};
|
|
|
|
|
2020-05-06 04:41:44 +02:00
|
|
|
export const defaultDeviceSettings = {
|
2020-01-29 20:37:25 +01:00
|
|
|
lang: null,
|
|
|
|
loadRawImages: false,
|
2020-11-25 13:31:34 +01:00
|
|
|
nsfw: 'respect', // respect, force, ignore
|
2020-02-12 19:11:37 +01:00
|
|
|
useOsNativeEmojis: false,
|
2020-08-19 14:47:18 +02:00
|
|
|
serverDisconnectedBehavior: 'quiet',
|
2020-01-29 20:37:25 +01:00
|
|
|
accounts: [],
|
2020-11-08 04:08:07 +01:00
|
|
|
recentlyUsedEmojis: [],
|
2020-11-08 04:40:56 +01:00
|
|
|
recentlyUsedUsers: [],
|
2020-01-29 20:37:25 +01:00
|
|
|
themes: [],
|
2020-10-19 07:50:57 +02:00
|
|
|
darkTheme: '8050783a-7f63-445a-b270-36d0f6ba1677',
|
2020-03-22 02:39:12 +01:00
|
|
|
lightTheme: '4eea646f-7afa-4645-83e9-83af0333cd37',
|
|
|
|
darkMode: false,
|
2020-07-11 03:13:11 +02:00
|
|
|
deckMode: false,
|
2020-03-22 02:39:12 +01:00
|
|
|
syncDeviceDarkMode: true,
|
2020-02-06 11:11:14 +01:00
|
|
|
animation: true,
|
2020-02-13 15:20:12 +01:00
|
|
|
animatedMfm: true,
|
2020-02-16 14:46:18 +01:00
|
|
|
imageNewTab: false,
|
2020-10-17 13:12:00 +02:00
|
|
|
chatOpenBehavior: 'page',
|
2020-10-24 18:21:41 +02:00
|
|
|
defaultSideView: false,
|
|
|
|
deckNavWindow: true,
|
2020-02-18 19:16:10 +01:00
|
|
|
showFixedPostForm: false,
|
2020-10-17 13:12:00 +02:00
|
|
|
disablePagesScript: false,
|
2020-05-31 05:53:06 +02:00
|
|
|
enableInfiniteScroll: true,
|
2020-07-12 11:14:59 +02:00
|
|
|
useBlurEffectForModal: true,
|
2020-11-07 02:43:27 +01:00
|
|
|
useFullReactionPicker: false,
|
2020-11-18 04:09:14 +01:00
|
|
|
reactionPickerWidth: 1,
|
|
|
|
reactionPickerHeight: 1,
|
2020-08-01 03:53:23 +02:00
|
|
|
sidebarDisplay: 'full', // full, icon, hide
|
2020-10-27 08:16:59 +01:00
|
|
|
instanceTicker: 'remote', // none, remote, always
|
2020-05-09 08:47:20 +02:00
|
|
|
roomGraphicsQuality: 'medium',
|
|
|
|
roomUseOrthographicCamera: true,
|
2020-07-11 03:13:11 +02:00
|
|
|
deckColumnAlign: 'left',
|
|
|
|
deckAlwaysShowMainColumn: true,
|
|
|
|
deckMainColumnPlace: 'left',
|
2020-02-09 23:23:43 +01:00
|
|
|
userData: {},
|
2020-01-29 20:37:25 +01:00
|
|
|
};
|
|
|
|
|
2020-02-10 15:17:42 +01:00
|
|
|
function copy<T>(data: T): T {
|
2020-02-09 23:23:43 +01:00
|
|
|
return JSON.parse(JSON.stringify(data));
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export const postFormActions = [];
|
|
|
|
export const userActions = [];
|
|
|
|
export const noteActions = [];
|
|
|
|
export const noteViewInterruptors = [];
|
|
|
|
export const notePostInterruptors = [];
|
|
|
|
|
|
|
|
export const store = createStore({
|
|
|
|
strict: _DEV_,
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
plugins: [createPersistedState({
|
2020-02-10 15:17:42 +01:00
|
|
|
paths: ['i', 'device', 'deviceUser', 'settings', 'instance']
|
2020-01-29 20:37:25 +01:00
|
|
|
})],
|
|
|
|
|
|
|
|
state: {
|
|
|
|
i: null,
|
|
|
|
},
|
|
|
|
|
|
|
|
getters: {
|
|
|
|
isSignedIn: state => state.i != null,
|
|
|
|
},
|
|
|
|
|
|
|
|
mutations: {
|
|
|
|
updateI(state, x) {
|
|
|
|
state.i = x;
|
|
|
|
},
|
|
|
|
|
2020-07-11 17:38:55 +02:00
|
|
|
updateIKeyValue(state, { key, value }) {
|
|
|
|
state.i[key] = value;
|
|
|
|
},
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2020-02-09 23:23:43 +01:00
|
|
|
async login(ctx, i) {
|
2020-01-29 20:37:25 +01:00
|
|
|
ctx.commit('updateI', i);
|
2020-02-09 23:23:43 +01:00
|
|
|
ctx.commit('settings/init', i.clientData);
|
|
|
|
ctx.commit('deviceUser/init', ctx.state.device.userData[i.id] || {});
|
2020-07-11 17:01:55 +02:00
|
|
|
// TODO: ローカルストレージを消してページリロードしたときは i が無いのでその場合のハンドリングをよしなにやる
|
2020-02-09 23:23:43 +01:00
|
|
|
await ctx.dispatch('addAcount', { id: i.id, i: localStorage.getItem('i') });
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
addAcount(ctx, info) {
|
|
|
|
if (!ctx.state.device.accounts.some(x => x.id === info.id)) {
|
|
|
|
ctx.commit('device/set', {
|
|
|
|
key: 'accounts',
|
|
|
|
value: ctx.state.device.accounts.concat([{ id: info.id, token: info.i }])
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
logout(ctx) {
|
2020-02-09 23:23:43 +01:00
|
|
|
ctx.commit('device/setUserData', { userId: ctx.state.i.id, data: ctx.state.deviceUser });
|
2020-01-29 20:37:25 +01:00
|
|
|
ctx.commit('updateI', null);
|
2020-02-09 23:23:43 +01:00
|
|
|
ctx.commit('settings/init', {});
|
|
|
|
ctx.commit('deviceUser/init', {});
|
2020-01-29 20:37:25 +01:00
|
|
|
localStorage.removeItem('i');
|
2020-03-20 05:56:22 +01:00
|
|
|
document.cookie = `igi=; path=/`;
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
2020-02-09 23:23:43 +01:00
|
|
|
async switchAccount(ctx, i) {
|
|
|
|
ctx.commit('device/setUserData', { userId: ctx.state.i.id, data: ctx.state.deviceUser });
|
2020-01-29 20:37:25 +01:00
|
|
|
localStorage.setItem('i', i.token);
|
2020-02-09 23:23:43 +01:00
|
|
|
await ctx.dispatch('login', i);
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
mergeMe(ctx, me) {
|
2020-07-13 16:29:30 +02:00
|
|
|
// TODO: プロパティ一つ一つに対してコミットが発生するのはアレなので良い感じにする
|
2020-01-29 20:37:25 +01:00
|
|
|
for (const [key, value] of Object.entries(me)) {
|
|
|
|
ctx.commit('updateIKeyValue', { key, value });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (me.clientData) {
|
2020-02-09 23:23:43 +01:00
|
|
|
ctx.commit('settings/init', me.clientData);
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
modules: {
|
2020-02-10 15:17:42 +01:00
|
|
|
instance: {
|
|
|
|
namespaced: true,
|
|
|
|
|
|
|
|
state: {
|
|
|
|
meta: null
|
|
|
|
},
|
|
|
|
|
2020-11-07 02:43:27 +01:00
|
|
|
getters: {
|
|
|
|
emojiCategories: state => {
|
|
|
|
const categories = new Set();
|
|
|
|
for (const emoji of state.meta.emojis) {
|
|
|
|
categories.add(emoji.category);
|
|
|
|
}
|
|
|
|
return Array.from(categories);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-02-10 15:17:42 +01:00
|
|
|
mutations: {
|
|
|
|
set(state, meta) {
|
|
|
|
state.meta = meta;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
async fetch(ctx) {
|
2020-10-17 13:12:00 +02:00
|
|
|
const meta = await api('meta', {
|
|
|
|
detail: false
|
|
|
|
});
|
2020-02-10 15:17:42 +01:00
|
|
|
|
|
|
|
ctx.commit('set', meta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
device: {
|
|
|
|
namespaced: true,
|
|
|
|
|
|
|
|
state: defaultDeviceSettings,
|
|
|
|
|
|
|
|
mutations: {
|
2020-10-24 18:23:23 +02:00
|
|
|
overwrite(state, x) {
|
|
|
|
for (const k of Object.keys(state)) {
|
|
|
|
if (x[k] === undefined) delete state[k];
|
|
|
|
}
|
|
|
|
for (const k of Object.keys(x)) {
|
|
|
|
state[k] = x[k];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
set(state, x: { key: string; value: any }) {
|
|
|
|
state[x.key] = x.value;
|
|
|
|
},
|
|
|
|
|
2020-02-09 23:23:43 +01:00
|
|
|
setUserData(state, x: { userId: string; data: any }) {
|
|
|
|
state.userData[x.userId] = copy(x.data);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
deviceUser: {
|
|
|
|
namespaced: true,
|
|
|
|
|
|
|
|
state: defaultDeviceUserSettings,
|
|
|
|
|
|
|
|
mutations: {
|
2020-10-24 18:23:23 +02:00
|
|
|
overwrite(state, x) {
|
|
|
|
for (const k of Object.keys(state)) {
|
|
|
|
if (x[k] === undefined) delete state[k];
|
|
|
|
}
|
|
|
|
for (const k of Object.keys(x)) {
|
|
|
|
state[k] = x[k];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-09 23:23:43 +01:00
|
|
|
init(state, x) {
|
|
|
|
for (const [key, value] of Object.entries(defaultDeviceUserSettings)) {
|
2020-11-14 01:59:33 +01:00
|
|
|
if (Object.prototype.hasOwnProperty.call(x, key)) {
|
2020-02-09 23:23:43 +01:00
|
|
|
state[key] = x[key];
|
|
|
|
} else {
|
|
|
|
state[key] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
set(state, x: { key: string; value: any }) {
|
|
|
|
state[x.key] = x.value;
|
|
|
|
},
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
setTl(state, x) {
|
|
|
|
state.tl = {
|
|
|
|
src: x.src,
|
|
|
|
arg: x.arg
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2020-05-06 04:41:44 +02:00
|
|
|
setMenu(state, menu) {
|
|
|
|
state.menu = menu;
|
|
|
|
},
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
setVisibility(state, visibility) {
|
|
|
|
state.visibility = visibility;
|
|
|
|
},
|
2020-02-05 01:42:58 +01:00
|
|
|
|
|
|
|
setLocalOnly(state, localOnly) {
|
|
|
|
state.localOnly = localOnly;
|
|
|
|
},
|
2020-02-09 23:23:43 +01:00
|
|
|
|
|
|
|
setWidgets(state, widgets) {
|
|
|
|
state.widgets = widgets;
|
|
|
|
},
|
|
|
|
|
|
|
|
addWidget(state, widget) {
|
|
|
|
state.widgets.unshift(widget);
|
|
|
|
},
|
|
|
|
|
|
|
|
removeWidget(state, widget) {
|
|
|
|
state.widgets = state.widgets.filter(w => w.id != widget.id);
|
|
|
|
},
|
|
|
|
|
|
|
|
updateWidget(state, x) {
|
2020-04-04 01:46:54 +02:00
|
|
|
const w = state.widgets.find(w => w.id === x.id);
|
2020-02-09 23:23:43 +01:00
|
|
|
if (w) {
|
|
|
|
w.data = x.data;
|
|
|
|
}
|
|
|
|
},
|
2020-07-11 03:13:11 +02:00
|
|
|
|
|
|
|
//#region Deck
|
2020-12-05 04:50:09 +01:00
|
|
|
// TODO: deck関連は動的にモジュール読み込みしたい
|
2020-07-11 03:13:11 +02:00
|
|
|
addDeckColumn(state, column) {
|
|
|
|
if (column.name == undefined) column.name = null;
|
|
|
|
state.deck.columns.push(column);
|
|
|
|
state.deck.layout.push([column.id]);
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
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);
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
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;
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
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);
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
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);
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
addDeckWidget(state, x) {
|
|
|
|
const column = state.deck.columns.find(c => c.id == x.id);
|
|
|
|
if (column == null) return;
|
|
|
|
if (column.widgets == null) column.widgets = [];
|
|
|
|
column.widgets.unshift(x.widget);
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
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);
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-12-05 04:50:09 +01:00
|
|
|
setDeckWidgets(state, x) {
|
|
|
|
const column = state.deck.columns.find(c => c.id == x.id);
|
|
|
|
if (column == null) return;
|
|
|
|
column.widgets = x.widgets;
|
|
|
|
},
|
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
renameDeckColumn(state, x) {
|
|
|
|
const column = state.deck.columns.find(c => c.id == x.id);
|
|
|
|
if (column == null) return;
|
|
|
|
column.name = x.name;
|
|
|
|
},
|
2020-07-11 17:14:34 +02:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
updateDeckColumn(state, x) {
|
2020-12-05 04:50:09 +01:00
|
|
|
const column = state.deck.columns.findIndex(c => c.id == x.id);
|
|
|
|
if (column > -1) return;
|
|
|
|
state.deck.columns[column] = x;
|
2020-07-11 03:13:11 +02:00
|
|
|
},
|
|
|
|
//#endregion
|
2020-07-11 17:38:55 +02:00
|
|
|
|
2020-07-29 17:41:17 +02:00
|
|
|
installPlugin(state, { id, meta, ast, token }) {
|
2020-07-11 17:38:55 +02:00
|
|
|
state.plugins.push({
|
2020-07-18 07:28:32 +02:00
|
|
|
...meta,
|
2020-07-29 17:41:17 +02:00
|
|
|
id,
|
2020-07-28 12:02:28 +02:00
|
|
|
active: true,
|
2020-07-18 07:28:32 +02:00
|
|
|
configData: {},
|
|
|
|
token: token,
|
2020-07-11 17:38:55 +02:00
|
|
|
ast: ast
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
uninstallPlugin(state, id) {
|
|
|
|
state.plugins = state.plugins.filter(x => x.id != id);
|
|
|
|
},
|
2020-07-18 07:28:32 +02:00
|
|
|
|
|
|
|
configPlugin(state, { id, config }) {
|
|
|
|
state.plugins.find(p => p.id === id).configData = config;
|
|
|
|
},
|
2020-07-28 12:02:28 +02:00
|
|
|
|
|
|
|
changePluginActive(state, { id, active }) {
|
|
|
|
state.plugins.find(p => p.id === id).active = active;
|
|
|
|
},
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
settings: {
|
|
|
|
namespaced: true,
|
|
|
|
|
|
|
|
state: defaultSettings,
|
|
|
|
|
|
|
|
mutations: {
|
|
|
|
set(state, x: { key: string; value: any }) {
|
|
|
|
nestedProperty.set(state, x.key, x.value);
|
|
|
|
},
|
|
|
|
|
|
|
|
init(state, x) {
|
|
|
|
for (const [key, value] of Object.entries(defaultSettings)) {
|
2020-11-14 01:59:33 +01:00
|
|
|
if (Object.prototype.hasOwnProperty.call(x, key)) {
|
2020-01-29 20:37:25 +01:00
|
|
|
state[key] = x[key];
|
|
|
|
} else {
|
|
|
|
state[key] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
set(ctx, x) {
|
|
|
|
ctx.commit('set', x);
|
|
|
|
|
|
|
|
if (ctx.rootGetters.isSignedIn) {
|
2020-10-17 13:12:00 +02:00
|
|
|
api('i/update-client-setting', {
|
|
|
|
name: x.key,
|
|
|
|
value: x.value
|
|
|
|
});
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|