Files: 9c5fb9afa9248c901294db9eac5e350da9bc055d / app / sync / initialise / settings.js
1326 bytesRaw
1 | const nest = require('depnest') |
2 | const merge = require('lodash/merge') |
3 | const fs = require('fs') |
4 | const { join } = require('path') |
5 | |
6 | exports.gives = nest('app.sync.initialise') |
7 | |
8 | exports.needs = nest({ |
9 | 'settings.sync.set': 'first', |
10 | 'settings.sync.get': 'first' |
11 | }) |
12 | |
13 | const defaults = { |
14 | patchbay: { |
15 | defaultTabs: ['/posts', '/inbox', '/notifications'], |
16 | accessibility: { |
17 | invert: false, |
18 | saturation: 100, |
19 | brightness: 100, |
20 | contrast: 100 |
21 | }, |
22 | customStyles: defaultStyles(), |
23 | pubHopConnections: 3 // all |
24 | }, |
25 | filter: { |
26 | exclude: { |
27 | channels: '' |
28 | }, |
29 | only: { |
30 | peopleIFollow: false |
31 | }, |
32 | show: { |
33 | post: true, |
34 | vote: false, // a.k.a. like |
35 | about: true, |
36 | contact: false, |
37 | channel: false, |
38 | pub: false, |
39 | chess: false |
40 | } |
41 | } |
42 | } |
43 | |
44 | exports.create = function (api) { |
45 | return nest('app.sync.initialise', initialiseSettings) |
46 | |
47 | function initialiseSettings () { |
48 | const { get, set } = api.settings.sync |
49 | const settings = merge({}, defaults, get()) |
50 | settings.filter.defaults = defaults.filter |
51 | |
52 | set(settings) |
53 | } |
54 | } |
55 | |
56 | function defaultStyles () { |
57 | // TODO add a nice little helper README / comments |
58 | const path = join(__dirname, '../../styles/mcss/app-theme-vars.mcss') |
59 | const styles = fs.readFileSync(path, 'utf8') |
60 | return styles |
61 | } |
62 |
Built with git-ssb-web