git ssb

16+

Dominic / patchbay



Commit c5f3ae9b32ca1c2db67647aed1f069264dd936e8

wip run patchbay parts from elsewhere

mixmix committed on 11/5/2018, 12:06:12 AM
Parent: 6d7b07c6507be7d09bea489eec0e38347c3e1629

Files changed

index.jschanged
main.jschanged
message/html/compose.jschanged
message/html/confirm.jschanged
package-lock.jsonchanged
index.jsView
@@ -9,8 +9,9 @@
99
1010 console.log('STARTING electron')
1111
1212 electron.app.on('ready', () => {
13 + // set up menus
1314 var menu = defaultMenu(electron.app, electron.shell)
1415 var view = menu.find(x => x.label === 'View')
1516 view.submenu = [
1617 { role: 'reload' },
@@ -68,70 +69,71 @@
6869
6970 // allow inspecting of background process
7071 electron.ipcMain.on('open-background-devtools', function (ev, config) {
7172 if (windows.background) {
72- windows.background.webContents.openDevTools({detach: true})
73 + windows.background.webContents.openDevTools({ detach: true })
7374 }
7475 })
7576 })
7677
7778 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 + })
9596 }
9697
9798 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 + })
130131 }
131132
132133 function openWindow (path, opts) {
133134 var window = new electron.BrowserWindow(opts)
135 +
134136 window.webContents.on('dom-ready', function () {
135137 window.webContents.executeJavaScript(`
136138 var electron = require('electron')
137139 var h = require('mutant/h')
main.jsView
@@ -1,8 +1,9 @@
11 const combine = require('depject')
22 const entry = require('depject/entry')
33 const nest = require('depnest')
44 const bulk = require('bulk-require')
5 +const values = require('lodash/values')
56
67 // polyfills
78 require('setimmediate')
89
@@ -29,23 +30,30 @@
2930 drafts: require('patch-drafts'),
3031 history: require('patch-history')
3132 }
3233 }
33-module.exports = patchbay
3434
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 +
3551 // for electro[n]
36-if (typeof window !== 'undefined') {
52 +if (typeof window !== 'undefined' && !module.parent.parent) {
53 + // debugger
3754 // 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 ]
4856 // plugings loaded first will over-ride core modules loaded later
4957 const sockets = combine.apply(null, args)
5058
5159 const api = entry(sockets, nest('app.html.app', 'first'))
message/html/compose.jsView
@@ -89,12 +89,14 @@
8989 const opts = {
9090 stripExif: api.settings.obs.get('patchbay.removeExif', true),
9191 isPrivate
9292 }
93 + debugger
9394 blobFiles(files, api.sbot.obs.connection, opts, afterBlobed)
9495 },
9596 placeholder
9697 })
98 +
9799 textArea.publish = publish // TODO: fix - clunky api for the keyboard shortcut to target
98100
99101 // load draft
100102 let draft = api.drafts.sync.get(draftLocation)
@@ -155,9 +157,10 @@
155157
156158 console.log('added:', result)
157159 }
158160
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')
160163
161164 var actions = h('section.actions', [
162165 fileInput,
163166 publishBtn
@@ -209,9 +212,10 @@
209212
210213 // scoped
211214
212215 function publish () {
213- publishBtn.disabled = true
216 + if (resolve(isPublishing)) return
217 + isPublishing.set(true)
214218
215219 const channel = channelInput.value.startsWith('#')
216220 ? channelInput.value.substr(1).trim()
217221 : channelInput.value.trim()
@@ -239,17 +243,17 @@
239243 if (typeof prepublish === 'function') {
240244 content = prepublish(content)
241245 }
242246 } catch (err) {
243- publishBtn.disabled = false
247 + isPublishing.set(false)
244248 if (cb) cb(err)
245249 else throw err
246250 }
247251
248252 return api.message.html.confirm(content, done)
249253
250254 function done (err, msg) {
251- publishBtn.disabled = false
255 + isPublishing.set(false)
252256 if (err) throw err
253257 else if (msg) {
254258 textArea.value = ''
255259 api.drafts.sync.remove(draftLocation)
message/html/confirm.jsView
@@ -49,9 +49,13 @@
4949 }
5050 }, 'cancel')
5151
5252 okay.addEventListener('keydown', (ev) => {
53 + ev.preventDefault()
54 + ev.stopPropagation()
55 +
5356 if (ev.keyCode === 27) cancel.click() // escape
57 + if (ev.keyCode === 13) okay.click() // enter
5458 })
5559
5660 lb.show(h('MessageConfirm', [
5761 h('header -preview_description', [
package-lock.jsonView
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