git ssb

16+

Dominic / patchbay



Tree: 5e5bef4d7a2202ff89f9fd54978ed73376abe898

Files: 5e5bef4d7a2202ff89f9fd54978ed73376abe898 / app / sync / addPage.js

777 bytesRaw
1const nest = require('depnest')
2
3exports.gives = nest({ 'app.sync.addPage': true })
4
5exports.needs = nest({
6 'app.html.tabs': 'first',
7 'router.sync.router': 'first',
8 'router.sync.normalise': 'first'
9})
10
11exports.create = function (api) {
12 return nest({
13 'app.sync.addPage': addPage
14 })
15
16 // TODO : make it so error catching doesn't need this, move it into goTo
17 function addPage (location, change, split) {
18 const tabs = api.app.html.tabs()
19 const page = api.router.sync.router(location)
20 if (!page) return
21
22 // TODO - review unique page id + naming system
23 page.id = page.id || buildId(location)
24 tabs.add(page, change, split)
25 }
26
27 function buildId (location) {
28 return JSON.stringify(
29 api.router.sync.normalise(location)
30 )
31 }
32}
33
34

Built with git-ssb-web