Files: 60479658b26b297158dd59938d021562a5b447ec / router / sync / routes.js
1622 bytesRaw
1 | const nest = require('depnest') |
2 | const { isMsg, isFeed } = require('ssb-ref') |
3 | exports.gives = nest('router.sync.routes') |
4 | |
5 | exports.needs = nest({ |
6 | 'app.page.error': 'first', |
7 | 'app.page.home': 'first', |
8 | 'app.page.channel': 'first', |
9 | 'app.page.settings': 'first', |
10 | 'app.page.groupFind': 'first', |
11 | 'app.page.groupIndex': 'first', |
12 | 'app.page.groupNew': 'first', |
13 | 'app.page.groupShow': 'first', |
14 | 'app.page.userFind': 'first', |
15 | 'app.page.userShow': 'first', |
16 | 'app.page.threadShow': 'first' |
17 | }) |
18 | |
19 | exports.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.channel , pages.channel ], |
27 | [ location => location.page === 'settings', pages.settings ], |
28 | |
29 | // Group pages |
30 | [ location => location.page === 'groupFind', pages.groupFind ], |
31 | [ location => location.page === 'groupIndex', pages.groupIndex ], |
32 | [ location => location.page === 'groupNew', pages.groupNew ], |
33 | [ location => location.type === 'groupShow' && isMsg(location.key), pages.groupShow ], |
34 | |
35 | // User pages |
36 | [ location => location.page === 'userFind', pages.userFind ], |
37 | [ location => isFeed(location.feed), pages.userShow ], |
38 | |
39 | // Thread pages |
40 | // QUESTION - should this be for private threads + group threads? |
41 | [ location => isMsg(location.key), pages.threadShow ], |
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 | |
61 |
Built with git-ssb-web