git ssb

16+

Dominic / patchbay



Tree: c1a1dc7a8dc3f88bd242e418cb5715798385f4e4

Files: c1a1dc7a8dc3f88bd242e418cb5715798385f4e4 / app / sync / initialise / settings.js

1293 bytesRaw
1const nest = require('depnest')
2const merge = require('lodash/merge')
3const fs = require('fs')
4const { join } = require('path')
5
6exports.gives = nest('app.sync.initialise')
7
8exports.needs = nest({
9 'settings.sync.set': 'first',
10 'settings.sync.get': 'first'
11})
12
13const 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
43exports.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
55function 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