git ssb

2+

mixmix / ticktack



Tree: fb0788760b2ce15437b50ead1e804b650cc19077

Files: fb0788760b2ce15437b50ead1e804b650cc19077 / app / html / app.js

1403 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 'router.sync.router': 'first',
12 'settings.sync.get': 'first',
13 'settings.sync.set': 'first',
14})
15
16exports.create = (api) => {
17 return nest({
18 'app.html.app': function app () {
19 api.app.sync.initialize()
20
21 var view = Value()
22 var app = h('App', view)
23 api.history.obs.location()(renderLocation)
24 function renderLocation (loc) {
25 console.log('rendering new view', 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