git ssb

2+

mixmix / ticktack



Tree: a7d4b9115a2dced12642b05809693fa90ef969ec

Files: a7d4b9115a2dced12642b05809693fa90ef969ec / app / html / app.js

1383 bytesRaw
1const nest = require('depnest')
2const { h, Value } = require('mutant')
3
4exports.gives = nest('app.html.app')
5
6exports.needs = nest({
7 'app.sync.initialize': 'map',
8 'app.html.header': 'first',
9 'history.obs.location': 'first',
10 'history.sync.push': 'first',
11 'keys.sync.id': 'first',
12 'router.sync.router': 'first',
13 'settings.sync.get': 'first',
14 'settings.sync.set': 'first',
15})
16
17exports.create = (api) => {
18 return nest({
19 'app.html.app': function app () {
20 api.app.sync.initialize()
21
22 var view = Value()
23 var app = h('App', view)
24 api.history.obs.location()(renderLocation)
25 function renderLocation (loc) {
26 var page = api.router.sync.router(loc)
27 if (page) view.set([
28 api.app.html.header({location: loc, push: api.history.sync.push}),
29 page
30 ])
31 }
32
33 const isOnboarded = api.settings.sync.get('onboarded')
34 if (isOnboarded)
35 api.history.sync.push({page: 'home'})
36 else {
37 api.history.sync.push({
38 page:'userEdit',
39 feed: api.keys.sync.id(),
40 callback: (err, didEdit) => {
41 if (err) throw new Error ('Error editing profile', err)
42
43 if (didEdit)
44 api.settings.sync.set({ onboarded: true })
45
46 api.history.sync.push({ page: 'home' })
47 }
48 })
49 }
50
51
52 return app
53 }
54 })
55}
56
57

Built with git-ssb-web