Commit c5f3ae9b32ca1c2db67647aed1f069264dd936e8
wip run patchbay parts from elsewhere
mixmix committed on 11/5/2018, 12:06:12 AMParent: 6d7b07c6507be7d09bea489eec0e38347c3e1629
Files changed
index.js | changed |
main.js | changed |
message/html/compose.js | changed |
message/html/confirm.js | changed |
package-lock.json | changed |
index.js | ||
---|---|---|
@@ -9,8 +9,9 @@ | ||
9 | 9 … | |
10 | 10 … | console.log('STARTING electron') |
11 | 11 … | |
12 | 12 … | electron.app.on('ready', () => { |
13 … | + // set up menus | |
13 | 14 … | var menu = defaultMenu(electron.app, electron.shell) |
14 | 15 … | var view = menu.find(x => x.label === 'View') |
15 | 16 … | view.submenu = [ |
16 | 17 … | { role: 'reload' }, |
@@ -68,70 +69,71 @@ | ||
68 | 69 … | |
69 | 70 … | // allow inspecting of background process |
70 | 71 … | electron.ipcMain.on('open-background-devtools', function (ev, config) { |
71 | 72 … | if (windows.background) { |
72 | - windows.background.webContents.openDevTools({detach: true}) | |
73 … | + windows.background.webContents.openDevTools({ detach: true }) | |
73 | 74 … | } |
74 | 75 … | }) |
75 | 76 … | }) |
76 | 77 … | |
77 | 78 … | function startBackgroundProcess () { |
78 | - if (!windows.background) { | |
79 | - windows.background = openWindow(Path.join(__dirname, 'server.js'), { | |
80 | - connect: false, | |
81 | - center: true, | |
82 | - fullscreen: false, | |
83 | - fullscreenable: false, | |
84 | - height: 150, | |
85 | - maximizable: false, | |
86 | - minimizable: false, | |
87 | - resizable: false, | |
88 | - show: false, | |
89 | - skipTaskbar: true, | |
90 | - title: 'patchbay-server', | |
91 | - useContentSize: true, | |
92 | - width: 150 | |
93 | - }) | |
94 | - } | |
79 … | + if (windows.background) return | |
80 … | + | |
81 … | + windows.background = openWindow(Path.join(__dirname, 'server.js'), { | |
82 … | + title: 'patchbay-server', | |
83 … | + show: false, | |
84 … | + connect: false, | |
85 … | + width: 150, | |
86 … | + height: 150, | |
87 … | + center: true, | |
88 … | + fullscreen: false, | |
89 … | + fullscreenable: false, | |
90 … | + maximizable: false, | |
91 … | + minimizable: false, | |
92 … | + resizable: false, | |
93 … | + skipTaskbar: true, | |
94 … | + useContentSize: true | |
95 … | + }) | |
95 | 96 … | } |
96 | 97 … | |
97 | 98 … | function openMainWindow () { |
98 | - if (!windows.main) { | |
99 | - var windowState = WindowState({ | |
100 | - defaultWidth: 1024, | |
101 | - defaultHeight: 768 | |
102 | - }) | |
103 | - windows.main = openWindow(Path.join(__dirname, 'main.js'), { | |
104 | - minWidth: 800, | |
105 | - x: windowState.x, | |
106 | - y: windowState.y, | |
107 | - width: windowState.width, | |
108 | - height: windowState.height, | |
109 | - autoHideMenuBar: true, | |
110 | - title: 'Patchbay', | |
111 | - frame: !process.env.FRAME, | |
112 | - // titleBarStyle: 'hidden', | |
113 | - show: true, | |
114 | - backgroundColor: '#FFF', | |
115 | - icon: './assets/icon.png' | |
116 | - }) | |
117 | - windowState.manage(windows.main) | |
118 | - windows.main.setSheetOffset(40) | |
119 | - windows.main.on('close', function (e) { | |
120 | - if (!quitting && process.platform === 'darwin') { | |
121 | - e.preventDefault() | |
122 | - windows.main.hide() | |
123 | - } | |
124 | - }) | |
125 | - windows.main.on('closed', function () { | |
126 | - windows.main = null | |
127 | - if (process.platform !== 'darwin') electron.app.quit() | |
128 | - }) | |
129 | - } | |
99 … | + if (windows.main) return | |
100 … | + | |
101 … | + var windowState = WindowState({ | |
102 … | + defaultWidth: 1024, | |
103 … | + defaultHeight: 768 | |
104 … | + }) | |
105 … | + windows.main = openWindow(Path.join(__dirname, 'main.js'), { | |
106 … | + title: 'Patchbay', | |
107 … | + show: true, | |
108 … | + x: windowState.x, | |
109 … | + y: windowState.y, | |
110 … | + minWidth: 800, | |
111 … | + width: windowState.width, | |
112 … | + height: windowState.height, | |
113 … | + autoHideMenuBar: true, | |
114 … | + frame: !process.env.FRAME, | |
115 … | + // titleBarStyle: 'hidden', | |
116 … | + backgroundColor: '#FFF', | |
117 … | + icon: './assets/icon.png' | |
118 … | + }) | |
119 … | + windowState.manage(windows.main) | |
120 … | + windows.main.setSheetOffset(40) | |
121 … | + windows.main.on('close', function (e) { | |
122 … | + if (!quitting && process.platform === 'darwin') { | |
123 … | + e.preventDefault() | |
124 … | + windows.main.hide() | |
125 … | + } | |
126 … | + }) | |
127 … | + windows.main.on('closed', function () { | |
128 … | + windows.main = null | |
129 … | + if (process.platform !== 'darwin') electron.app.quit() | |
130 … | + }) | |
130 | 131 … | } |
131 | 132 … | |
132 | 133 … | function openWindow (path, opts) { |
133 | 134 … | var window = new electron.BrowserWindow(opts) |
135 … | + | |
134 | 136 … | window.webContents.on('dom-ready', function () { |
135 | 137 … | window.webContents.executeJavaScript(` |
136 | 138 … | var electron = require('electron') |
137 | 139 … | var h = require('mutant/h') |
main.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | 1 … | const combine = require('depject') |
2 | 2 … | const entry = require('depject/entry') |
3 | 3 … | const nest = require('depnest') |
4 | 4 … | const bulk = require('bulk-require') |
5 … | +const values = require('lodash/values') | |
5 | 6 … | |
6 | 7 … | // polyfills |
7 | 8 … | require('setimmediate') |
8 | 9 … | |
@@ -29,23 +30,30 @@ | ||
29 | 30 … | drafts: require('patch-drafts'), |
30 | 31 … | history: require('patch-history') |
31 | 32 … | } |
32 | 33 … | } |
33 | -module.exports = patchbay | |
34 | 34 … | |
35 … | +const plugins = { | |
36 … | + scry: require('patchbay-scry'), | |
37 … | + darkCrystal: require('patchbay-dark-crystal'), | |
38 … | + poll: require('patchbay-poll'), | |
39 … | + inbox: require('patch-inbox'), // TODO needs work | |
40 … | + chess: require('ssb-chess-mithril'), | |
41 … | + book: require('patchbay-book'), | |
42 … | + gatherings: require('patchbay-gatherings') | |
43 … | +} | |
44 … | + | |
45 … | +module.exports = { | |
46 … | + plugins, | |
47 … | + patchbay, | |
48 … | + patchcore | |
49 … | +} | |
50 … | + | |
35 | 51 … | // for electro[n] |
36 | -if (typeof window !== 'undefined') { | |
52 … | +if (typeof window !== 'undefined' && !module.parent.parent) { | |
53 … | + // debugger | |
37 | 54 … | // TODO spin up settings check which modules are wanted |
38 | - const plugins = [ | |
39 | - require('patchbay-scry'), | |
40 | - require('patchbay-dark-crystal'), | |
41 | - require('patchbay-poll'), | |
42 | - require('patch-inbox'), // TODO needs work | |
43 | - require('ssb-chess-mithril'), | |
44 | - require('patchbay-book'), | |
45 | - require('patchbay-gatherings') | |
46 | - ] | |
47 | - const args = [ ...plugins, patchbay, patchcore ] | |
55 … | + const args = [ ...values(plugins), patchbay, patchcore ] | |
48 | 56 … | // plugings loaded first will over-ride core modules loaded later |
49 | 57 … | const sockets = combine.apply(null, args) |
50 | 58 … | |
51 | 59 … | const api = entry(sockets, nest('app.html.app', 'first')) |
message/html/compose.js | ||
---|---|---|
@@ -89,12 +89,14 @@ | ||
89 | 89 … | const opts = { |
90 | 90 … | stripExif: api.settings.obs.get('patchbay.removeExif', true), |
91 | 91 … | isPrivate |
92 | 92 … | } |
93 … | + debugger | |
93 | 94 … | blobFiles(files, api.sbot.obs.connection, opts, afterBlobed) |
94 | 95 … | }, |
95 | 96 … | placeholder |
96 | 97 … | }) |
98 … | + | |
97 | 99 … | textArea.publish = publish // TODO: fix - clunky api for the keyboard shortcut to target |
98 | 100 … | |
99 | 101 … | // load draft |
100 | 102 … | let draft = api.drafts.sync.get(draftLocation) |
@@ -155,9 +157,10 @@ | ||
155 | 157 … | |
156 | 158 … | console.log('added:', result) |
157 | 159 … | } |
158 | 160 … | |
159 | - var publishBtn = h('button', { 'ev-click': publish }, isPrivate ? 'Reply' : 'Publish') | |
161 … | + var isPublishing = Value(false) | |
162 … | + var publishBtn = h('button', { 'ev-click': publish, disabled: isPublishing }, isPrivate ? 'Reply' : 'Publish') | |
160 | 163 … | |
161 | 164 … | var actions = h('section.actions', [ |
162 | 165 … | fileInput, |
163 | 166 … | publishBtn |
@@ -209,9 +212,10 @@ | ||
209 | 212 … | |
210 | 213 … | // scoped |
211 | 214 … | |
212 | 215 … | function publish () { |
213 | - publishBtn.disabled = true | |
216 … | + if (resolve(isPublishing)) return | |
217 … | + isPublishing.set(true) | |
214 | 218 … | |
215 | 219 … | const channel = channelInput.value.startsWith('#') |
216 | 220 … | ? channelInput.value.substr(1).trim() |
217 | 221 … | : channelInput.value.trim() |
@@ -239,17 +243,17 @@ | ||
239 | 243 … | if (typeof prepublish === 'function') { |
240 | 244 … | content = prepublish(content) |
241 | 245 … | } |
242 | 246 … | } catch (err) { |
243 | - publishBtn.disabled = false | |
247 … | + isPublishing.set(false) | |
244 | 248 … | if (cb) cb(err) |
245 | 249 … | else throw err |
246 | 250 … | } |
247 | 251 … | |
248 | 252 … | return api.message.html.confirm(content, done) |
249 | 253 … | |
250 | 254 … | function done (err, msg) { |
251 | - publishBtn.disabled = false | |
255 … | + isPublishing.set(false) | |
252 | 256 … | if (err) throw err |
253 | 257 … | else if (msg) { |
254 | 258 … | textArea.value = '' |
255 | 259 … | api.drafts.sync.remove(draftLocation) |
message/html/confirm.js | ||
---|---|---|
@@ -49,9 +49,13 @@ | ||
49 | 49 … | } |
50 | 50 … | }, 'cancel') |
51 | 51 … | |
52 | 52 … | okay.addEventListener('keydown', (ev) => { |
53 … | + ev.preventDefault() | |
54 … | + ev.stopPropagation() | |
55 … | + | |
53 | 56 … | if (ev.keyCode === 27) cancel.click() // escape |
57 … | + if (ev.keyCode === 13) okay.click() // enter | |
54 | 58 … | }) |
55 | 59 … | |
56 | 60 … | lb.show(h('MessageConfirm', [ |
57 | 61 … | h('header -preview_description', [ |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 374372 bytes New file size: 374391 bytes |
Built with git-ssb-web