git ssb

16+

Dominic / patchbay



Tree: abc121a76b7427cb820cb00ba8b51b52942893c1

Files: abc121a76b7427cb820cb00ba8b51b52942893c1 / app / sync / initialise / electronState.js

1049 bytesRaw
1const nest = require('depnest')
2const electron = require('electron')
3
4exports.gives = nest('app.sync.initialise')
5
6exports.needs = nest({
7 'settings.sync.get': 'first',
8 'settings.sync.set': 'first'
9})
10
11exports.create = function (api) {
12 return nest('app.sync.initialise', errorCatcher)
13
14 function errorCatcher () {
15 /// /// TODO - extract this to keep patch-lite isolated from electron
16 const { getCurrentWebContents, getCurrentWindow } = electron.remote
17 window.addEventListener('resize', () => {
18 var wc = getCurrentWebContents()
19 wc && wc.getZoomFactor((zf) => {
20 api.settings.sync.set({
21 electron: {
22 zoomFactor: zf,
23 windowBounds: getCurrentWindow().getBounds()
24 }
25 })
26 })
27 })
28
29 var zoomFactor = api.settings.sync.get('electron.zoomFactor')
30 if (zoomFactor) { getCurrentWebContents().setZoomFactor(zoomFactor) }
31
32 var bounds = api.settings.sync.get('electron.windowBounds')
33 if (bounds) { getCurrentWindow().setBounds(bounds) }
34 /// ///
35 }
36}
37

Built with git-ssb-web