Commit 323f8174abcb0c159f8393dcf5cdf41ff6141231
standardise
mix irving committed on 2/7/2018, 9:53:44 AMParent: ab8ce1ee60d988f3d1fcc1d1cf158bb841ce93e0
Files changed
about/html/edit.js | changed |
app/async/catch-link-click.js | changed |
app/html/app.js | changed |
app/html/filter.js | changed |
app/html/menu.js | changed |
app/html/search-bar.js | changed |
app/html/tabs.js | changed |
app/page/channel.js | changed |
app/sync/catch-keyboard-shortcut.js | changed |
app/sync/goTo.js | changed |
app/sync/initialise/settings.js | changed |
background-process.js | changed |
config.js | changed |
contact/html/relationships.js | changed |
index.js | changed |
main.js | changed |
message/html/compose.js | changed |
message/html/like.js | changed |
message/html/render/contact.js | changed |
about/html/edit.js | ||
---|---|---|
@@ -83,20 +83,19 @@ | ||
83 | 83 … | if (name.new) return name.new |
84 | 84 … | else return name.current |
85 | 85 … | }) |
86 | 86 … | |
87 | - | |
88 | 87 … | var balances_div = h('div.balances') |
89 | 88 … | |
90 | 89 … | mutual.getAccountBalances(id, (error, balances) => { |
91 | 90 … | if (balances == null) return '' |
92 | 91 … | |
93 | - var balance_els = []; | |
94 | - Object.keys(balances).forEach(function(key) { | |
92 … | + var balance_els = [] | |
93 … | + Object.keys(balances).forEach(function (key) { | |
95 | 94 … | balances_div.appendChild( |
96 | 95 … | h('div', `💰 ${balances[key]} ${key}`) |
97 | 96 … | ) |
98 | - }); | |
97 … | + }) | |
99 | 98 … | }) |
100 | 99 … | |
101 | 100 … | return h('AboutEditor', [ |
102 | 101 … | lightbox, |
@@ -227,5 +226,4 @@ | ||
227 | 226 … | }) |
228 | 227 … | } |
229 | 228 … | } |
230 | 229 … | } |
231 | - |
app/async/catch-link-click.js | ||
---|---|---|
@@ -5,9 +5,9 @@ | ||
5 | 5 … | |
6 | 6 … | exports.needs = nest({ |
7 | 7 … | 'app.html.externalConfirm': 'first', |
8 | 8 … | 'app.sync.goTo': 'first', |
9 | - 'router.sync.normalise': 'first', | |
9 … | + 'router.sync.normalise': 'first' | |
10 | 10 … | }) |
11 | 11 … | |
12 | 12 … | exports.create = function (api) { |
13 | 13 … | return nest('app.async.catchLinkClick', catchLinkClick) |
@@ -51,5 +51,4 @@ | ||
51 | 51 … | const openBackground = ctrlKey |
52 | 52 … | api.app.sync.goTo(location, openBackground) |
53 | 53 … | } |
54 | 54 … | } |
55 | - |
app/html/app.js | ||
---|---|---|
@@ -24,14 +24,14 @@ | ||
24 | 24 … | exports.create = function (api) { |
25 | 25 … | return nest('app.html.app', app) |
26 | 26 … | |
27 | 27 … | function app () { |
28 | - console.log("STARTING app") | |
28 … | + console.log('STARTING app') | |
29 | 29 … | |
30 | 30 … | api.app.sync.initialise() |
31 | 31 … | |
32 | 32 … | window = api.app.sync.window(window) |
33 | - | |
33 … | + | |
34 | 34 … | const css = values(api.styles.css()).join('\n') |
35 | 35 … | insertCss(css) |
36 | 36 … | |
37 | 37 … | const initialTabs = ['/public', '/inbox', '/notifications'] |
@@ -43,9 +43,9 @@ | ||
43 | 43 … | // Catch user actions |
44 | 44 … | api.app.sync.catchKeyboardShortcut(window, { tabs }) |
45 | 45 … | api.app.async.catchLinkClick(App) |
46 | 46 … | |
47 | - api.history.obs.location()(loc => api.app.sync.goTo(loc || {}) ) | |
47 … | + api.history.obs.location()(loc => api.app.sync.goTo(loc || {})) | |
48 | 48 … | |
49 | 49 … | // Catch errors |
50 | 50 … | var { container: errorPage, addError } = api.router.sync.router('/errors') |
51 | 51 … | window.addEventListener('error', ev => { |
@@ -53,9 +53,9 @@ | ||
53 | 53 … | |
54 | 54 … | addError(ev.error || ev) |
55 | 55 … | }) |
56 | 56 … | |
57 | - ////// TODO - extract this to keep patch-lite isolated from electron | |
57 … | + /// /// TODO - extract this to keep patch-lite isolated from electron | |
58 | 58 … | const { getCurrentWebContents, getCurrentWindow } = electron.remote |
59 | 59 … | window.addEventListener('resize', () => { |
60 | 60 … | var wc = getCurrentWebContents() |
61 | 61 … | wc && wc.getZoomFactor((zf) => { |
@@ -68,15 +68,13 @@ | ||
68 | 68 … | }) |
69 | 69 … | }) |
70 | 70 … | |
71 | 71 … | var zoomFactor = api.settings.sync.get('electron.zoomFactor') |
72 | - if (zoomFactor) | |
73 | - getCurrentWebContents().setZoomFactor(zoomFactor) | |
72 … | + if (zoomFactor) { getCurrentWebContents().setZoomFactor(zoomFactor) } | |
74 | 73 … | |
75 | 74 … | var bounds = api.settings.sync.get('electron.windowBounds') |
76 | - if (bounds) | |
77 | - getCurrentWindow().setBounds(bounds) | |
78 | - ////// | |
75 … | + if (bounds) { getCurrentWindow().setBounds(bounds) } | |
76 … | + /// /// | |
79 | 77 … | |
80 | 78 … | return App |
81 | 79 … | } |
82 | 80 … | } |
app/html/filter.js | ||
---|---|---|
@@ -33,23 +33,23 @@ | ||
33 | 33 … | |
34 | 34 … | const filterSettings = api.settings.obs.get('filter') |
35 | 35 … | |
36 | 36 … | const channelInput = h('input', |
37 | - { value: filterSettings().exclude.channels, | |
38 | - 'ev-keyup': (ev) => { | |
39 | - var text = ev.target.value | |
40 | - if (text.length == 0 || ev.which == 13) { | |
41 | - api.settings.sync.set({ | |
42 | - filter: { | |
43 | - exclude: { | |
44 | - channels: text | |
45 | - } | |
46 | - } | |
47 | - }) | |
48 | - draw() | |
49 | - } | |
50 | - } | |
51 | - } | |
37 … | + { value: filterSettings().exclude.channels, | |
38 … | + 'ev-keyup': (ev) => { | |
39 … | + var text = ev.target.value | |
40 … | + if (text.length == 0 || ev.which == 13) { | |
41 … | + api.settings.sync.set({ | |
42 … | + filter: { | |
43 … | + exclude: { | |
44 … | + channels: text | |
45 … | + } | |
46 … | + } | |
47 … | + }) | |
48 … | + draw() | |
49 … | + } | |
50 … | + } | |
51 … | + } | |
52 | 52 … | ) |
53 | 53 … | |
54 | 54 … | const isFiltered = computed(filterSettings, (filterSettings) => { |
55 | 55 … | const _settings = Object.assign({}, filterSettings) |
@@ -97,10 +97,10 @@ | ||
97 | 97 … | const state = computed(filterSettings, settings => get(settings, [filterGroup, type])) |
98 | 98 … | const handleClick = () => { |
99 | 99 … | const currentState = state() |
100 | 100 … | |
101 | - //TODO use some lodash tool ? | |
102 | - api.settings.sync.set({ | |
101 … | + // TODO use some lodash tool ? | |
102 … | + api.settings.sync.set({ | |
103 | 103 … | filter: { |
104 | 104 … | [filterGroup]: { |
105 | 105 … | [type]: !currentState |
106 | 106 … | } |
app/html/menu.js | ||
---|---|---|
@@ -3,11 +3,11 @@ | ||
3 | 3 … | |
4 | 4 … | exports.gives = nest('app.html.menu') |
5 | 5 … | |
6 | 6 … | exports.needs = nest({ |
7 | - "app.html.menuItem": "map", | |
8 | - "app.sync.goTo": "first", | |
9 | - "sbot.obs.connection": "first" | |
7 … | + 'app.html.menuItem': 'map', | |
8 … | + 'app.sync.goTo': 'first', | |
9 … | + 'sbot.obs.connection': 'first' | |
10 | 10 … | }) |
11 | 11 … | |
12 | 12 … | exports.create = function (api) { |
13 | 13 … | var _menu |
app/html/search-bar.js | ||
---|---|---|
@@ -6,9 +6,9 @@ | ||
6 | 6 … | |
7 | 7 … | exports.needs = nest({ |
8 | 8 … | 'app.sync.goTo': 'first', |
9 | 9 … | 'about.async.suggest': 'first', |
10 | - 'channel.async.suggest': 'first', | |
10 … | + 'channel.async.suggest': 'first' | |
11 | 11 … | // 'app.async.suggest': 'reduce' // TODO add ability to add to this |
12 | 12 … | }) |
13 | 13 … | |
14 | 14 … | exports.create = function (api) { |
@@ -19,13 +19,10 @@ | ||
19 | 19 … | |
20 | 20 … | const getProfileSuggestions = api.about.async.suggest() |
21 | 21 … | const getChannelSuggestions = api.channel.async.suggest() |
22 | 22 … | |
23 | - function goToLocation(location, ev) { | |
24 | - if (location[0] == '?') | |
25 | - location = { page: 'search', query: location.substring(1) } | |
26 | - else if (!['@', '#', '%', '&', '/'].includes(location[0])) | |
27 | - location = { page: 'search', query: location } | |
23 … | + function goToLocation (location, ev) { | |
24 … | + if (location[0] == '?') { location = { page: 'search', query: location.substring(1) } } else if (!['@', '#', '%', '&', '/'].includes(location[0])) { location = { page: 'search', query: location } } | |
28 | 25 … | |
29 | 26 … | api.app.sync.goTo(location) |
30 | 27 … | if (!ev.ctrlKey) input.blur() |
31 | 28 … | } |
@@ -43,9 +40,9 @@ | ||
43 | 40 … | input.blur() |
44 | 41 … | } |
45 | 42 … | } |
46 | 43 … | }) |
47 | - | |
44 … | + | |
48 | 45 … | input.addEventListener('suggestselect', ev => { |
49 | 46 … | input.value = ev.detail.id // HACK : this over-rides the markdown value |
50 | 47 … | goToLocation(input.value.trim(), ev) |
51 | 48 … | }) |
@@ -80,14 +77,14 @@ | ||
80 | 77 … | ] |
81 | 78 … | |
82 | 79 … | return pages |
83 | 80 … | .filter(page => ~page.indexOf(word)) |
84 | - .sort((a, b) => a.indexOf(word) < b.indexOf(word) ? -1 : +1 ) | |
81 … | + .sort((a, b) => a.indexOf(word) < b.indexOf(word) ? -1 : +1) | |
85 | 82 … | .map(page => { |
86 | 83 … | return { |
87 | - title: '/'+page, | |
88 | - id: '/'+page, | |
89 | - value: '/'+page, | |
84 … | + title: '/' + page, | |
85 … | + id: '/' + page, | |
86 … | + value: '/' + page | |
90 | 87 … | } |
91 | 88 … | }) |
92 | 89 … | } |
93 | 90 … |
app/html/tabs.js | ||
---|---|---|
@@ -42,9 +42,9 @@ | ||
42 | 42 … | return JSON.stringify(loc) != page.id |
43 | 43 … | }) |
44 | 44 … | history.set(prunedHistory) |
45 | 45 … | } |
46 | - | |
46 … | + | |
47 | 47 … | const search = api.app.html.searchBar() |
48 | 48 … | const menu = api.app.html.menu() |
49 | 49 … | |
50 | 50 … | _tabs = Tabs({ |
@@ -73,5 +73,4 @@ | ||
73 | 73 … | return keys |
74 | 74 … | .map(k => location[k]) |
75 | 75 … | .join(', ') |
76 | 76 … | } |
77 | - |
app/page/channel.js | ||
---|---|---|
@@ -63,12 +63,12 @@ | ||
63 | 63 … | ) |
64 | 64 … | } |
65 | 65 … | draw() |
66 | 66 … | |
67 | - var page = h('Page -channel', {title: channel}, [ | |
67 … | + var page = h('Page -channel', {title: channel}, [ | |
68 | 68 … | // filterMenu, // TODO - extract non-scroller els like filterMenu here |
69 | 69 … | container |
70 | - ]) | |
70 … | + ]) | |
71 | 71 … | |
72 | 72 … | // TODO better scroll hack for keyboard shortcuts |
73 | 73 … | page.scroll = container.scroll |
74 | 74 … |
app/sync/catch-keyboard-shortcut.js | ||
---|---|---|
@@ -4,9 +4,9 @@ | ||
4 | 4 … | |
5 | 5 … | exports.needs = nest({ |
6 | 6 … | 'app.html.searchBar': 'first', |
7 | 7 … | 'app.html.tabs': 'first', |
8 | - 'app.sync.goTo': 'first', | |
8 … | + 'app.sync.goTo': 'first' | |
9 | 9 … | }) |
10 | 10 … | |
11 | 11 … | var gPressed = false |
12 | 12 … | |
@@ -130,5 +130,4 @@ | ||
130 | 130 … | |
131 | 131 … | // this uses a crudely exported nav api |
132 | 132 … | msg.querySelector('.meta .toggle-raw-msg').click() |
133 | 133 … | } |
134 | - |
app/sync/goTo.js | ||
---|---|---|
@@ -6,9 +6,9 @@ | ||
6 | 6 … | 'app.html.tabs': 'first', |
7 | 7 … | 'history.obs.store': 'first', |
8 | 8 … | 'history.sync.push': 'first', |
9 | 9 … | 'router.sync.normalise': 'first', |
10 | - 'router.sync.router': 'first', | |
10 … | + 'router.sync.router': 'first' | |
11 | 11 … | }) |
12 | 12 … | |
13 | 13 … | exports.create = function (api) { |
14 | 14 … | return nest('app.sync.goTo', goTo) |
app/sync/initialise/settings.js | ||
---|---|---|
@@ -4,15 +4,15 @@ | ||
4 | 4 … | exports.gives = nest('app.sync.initialise') |
5 | 5 … | |
6 | 6 … | exports.needs = nest({ |
7 | 7 … | 'settings.sync.set': 'first', |
8 | - 'settings.sync.get': 'first', | |
8 … | + 'settings.sync.get': 'first' | |
9 | 9 … | }) |
10 | 10 … | |
11 | 11 … | const defaults = { |
12 | 12 … | filter: { |
13 | 13 … | exclude: { |
14 | - channels: "" | |
14 … | + channels: '' | |
15 | 15 … | }, |
16 | 16 … | only: { |
17 | 17 … | peopleIFollow: false |
18 | 18 … | }, |
@@ -38,5 +38,4 @@ | ||
38 | 38 … | |
39 | 39 … | set(settings) |
40 | 40 … | } |
41 | 41 … | } |
42 | - |
background-process.js | ||
---|---|---|
@@ -19,9 +19,9 @@ | ||
19 | 19 … | .use(require('ssb-about')) |
20 | 20 … | .use(require('ssb-fulltext')) |
21 | 21 … | // .use(require('ssb-ebt')) |
22 | 22 … | .use(require('ssb-ws')) |
23 | - .use(require('ssb-chess-db')); | |
23 … | + .use(require('ssb-chess-db')) | |
24 | 24 … | |
25 | 25 … | // pull config options out of depject |
26 | 26 … | var config = require('./config').create().config.sync.load() |
27 | 27 … |
contact/html/relationships.js | ||
---|---|---|
@@ -72,9 +72,9 @@ | ||
72 | 72 … | h('button', { 'ev-click': () => follow(id) }, 'Follow') |
73 | 73 … | ), |
74 | 74 … | h('button', { disabled: 'disabled' }, 'Loading...') |
75 | 75 … | ), |
76 | - when(ImFollowing.sync, h('div.relationship-status', relationshipStatus)), | |
76 … | + when(ImFollowing.sync, h('div.relationship-status', relationshipStatus)) | |
77 | 77 … | ]), |
78 | 78 … | h('section -blocking', [ |
79 | 79 … | when(ImBlockingThem, |
80 | 80 … | h('button', { 'ev-click': () => unblock(id, console.log) }, 'unblock'), |
@@ -84,9 +84,9 @@ | ||
84 | 84 … | "Blocking tells everyone you don't want to communicate with a person.", |
85 | 85 … | h('ul', [ |
86 | 86 … | h('li', 'You will no longer receive messages from this person'), |
87 | 87 … | h('li', "This person won't get any new information about you (including this block)"), |
88 | - h('li', "Your followers will see you have blocked this person - their apps need to know so that they don't pass your information on."), | |
88 … | + h('li', "Your followers will see you have blocked this person - their apps need to know so that they don't pass your information on.") | |
89 | 89 … | ]) |
90 | 90 … | ]) |
91 | 91 … | ]) |
92 | 92 … | ]) |
index.js | ||
---|---|---|
@@ -134,5 +134,4 @@ | ||
134 | 134 … | |
135 | 135 … | window.loadURL('file://' + Path.join(__dirname, 'assets', 'base.html')) |
136 | 136 … | return window |
137 | 137 … | } |
138 | - |
main.js | ||
---|---|---|
@@ -5,9 +5,9 @@ | ||
5 | 5 … | |
6 | 6 … | // polyfills |
7 | 7 … | require('setimmediate') |
8 | 8 … | |
9 | -const patchbay = { | |
9 … | +const patchbay = { | |
10 | 10 … | patchbay: { |
11 | 11 … | about: bulk(__dirname, [ 'about/**/*.js' ]), |
12 | 12 … | app: bulk(__dirname, [ 'app/**/*.js' ]), |
13 | 13 … | blob: bulk(__dirname, [ 'blob/**/*.js' ]), |
@@ -22,17 +22,16 @@ | ||
22 | 22 … | suggestions: require('patch-suggest'), |
23 | 23 … | settings: require('patch-settings'), |
24 | 24 … | drafts: require('patch-drafts'), |
25 | 25 … | inbox: require('patch-inbox'), // TODO - ideally this would be a standalone patch-* module |
26 | - history: require('patch-history'), | |
26 … | + history: require('patch-history') | |
27 | 27 … | } |
28 | 28 … | } |
29 | 29 … | |
30 | - | |
31 | 30 … | // from more specialized to more general |
32 | 31 … | const sockets = combine( |
33 | - //require('ssb-horcrux'), | |
34 | - //require('patch-hub'), | |
32 … | + // require('ssb-horcrux'), | |
33 … | + // require('patch-hub'), | |
35 | 34 … | |
36 | 35 … | require('ssb-chess'), |
37 | 36 … | require('patchbay-gatherings'), |
38 | 37 … | require('patchbay-book'), |
@@ -49,5 +48,4 @@ | ||
49 | 48 … | // for electro[n] |
50 | 49 … | if (typeof window !== 'undefined') { |
51 | 50 … | document.body.appendChild(app()) |
52 | 51 … | } |
53 | - |
message/html/compose.js | ||
---|---|---|
@@ -20,13 +20,13 @@ | ||
20 | 20 … | exports.create = function (api) { |
21 | 21 … | return nest({ 'message.html.compose': compose }) |
22 | 22 … | |
23 | 23 … | function compose (options, cb) { |
24 | - const { | |
24 … | + const { | |
25 | 25 … | meta, |
26 | - location, | |
26 … | + location, | |
27 | 27 … | feedIdsInThread = [], |
28 | - prepublish, | |
28 … | + prepublish, | |
29 | 29 … | placeholder = 'Write a message', |
30 | 30 … | shrink = true |
31 | 31 … | } = options |
32 | 32 … | |
@@ -104,9 +104,9 @@ | ||
104 | 104 … | ) |
105 | 105 … | var fileInput = api.blob.html.input(file => { |
106 | 106 … | const megabytes = file.size / 1024 / 1024 |
107 | 107 … | if (megabytes >= 5) { |
108 | - const rounded = Math.floor(megabytes*100)/100 | |
108 … | + const rounded = Math.floor(megabytes * 100) / 100 | |
109 | 109 … | warningMessage.set([ |
110 | 110 … | h('i.fa.fa-exclamation-triangle'), |
111 | 111 … | h('strong', file.name), |
112 | 112 … | ` is ${rounded}MB - the current limit is 5MB` |
message/html/like.js | ||
---|---|---|
@@ -47,5 +47,4 @@ | ||
47 | 47 … | |
48 | 48 … | function doesLike (likes, userId) { |
49 | 49 … | return likes.includes(userId) |
50 | 50 … | } |
51 | - |
message/html/render/contact.js | ||
---|---|---|
@@ -30,14 +30,18 @@ | ||
30 | 30 … | |
31 | 31 … | function renderContent ({ contact, following, blocking }) { |
32 | 32 … | const name = api.about.html.link(contact) |
33 | 33 … | |
34 | - if (blocking != undefined) return [ | |
35 | - blocking ? 'blocked ' : 'unblocked ', | |
36 | - name | |
37 | - ] | |
38 | - if (following != undefined) return [ | |
39 | - following ? 'followed ' : 'unfollowed ', | |
40 | - name | |
41 | - ] | |
34 … | + if (blocking != undefined) { | |
35 … | + return [ | |
36 … | + blocking ? 'blocked ' : 'unblocked ', | |
37 … | + name | |
38 … | + ] | |
39 … | + } | |
40 … | + if (following != undefined) { | |
41 … | + return [ | |
42 … | + following ? 'followed ' : 'unfollowed ', | |
43 … | + name | |
44 … | + ] | |
45 … | + } | |
42 | 46 … | } |
43 | 47 … | } |
Built with git-ssb-web