firefish/src/client/app/store.ts

461 lines
12 KiB
TypeScript
Raw Normal View History

2019-06-21 08:08:17 +02:00
import Vue from 'vue';
2018-04-29 10:17:15 +02:00
import Vuex from 'vuex';
2018-05-20 19:13:39 +02:00
import createPersistedState from 'vuex-persistedstate';
import * as nestedProperty from 'nested-property';
2018-05-20 19:13:39 +02:00
2018-04-29 14:37:51 +02:00
import MiOS from './mios';
2018-09-06 17:02:55 +02:00
import { erase } from '../../prelude/array';
2018-10-19 07:34:51 +02:00
import getNoteSummary from '../../misc/get-note-summary';
2018-04-29 10:17:15 +02:00
const defaultSettings = {
keepCw: false,
tagTimelines: [],
2018-04-29 10:17:15 +02:00
fetchOnScroll: true,
remainDeletedNote: false,
2018-04-29 10:17:15 +02:00
showPostFormOnTopOfTl: false,
2018-08-16 23:03:03 +02:00
suggestRecentHashtags: true,
showClockOnHeader: true,
2018-04-29 10:17:15 +02:00
circleIcons: true,
contrastedAcct: true,
showFullAcct: false,
showVia: true,
2018-04-29 10:17:15 +02:00
showReplyTarget: true,
showMyRenotes: true,
showRenotedMyNotes: true,
2018-08-16 16:59:22 +02:00
showLocalRenotes: true,
loadRemoteMedia: true,
2018-05-27 15:39:20 +02:00
disableViaMobile: false,
2018-06-18 10:25:20 +02:00
memo: null,
iLikeSushi: false,
rememberNoteVisibility: false,
defaultNoteVisibility: 'public',
2019-04-17 07:30:31 +02:00
wallpaper: null,
webSearchEngine: 'https://www.google.com/?#q={{query}}',
mutedWords: [],
2019-06-07 13:34:05 +02:00
gamesReversiShowBoardLabels: false,
gamesReversiUseAvatarStones: true,
2019-06-12 06:47:58 +02:00
disableAnimatedMfm: false,
homeProfiles: {},
mobileHomeProfiles: {},
deckProfiles: {},
uploadFolder: null,
pastedFileName: 'yyyy-MM-dd HH-mm-ss [{{number}}]',
pasteDialog: false,
2018-04-29 10:17:15 +02:00
};
2018-05-20 19:13:39 +02:00
const defaultDeviceSettings = {
2019-06-21 08:08:17 +02:00
homeProfile: 'Default',
mobileHomeProfile: 'Default',
deckProfile: 'Default',
deckMode: false,
deckColumnAlign: 'center',
deckColumnWidth: 'normal',
2019-02-26 06:28:38 +01:00
useShadow: false,
roundedCorners: true,
2018-09-16 14:40:48 +02:00
reduceMotion: false,
2019-02-26 06:28:38 +01:00
darkmode: true,
2019-03-17 12:48:55 +01:00
darkTheme: 'bb5a8287-a072-4b0a-8ae5-ea2a0d33f4f2',
2018-09-28 17:01:11 +02:00
lightTheme: 'light',
lineWidth: 1,
fontSize: 0,
2018-09-28 17:01:11 +02:00
themes: [],
2018-05-20 19:13:39 +02:00
enableSounds: true,
soundVolume: 0.5,
mediaVolume: 0.5,
2018-05-20 19:13:39 +02:00
lang: null,
2019-04-19 04:07:54 +02:00
appTypeForce: 'auto',
2018-05-20 19:13:39 +02:00
debug: false,
lightmode: false,
loadRawImages: false,
alwaysShowNsfw: false,
2018-09-05 06:47:26 +02:00
postStyle: 'standard',
2018-10-14 12:44:30 +02:00
navbar: 'top',
mobileNotificationPosition: 'bottom',
useOsDefaultEmojis: false,
disableShowingAnimatedImages: false,
expandUsersPhotos: true,
expandUsersActivity: true,
2019-07-27 22:25:12 +02:00
enableMobileQuickNotificationView: false,
MisskeyRoom (#5267) * wip * Add pemcil * Fix bug * Update .gitattributes * Add :custard: * Better :custard: * Add color boxes * Add pc * Add keyboard * Add :package: * Add more :package: * :v: * carpet * Add plant * :v: * :v: * Update room.vue * Add plant * :v: * :v: * :v: * :v: * :v: * 段ボール箱がてかりすぎているのを修正 * Update room.ts * Render username * :v: * Add new :package: * Update room.ts * Remove blender backup files * Refactor * Improve performance * Update room.ts * Update .gitattributes * Update room.ts * Better fan * Better tissue rendering * Add :penguin: * Create photoframe2.glb * chairs * Add :book: * fix: HiDPi環境でオブジェクトを選択できない (#5268) * Better monitor * :v: * Add corkboard * Add missing blend * mousepad * Add missing blend * Add cube * 額縁やモニターなどに任意の画像を表示できるように * Update MisskeyRoom section of CONTRIBUTING.md (#5272) * Update MisskeyRoom section of CONTRIBUTING.md * Update CONTRIBUTING.md * Update CONTRIBUTING.md * Refactor * カスタムテクスチャがずれないように * Remove debug code * Update furnitures.json5 * 一部の家具の色を自由に変えられるように * Update ja-JP.yml * Type annotation * 家具の色やテクスチャをすぐ反映するように * Update room.vue * Update furnitures.json5 * Add :tv: * Update ja-JP.yml * 床の色を変えられるように * 和室にできるように * Update washitsu * Use MeshLambertMaterial to improve performance * Use MeshLambertMaterial * Fix bug * Refactor * Update room.ts * Fix washitsu * Update room.vue * Update washistu * Use MeshLambertMaterial * Update room.ts * Set current property value * Disable reactivity to improve performance a bit * Fix bug * Set current carpet color * Update ja-JP.yml * Add rubik-cube (#5278) * Update ja-JP.yml (#5279) * Update UI * ルームの設定を追加 * Add room link * 家具をドラッグで移動や回転できるように * esnextにする (#5286) * Fix moduleResolution * Use uuid v4 * Fix bug * マットの色を変えられるように * :v: * 異方性フィルタリングするように * グラフィックの品質をフィルタリングに反映 * Add bloom effect when ultra graphics * Add posters * :art:
2019-08-18 07:41:33 +02:00
roomGraphicsQuality: 'medium',
roomUseOrthographicCamera: true,
2018-05-20 19:13:39 +02:00
};
2018-04-29 10:17:15 +02:00
export default (os: MiOS) => new Vuex.Store({
2018-05-27 06:49:09 +02:00
plugins: [createPersistedState({
paths: ['i', 'device', 'settings']
2018-05-20 19:13:39 +02:00
})],
2018-04-29 10:17:15 +02:00
state: {
2018-05-27 06:49:09 +02:00
i: null,
2018-05-17 16:53:55 +02:00
indicate: false,
uiHeaderHeight: 0,
2018-10-19 07:34:51 +02:00
behindNotes: []
2018-04-29 10:17:15 +02:00
},
2018-05-27 06:49:09 +02:00
getters: {
2019-06-21 08:08:17 +02:00
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],
2018-05-27 06:49:09 +02:00
},
2018-04-29 10:17:15 +02:00
mutations: {
2018-05-27 06:49:09 +02:00
updateI(state, x) {
state.i = x;
},
updateIKeyValue(state, x) {
state.i[x.key] = x.value;
},
2018-05-17 16:53:55 +02:00
indicate(state, x) {
state.indicate = x;
},
2018-04-29 10:17:15 +02:00
setUiHeaderHeight(state, height) {
state.uiHeaderHeight = height;
},
2018-10-19 07:34:51 +02:00
pushBehindNote(state, note) {
if (note.userId === state.i.id) return;
if (state.behindNotes.some(n => n.id === note.id)) return;
state.behindNotes.push(note);
document.title = `(${state.behindNotes.length}) ${getNoteSummary(note)}`;
},
clearBehindNotes(state) {
state.behindNotes = [];
document.title = os.instanceName;
2019-06-21 08:08:17 +02:00
},
setHome(state, data) {
Vue.set(state.settings.homeProfiles, state.device.homeProfile, data);
os.store.dispatch('settings/updateHomeProfile');
},
2019-06-21 08:11:56 +02:00
setDeck(state, data) {
Vue.set(state.settings.deckProfiles, state.device.deckProfile, data);
os.store.dispatch('settings/updateDeckProfile');
},
2019-06-21 08:08:17 +02:00
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');
2018-04-29 10:17:15 +02:00
}
},
2018-05-27 06:49:09 +02:00
actions: {
login(ctx, i) {
ctx.commit('updateI', i);
Use PostgreSQL instead of MongoDB (#4572) * wip * Update note.ts * Update timeline.ts * Update core.ts * wip * Update generate-visibility-query.ts * wip * wip * wip * wip * wip * Update global-timeline.ts * wip * wip * wip * Update vote.ts * wip * wip * Update create.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update files.ts * wip * wip * Update CONTRIBUTING.md * wip * wip * wip * wip * wip * wip * wip * wip * Update read-notification.ts * wip * wip * wip * wip * wip * wip * wip * Update cancel.ts * wip * wip * wip * Update show.ts * wip * wip * Update gen-id.ts * Update create.ts * Update id.ts * wip * wip * wip * wip * wip * wip * wip * Docker: Update files about Docker (#4599) * Docker: Use cache if files used by `yarn install` was not updated This patch reduces the number of times to installing node_modules. For example, `yarn install` step will be skipped when only ".config/default.yml" is updated. * Docker: Migrate MongoDB to Postgresql Misskey uses Postgresql as a database instead of Mongodb since version 11. * Docker: Uncomment about data persistence This patch will save a lot of databases. * wip * wip * wip * Update activitypub.ts * wip * wip * wip * Update logs.ts * wip * Update drive-file.ts * Update register.ts * wip * wip * Update mentions.ts * wip * wip * wip * Update recommendation.ts * wip * Update index.ts * wip * Update recommendation.ts * Doc: Update docker.ja.md and docker.en.md (#1) (#4608) Update how to set up misskey. * wip * :v: * wip * Update note.ts * Update postgre.ts * wip * wip * wip * wip * Update add-file.ts * wip * wip * wip * Clean up * Update logs.ts * wip * :pizza: * wip * Ad notes * wip * Update api-visibility.ts * Update note.ts * Update add-file.ts * tests * tests * Update postgre.ts * Update utils.ts * wip * wip * Refactor * wip * Refactor * wip * wip * Update show-users.ts * Update update-instance.ts * wip * Update feed.ts * Update outbox.ts * Update outbox.ts * Update user.ts * wip * Update list.ts * Update update-hashtag.ts * wip * Update update-hashtag.ts * Refactor * Update update.ts * wip * wip * :v: * clean up * docs * Update push.ts * wip * Update api.ts * wip * :v: * Update make-pagination-query.ts * :v: * Delete hashtags.ts * Update instances.ts * Update instances.ts * Update create.ts * Update search.ts * Update reversi-game.ts * Update signup.ts * Update user.ts * id * Update example.yml * :art: * objectid * fix * reversi * reversi * Fix bug of chart engine * Add test of chart engine * Improve test * Better testing * Improve chart engine * Refactor * Add test of chart engine * Refactor * Add chart test * Fix bug * コミットし忘れ * Refactoring * :v: * Add tests * Add test * Extarct note tests * Refactor * 存在しないユーザーにメンションできなくなっていた問題を修正 * Fix bug * Update update-meta.ts * Fix bug * Update mention.vue * Fix bug * Update meta.ts * Update CONTRIBUTING.md * Fix bug * Fix bug * Fix bug * Clean up * Clean up * Update notification.ts * Clean up * Add mute tests * Add test * Refactor * Add test * Fix test * Refactor * Refactor * Add tests * Update utils.ts * Update utils.ts * Fix test * Update package.json * Update update.ts * Update manifest.ts * Fix bug * Fix bug * Add test * :art: * Update endpoint permissions * Updaye permisison * Update person.ts #4299 * データベースと同期しないように * Fix bug * Fix bug * Update reversi-game.ts * Use a feature of Node v11.7.0 to extract a public key (#4644) * wip * wip * :v: * Refactoring #1540 * test * test * test * test * test * test * test * Fix bug * Fix test * :sushi: * wip * #4471 * Add test for #4335 * Refactor * Fix test * Add tests * :clock4: * Fix bug * Add test * Add test * rename * Fix bug
2019-04-07 14:50:36 +02:00
ctx.dispatch('settings/merge', i.clientData);
2018-05-27 06:49:09 +02:00
},
logout(ctx) {
ctx.commit('updateI', null);
document.cookie = `i=; max-age=0; domain=${document.location.hostname}`;
2018-11-28 08:19:02 +01:00
localStorage.removeItem('i');
2018-05-27 06:49:09 +02:00
},
mergeMe(ctx, me) {
for (const [key, value] of Object.entries(me)) {
2018-05-27 06:49:09 +02:00
ctx.commit('updateIKeyValue', { key, value });
}
2018-05-27 06:49:09 +02:00
Use PostgreSQL instead of MongoDB (#4572) * wip * Update note.ts * Update timeline.ts * Update core.ts * wip * Update generate-visibility-query.ts * wip * wip * wip * wip * wip * Update global-timeline.ts * wip * wip * wip * Update vote.ts * wip * wip * Update create.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update files.ts * wip * wip * Update CONTRIBUTING.md * wip * wip * wip * wip * wip * wip * wip * wip * Update read-notification.ts * wip * wip * wip * wip * wip * wip * wip * Update cancel.ts * wip * wip * wip * Update show.ts * wip * wip * Update gen-id.ts * Update create.ts * Update id.ts * wip * wip * wip * wip * wip * wip * wip * Docker: Update files about Docker (#4599) * Docker: Use cache if files used by `yarn install` was not updated This patch reduces the number of times to installing node_modules. For example, `yarn install` step will be skipped when only ".config/default.yml" is updated. * Docker: Migrate MongoDB to Postgresql Misskey uses Postgresql as a database instead of Mongodb since version 11. * Docker: Uncomment about data persistence This patch will save a lot of databases. * wip * wip * wip * Update activitypub.ts * wip * wip * wip * Update logs.ts * wip * Update drive-file.ts * Update register.ts * wip * wip * Update mentions.ts * wip * wip * wip * Update recommendation.ts * wip * Update index.ts * wip * Update recommendation.ts * Doc: Update docker.ja.md and docker.en.md (#1) (#4608) Update how to set up misskey. * wip * :v: * wip * Update note.ts * Update postgre.ts * wip * wip * wip * wip * Update add-file.ts * wip * wip * wip * Clean up * Update logs.ts * wip * :pizza: * wip * Ad notes * wip * Update api-visibility.ts * Update note.ts * Update add-file.ts * tests * tests * Update postgre.ts * Update utils.ts * wip * wip * Refactor * wip * Refactor * wip * wip * Update show-users.ts * Update update-instance.ts * wip * Update feed.ts * Update outbox.ts * Update outbox.ts * Update user.ts * wip * Update list.ts * Update update-hashtag.ts * wip * Update update-hashtag.ts * Refactor * Update update.ts * wip * wip * :v: * clean up * docs * Update push.ts * wip * Update api.ts * wip * :v: * Update make-pagination-query.ts * :v: * Delete hashtags.ts * Update instances.ts * Update instances.ts * Update create.ts * Update search.ts * Update reversi-game.ts * Update signup.ts * Update user.ts * id * Update example.yml * :art: * objectid * fix * reversi * reversi * Fix bug of chart engine * Add test of chart engine * Improve test * Better testing * Improve chart engine * Refactor * Add test of chart engine * Refactor * Add chart test * Fix bug * コミットし忘れ * Refactoring * :v: * Add tests * Add test * Extarct note tests * Refactor * 存在しないユーザーにメンションできなくなっていた問題を修正 * Fix bug * Update update-meta.ts * Fix bug * Update mention.vue * Fix bug * Update meta.ts * Update CONTRIBUTING.md * Fix bug * Fix bug * Fix bug * Clean up * Clean up * Update notification.ts * Clean up * Add mute tests * Add test * Refactor * Add test * Fix test * Refactor * Refactor * Add tests * Update utils.ts * Update utils.ts * Fix test * Update package.json * Update update.ts * Update manifest.ts * Fix bug * Fix bug * Add test * :art: * Update endpoint permissions * Updaye permisison * Update person.ts #4299 * データベースと同期しないように * Fix bug * Fix bug * Update reversi-game.ts * Use a feature of Node v11.7.0 to extract a public key (#4644) * wip * wip * :v: * Refactoring #1540 * test * test * test * test * test * test * test * Fix bug * Fix test * :sushi: * wip * #4471 * Add test for #4335 * Refactor * Fix test * Add tests * :clock4: * Fix bug * Add test * Add test * rename * Fix bug
2019-04-07 14:50:36 +02:00
if (me.clientData) {
ctx.dispatch('settings/merge', me.clientData);
2018-05-27 06:49:09 +02:00
}
},
},
2018-04-29 10:17:15 +02:00
modules: {
2018-05-20 19:13:39 +02:00
device: {
namespaced: true,
state: defaultDeviceSettings,
mutations: {
set(state, x: { key: string; value: any }) {
state[x.key] = x.value;
2018-05-26 17:18:44 +02:00
},
setTl(state, x) {
state.tl = {
src: x.src,
arg: x.arg
};
2018-08-17 09:35:04 +02:00
},
setVisibility(state, visibility) {
state.visibility = visibility;
2018-06-05 22:18:08 +02:00
},
}
},
2018-04-29 10:17:15 +02:00
settings: {
namespaced: true,
2018-04-29 10:17:15 +02:00
state: defaultSettings,
2018-06-05 22:18:08 +02:00
mutations: {
set(state, x: { key: string; value: any }) {
nestedProperty.set(state, x.key, x.value);
},
},
actions: {
merge(ctx, settings) {
if (settings == null) return;
for (const [key, value] of Object.entries(settings)) {
ctx.commit('set', { key, value });
}
},
set(ctx, x) {
ctx.commit('set', x);
2018-06-05 22:18:08 +02:00
if (ctx.rootGetters.isSignedIn) {
2019-04-18 14:36:44 +02:00
os.api('i/update-client-setting', {
name: x.key,
value: x.value
});
}
2018-06-06 23:13:57 +02:00
},
updateHomeProfile(ctx) {
const profiles = ctx.state.homeProfiles;
ctx.commit('set', {
key: 'homeProfiles',
value: profiles
});
os.api('i/update-client-setting', {
name: 'homeProfiles',
value: profiles
});
},
updateMobileHomeProfile(ctx) {
const profiles = ctx.state.mobileHomeProfiles;
ctx.commit('set', {
key: 'mobileHomeProfiles',
value: profiles
});
os.api('i/update-client-setting', {
name: 'mobileHomeProfiles',
value: profiles
});
},
updateDeckProfile(ctx) {
const profiles = ctx.state.deckProfiles;
ctx.commit('set', {
key: 'deckProfiles',
value: profiles
});
os.api('i/update-client-setting', {
name: 'deckProfiles',
value: profiles
});
},
2018-04-29 10:17:15 +02:00
}
}
}
});