Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
feat(settings): new structure and saved as settings.json
Browse files Browse the repository at this point in the history
  • Loading branch information
herteleo committed Apr 20, 2019
1 parent 34ba2bf commit b42e171
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/store/modules/Settings.js
@@ -1,11 +1,33 @@
import Connection from '@/db';

const db = new Connection({
file: 'settings.json',
defaults: {
'dimmer.dimDelayInMs': 5000,
'dimmer.dimIfWindowIsNotInFocus': false,
'layout.sideBarLocation': 'left',
'notifications.holdBackIfWindowIsNotInFocus': false,
'notifications.sendSummaryIfWindowIsNotInFocus': false,
'notifications.summaryIntervalInMs': 1200000,
'window.muteAudioIfWindowIsNotInFocus': false,
},
});

export default {
namespaced: true,
state: {
isDimActive: false,
isLayoutInverted: false,
muteOnWindowBlur: false,
dbUpdated: Date.now(),
},
getters: {
all({ dbUpdated }) {
return db(dbUpdated).value();
},
byKey({ dbUpdated }) {
return key => db(dbUpdated).get(key).value();
},
isDimActive({ isDimActive }) {
return isDimActive;
},
Expand All @@ -26,7 +48,14 @@ export default {
setMuteOnWindowBlur(state, yesNo) {
state.muteOnWindowBlur = yesNo;
},
triggerDbUpdate(state) {
state.dbUpdated = Date.now();
},
},
actions: {
set({ commit }, [key, value]) {
db().set(key, value).write();
commit('triggerDbUpdate');
},
},
};

0 comments on commit b42e171

Please sign in to comment.