git ssb

2+

mixmix / ticktack



Tree: ce8d61fcc1f40737fead142b9c628519f7e9a145

Files: ce8d61fcc1f40737fead142b9c628519f7e9a145 / router / sync / routes.js

1663 bytesRaw
1const nest = require('depnest')
2const { isMsg, isFeed } = require('ssb-ref')
3exports.gives = nest('router.sync.routes')
4
5exports.needs = nest({
6 'app.page.error': 'first',
7 'app.page.home': 'first',
8 'app.page.settings': 'first',
9 'app.page.groupFind': 'first',
10 'app.page.groupIndex': 'first',
11 'app.page.groupNew': 'first',
12 'app.page.groupShow': 'first',
13 'app.page.userFind': 'first',
14 'app.page.userShow': 'first',
15 'app.page.threadNew': 'first',
16 'app.page.threadShow': 'first',
17})
18
19exports.create = (api) => {
20 return nest('router.sync.routes', (sofar = []) => {
21 const pages = api.app.page
22 // route format: [ routeValidator, routeFunction ]
23
24 const routes = [
25 [ location => location.page === 'home', pages.home ],
26 [ location => location.page === 'settings', pages.settings ],
27
28 // Group pages
29 [ location => location.page === 'groupFind', pages.groupFind ],
30 [ location => location.page === 'groupIndex', pages.groupIndex ],
31 [ location => location.page === 'groupNew', pages.groupNew ],
32 [ location => location.type === 'groupShow' && isMsg(location.key), pages.groupShow ],
33
34 // Thread pages
35 // QUESTION - should this be for private threads + group threads?
36 [ location => location.page === 'threadNew' && isFeed(location.feed), pages.threadNew ],
37 [ location => isMsg(location.key), pages.threadShow ],
38
39 // User pages
40 [ location => location.page === 'userFind', pages.userFind ],
41 [ location => isFeed(location.feed), pages.userShow ],
42
43 // Error page
44 [ location => true, pages.error ]
45 ]
46
47 return [...routes, ...sofar]
48 })
49}
50
51
52
53
54
55
56
57
58
59
60

Built with git-ssb-web