Files: f5f5076c7d11cfe178ddd244bae99d532ac55feb / app / sync / initialise / settings.js
1293 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 | }, |
24 | filter: { |
25 | exclude: { |
26 | channels: '' |
27 | }, |
28 | only: { |
29 | peopleIFollow: false |
30 | }, |
31 | show: { |
32 | post: true, |
33 | vote: false, // a.k.a. like |
34 | about: true, |
35 | contact: false, |
36 | channel: false, |
37 | pub: false, |
38 | chess: false |
39 | } |
40 | } |
41 | } |
42 | |
43 | exports.create = function (api) { |
44 | return nest('app.sync.initialise', initialiseSettings) |
45 | |
46 | function initialiseSettings () { |
47 | const { get, set } = api.settings.sync |
48 | const settings = merge({}, defaults, get()) |
49 | settings.filter.defaults = defaults.filter |
50 | |
51 | set(settings) |
52 | } |
53 | } |
54 | |
55 | function defaultStyles () { |
56 | // TODO add a nice little helper README / comments |
57 | const path = join(__dirname, '../../styles/mcss/app-theme-vars.mcss') |
58 | const styles = fs.readFileSync(path, 'utf8') |
59 | return styles |
60 | } |
61 |
Built with git-ssb-web