git ssb

2+

mixmix / ticktack



Tree: 46d507d68f853a7a8459be31b98e58fa4e8430aa

Files: 46d507d68f853a7a8459be31b98e58fa4e8430aa / app / html / app.js

1939 bytesRaw
1const nest = require('depnest')
2const values = require('lodash/values')
3const insertCss = require('insert-css')
4const openExternal = require('open-external')
5
6const HyperNav = require('hyper-nav')
7const computed = require('mutant/computed')
8const h = require('mutant/h')
9
10exports.gives = nest({
11 'app.html.app': true,
12 'history.obs.history': true,
13 'history.sync.push': true,
14 'history.sync.back': true,
15})
16
17exports.needs = nest({
18 'about.async.suggest': 'first',
19 'app.html.header': 'first',
20 'app.async.catchLinkClick': 'first',
21 'channel.async.suggest': 'first',
22 'keys.sync.id': 'first',
23 'router.sync.router': 'first',
24 'settings.sync.get': 'first',
25 'settings.sync.set': 'first',
26 'styles.css': 'reduce',
27})
28
29exports.create = (api) => {
30 var nav = null
31
32 return nest({
33 'app.html.app': function app () {
34
35 // DIRTY HACK - initializes the suggestion indexes
36 api.about.async.suggest()
37 api.channel.async.suggest()
38
39 const css = values(api.styles.css()).join('\n')
40 insertCss(css)
41
42 api.app.async.catchLinkClick(document.body, (link, { isExternal }) => {
43 if (isExternal) return openExternal(link)
44 nav.push(link)
45 })
46
47 nav = HyperNav(
48 api.router.sync.router,
49 api.app.html.header
50 )
51
52 const isOnboarded = api.settings.sync.get('onboarded')
53 if (isOnboarded)
54 nav.push({page: 'home'})
55 else {
56 nav.push({
57 page:'userEdit',
58 feed: api.keys.sync.id(),
59 callback: (err, didEdit) => {
60 if (err) throw new Error ('Error editing profile', err)
61
62 if (didEdit)
63 api.settings.sync.set({ onboarded: true })
64
65 nav.push({ page: 'home' })
66 }
67 })
68 }
69
70 return nav
71 },
72 'history.sync.push': (location) => nav.push(location),
73 'history.sync.back': () => nav.back(),
74 'history.obs.history': () => nav.history,
75 })
76}
77
78
79
80

Built with git-ssb-web