git ssb

16+

Dominic / patchbay



Tree: 9c5fb9afa9248c901294db9eac5e350da9bc055d

Files: 9c5fb9afa9248c901294db9eac5e350da9bc055d / app / sync / initialise / settings.js

1326 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 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
44exports.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
56function 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