Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 45607e8

Browse files
Merge pull request #1199 from ssbc/update-deps
Unbreak the build (upgrade npm dependencies)
2 parents b686692 + 1bb92d7 commit 45607e8

File tree

13 files changed

+631
-813
lines changed

13 files changed

+631
-813
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@ before_install:
3333
libxext-dev \
3434
libxkbfile-dev \
3535
libxtst-dev
36-
else
37-
npm uninstall --save mouse-forward-back
3836
fi
3937
4038
script: npm test && npm run dist
4139

42-
4340
branches:
4441
only:
4542
- master

index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ electron.app.on('ready', () => {
5555
server: !(process.argv.includes('-g') || process.argv.includes('--use-global-ssb'))
5656
}, () => {
5757
const browserWindow = openMainWindow()
58+
59+
browserWindow.on('app-command', (e, cmd) => {
60+
switch (cmd) {
61+
case 'browser-backward': {
62+
browserWindow.webContents.send('goBack')
63+
break
64+
}
65+
case 'browser-forward': {
66+
browserWindow.webContents.send('goForward')
67+
break
68+
}
69+
}
70+
})
71+
5872
const menu = defaultMenu(electron.app, electron.shell)
5973

6074
menu.splice(4, 0, {
@@ -152,6 +166,7 @@ function openMainWindow () {
152166
backgroundColor: '#EEE',
153167
icon: Path.join(__dirname, 'assets/icon.png')
154168
})
169+
155170
windowState.manage(windows.main)
156171
windows.main.setSheetOffset(40)
157172
windows.main.on('close', function (e) {

lib/context-menu-and-spellcheck.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const ref = require('ssb-ref')
66
let navigateHandler = null
77
module.exports = setupContextMenuAndSpellCheck
88

9-
function setupContextMenuAndSpellCheck (config, { navigate, getMessageText }) {
9+
function setupContextMenuAndSpellCheck (config, { navigate, getMessageText, language }) {
1010
navigateHandler = navigate
1111
const spellCheckHandler = new SpellCheckHandler()
1212
spellCheckHandler.attachToInput()
1313

1414
// Start off as US English, America #1 (lol)
15-
spellCheckHandler.switchLanguage('en-US')
15+
spellCheckHandler.switchLanguage(language || 'en-US')
1616

1717
const contextMenuBuilder = new ContextMenuBuilder(spellCheckHandler, null, true, (menu, menuInfo) => {
1818
const ddg = new MenuItem({

lib/main-window.js

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ const requireStyle = require('require-style')
1616
const ssbUri = require('ssb-uri')
1717
const pull = require('pull-stream')
1818

19-
let mouseForwardBack
20-
21-
try {
22-
mouseForwardBack = require('mouse-forward-back')
23-
} catch (err) {
24-
mouseForwardBack = false
25-
}
26-
2719
module.exports = function (config) {
2820
const sockets = combine(
2921
overrideConfig(config),
@@ -57,7 +49,8 @@ module.exports = function (config) {
5749
}))
5850

5951
const i18n = api.intl.sync.i18n
60-
setupContextMenuAndSpellCheck(api.config.sync.load(), { navigate, getMessageText })
52+
const language = api.settings.obs.get('patchwork.lang', '')()
53+
setupContextMenuAndSpellCheck(api.config.sync.load(), { navigate, getMessageText, language })
6154

6255
const id = api.keys.sync.id()
6356
const latestUpdate = LatestUpdate()
@@ -138,23 +131,12 @@ module.exports = function (config) {
138131
const pendingCount = views.get('/mentions').pendingUpdates
139132

140133
watch(pendingCount, count => {
141-
electron.remote.app.setBadgeCount(count)
134+
electron.remote.app.badgeCount = count
142135
})
143136

144137
electron.ipcRenderer.on('goForward', views.goForward)
145138
electron.ipcRenderer.on('goBack', views.goBack)
146139

147-
if (mouseForwardBack) {
148-
mouseForwardBack.register((direction) => {
149-
if (direction === 'back') {
150-
views.goBack()
151-
} else if (direction === 'forward') {
152-
views.goForward()
153-
}
154-
},
155-
electron.remote.getCurrentWindow().getNativeWindowHandle())
156-
}
157-
158140
document.head.appendChild(
159141
h('style', {
160142
innerHTML: computed(api.settings.obs.get('patchwork.theme', 'light'), themeName => {
@@ -330,26 +312,25 @@ module.exports = function (config) {
330312
const element = h('a -drop', {
331313
'ev-click': () => {
332314
const rects = element.getBoundingClientRect()
333-
electron.remote.getCurrentWindow().webContents.getZoomFactor((factor) => {
334-
const menu = electron.remote.Menu.buildFromTemplate(items.map(item => {
335-
if (typeof item === 'function') {
336-
return item()
337-
} else if (item.separator) {
338-
return { type: 'separator' }
339-
} else {
340-
return {
341-
label: item[0],
342-
click () {
343-
navigate(item[1])
344-
}
315+
const factor = electron.remote.getCurrentWindow().webContents.zoomFactor
316+
const menu = electron.remote.Menu.buildFromTemplate(items.map(item => {
317+
if (typeof item === 'function') {
318+
return item()
319+
} else if (item.separator) {
320+
return { type: 'separator' }
321+
} else {
322+
return {
323+
label: item[0],
324+
click () {
325+
navigate(item[1])
345326
}
346327
}
347-
}))
348-
menu.popup({
349-
window: electron.remote.getCurrentWindow(),
350-
x: Math.round(rects.left * factor),
351-
y: Math.round(rects.bottom * factor) + 4
352-
})
328+
}
329+
}))
330+
menu.popup({
331+
window: electron.remote.getCurrentWindow(),
332+
x: Math.round(rects.left * factor),
333+
y: Math.round(rects.bottom * factor) + 4
353334
})
354335
}
355336
}, title)
@@ -436,7 +417,7 @@ module.exports = function (config) {
436417
if (value.content.type === 'gathering') {
437418
api.about.async.latestValues(id, ['title', 'description'], (err, values) => {
438419
if (err) return cb(err)
439-
var text = `# ${values.title}\n\n${values.description}`
420+
const text = `# ${values.title}\n\n${values.description}`
440421
cb(null, text)
441422
})
442423
} else {

lib/window.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ const extend = require('xtend/mutable')
44

55
module.exports = function Window (config, path, opts) {
66
const window = new electron.BrowserWindow(extend({
7-
show: false
7+
show: false,
8+
webPreferences: {
9+
nodeIntegration: true // XXX: Maybe not always necessary (?)
10+
}
811
}, opts))
912

1013
electron.ipcMain.on('ready-to-show', handleReadyToShow)

locales/es.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
"Hide details": "Ocultar detalles",
240240
"Show details": "Mostrar detalles",
241241
"forked from parent thread ": "bifurcó de padre hilo ",
242-
"Browse Recently Active": "Ve recién activo",
242+
"Browse Recently Active": "Ve recién activo",
243243
"el": "el",
244244
"eo": "eo",
245245
"fr": "fr",

0 commit comments

Comments
 (0)