git ssb

16+

Dominic / patchbay



Commit b7d7f86afc99c01161ac2e00a2decf8ecb85246e

extract addPage and goTo into sync functions

mix irving committed on 4/22/2017, 11:17:21 PM
Parent: cb96c21f9190d81e56e129d5b7def3e8300c8cbe

Files changed

app/sync/addPage.jsadded
app/sync/goTo.jsadded
app/sync/addPage.jsView
@@ -1,0 +1,29 @@
1 +const nest = require('depnest')
2 +
3 +exports.gives = nest({ 'app.sync.addPage': true })
4 +
5 +exports.needs = nest({
6 + 'app.html.tabs': 'first',
7 + 'app.html.page': 'first'
8 +})
9 +
10 +exports.create = function (api) {
11 + return nest({
12 + 'app.sync': {
13 + addPage
14 + }
15 + })
16 +
17 + // TODO : make it so error catching doesn't need this, move it into goTo
18 + function addPage (link, change, split) {
19 + const tabs = api.app.html.tabs()
20 +
21 + const page = api.app.html.page(link)
22 + if (!page) return
23 +
24 + page.id = page.id || link
25 + tabs.add(page, change, split)
26 + }
27 +}
28 +
29 +
app/sync/goTo.jsView
@@ -1,0 +1,30 @@
1 +const nest = require('depnest')
2 +
3 +exports.gives = nest({ 'app.sync.goTo': true })
4 +
5 +exports.needs = nest({
6 + 'app.html.tabs': 'first',
7 + 'app.sync.addPage': 'first'
8 +})
9 +
10 +exports.create = function (api) {
11 + return nest({
12 + 'app.sync': {
13 + goTo
14 + }
15 + })
16 +
17 + function goTo (path, change) {
18 + const tabs = api.app.html.tabs()
19 +
20 + if (tabs.has(path)) {
21 + tabs.select(path)
22 + return true
23 + }
24 +
25 + addPage(path, true, false)
26 + return change
27 + }
28 +
29 +}
30 +

Built with git-ssb-web