Commit cbef0d72b505f32da320aecf8f0c3251e868f40d
standardise
mix irving committed on 2/8/2018, 5:16:20 AMParent: f9247af42625faa86a666f3a03671aa524a870a4
Files changed
app/page/thread.js | changed |
app/sync/catch-keyboard-shortcut.js | changed |
app/sync/goTo.js | changed |
app/sync/locationId.js | changed |
router/async/normalise.js | changed |
router/async/router.js | changed |
app/page/thread.js | |||
---|---|---|---|
@@ -88,9 +88,8 @@ | |||
88 | 88 … | }) | |
89 | 89 … | ||
90 | 90 … | return container | |
91 | 91 … | ||
92 | - | ||
93 | 92 … | function scrollDownToMessage (id) { | |
94 | 93 … | const locationId = api.app.sync.locationId(location) | |
95 | 94 … | const tabs = api.app.html.tabs() | |
96 | 95 … | locateKey() | |
@@ -108,5 +107,4 @@ | |||
108 | 107 … | } | |
109 | 108 … | } | |
110 | 109 … | } | |
111 | 110 … | } | |
112 | - |
app/sync/catch-keyboard-shortcut.js | ||
---|---|---|
@@ -107,9 +107,8 @@ | ||
107 | 107 … | goTo(msg.dataset.id) |
108 | 108 … | // TODO - rm the dataset.root decorator |
109 | 109 … | } |
110 | 110 … | |
111 | - | |
112 | 111 … | function toggleRawMessage (ev) { |
113 | 112 … | const msg = ev.target |
114 | 113 … | if (!msg.classList.contains('Message')) return |
115 | 114 … |
app/sync/goTo.js | ||
---|---|---|
@@ -26,9 +26,9 @@ | ||
26 | 26 … | const { |
27 | 27 … | openBackground = false, |
28 | 28 … | split = false |
29 | 29 … | } = options |
30 | - | |
30 … | + | |
31 | 31 … | const tabs = api.app.html.tabs() |
32 | 32 … | |
33 | 33 … | // currently do normalisation here only to generate normalised locationId |
34 | 34 … | api.router.async.normalise(location, (err, location) => { |
@@ -57,9 +57,8 @@ | ||
57 | 57 … | history.set([ ..._history, location, current ]) |
58 | 58 … | } else { |
59 | 59 … | api.history.sync.push(location) |
60 | 60 … | } |
61 | - | |
62 | 61 … | }) |
63 | 62 … | }) |
64 | 63 … | } |
65 | 64 … | } |
app/sync/locationId.js | ||
---|---|---|
@@ -9,12 +9,13 @@ | ||
9 | 9 … | |
10 | 10 … | function locationId (location) { |
11 | 11 … | if (typeof location === 'string') return string |
12 | 12 … | |
13 | - if (isMsg(location.key)) location = { | |
14 | - key: get(location, 'value.content.root', location.key) | |
13 … | + if (isMsg(location.key)) { | |
14 … | + location = { | |
15 … | + key: get(location, 'value.content.root', location.key) | |
16 … | + } | |
15 | 17 … | } |
16 | 18 … | |
17 | 19 … | return JSON.stringify(location) |
18 | 20 … | } |
19 | 21 … | } |
20 | - |
router/async/normalise.js | ||
---|---|---|
@@ -4,24 +4,25 @@ | ||
4 | 4 … | exports.gives = nest('router.async.normalise') |
5 | 5 … | |
6 | 6 … | exports.needs = nest({ |
7 | 7 … | 'message.sync.unbox': 'first', |
8 | - 'sbot.async.get': 'first', | |
8 … | + 'sbot.async.get': 'first' | |
9 | 9 … | }) |
10 | 10 … | |
11 | 11 … | exports.create = (api) => { |
12 | 12 … | return nest('router.async.normalise', normalise) |
13 | 13 … | |
14 | 14 … | function normalise (location, cb) { |
15 | 15 … | if (typeof location === 'object') cb(null, location) |
16 | - else if (isMsg(location)) api.sbot.async.get(location, (err, value) => { | |
17 | - if (err) cb(err) | |
18 | - else { | |
19 | - if (typeof value.content === 'string') value = api.message.sync.unbox(value) | |
20 | - cb(null, {key: location, value}) | |
21 | - } | |
22 | - }) | |
23 | - else if (isBlob(location)) cb(null, { blob: location }) | |
16 … | + else if (isMsg(location)) { | |
17 … | + api.sbot.async.get(location, (err, value) => { | |
18 … | + if (err) cb(err) | |
19 … | + else { | |
20 … | + if (typeof value.content === 'string') value = api.message.sync.unbox(value) | |
21 … | + cb(null, {key: location, value}) | |
22 … | + } | |
23 … | + }) | |
24 … | + } else if (isBlob(location)) cb(null, { blob: location }) | |
24 | 25 … | else if (isChannel(location)) cb(null, { channel: location }) |
25 | 26 … | else if (isFeed(location)) cb(null, { feed: location }) |
26 | 27 … | else if (isPage(location)) cb(null, { page: location.substring(1) }) |
27 | 28 … | |
@@ -35,5 +36,4 @@ | ||
35 | 36 … | |
36 | 37 … | function isPage (str) { |
37 | 38 … | return typeof str === 'string' && str[0] === '/' && str.length > 1 |
38 | 39 … | } |
39 | - |
Built with git-ssb-web