git ssb

16+

Dominic / patchbay



Tree: 55335207126eb15c3a0f1834ffb8bbcbd32658a8

Files: 55335207126eb15c3a0f1834ffb8bbcbd32658a8 / app / sync / initialise / electron-state.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