Files: f3a07a62ed183316f08c7c0cf24dcb767afd29b1 / app / sync / initialize / zoomMemory.js
1036 bytesRaw
1 | const nest = require('depnest') |
2 | const electron = require('electron') |
3 | |
4 | exports.gives = nest('app.sync.initialize') |
5 | |
6 | exports.needs = nest({ |
7 | 'settings.sync.get': 'first', |
8 | 'settings.sync.set': 'first' |
9 | }) |
10 | |
11 | exports.create = (api) => { |
12 | return nest('app.sync.initialize', zoomMemory) |
13 | |
14 | function zoomMemory () { |
15 | const { getCurrentWebContents, getCurrentWindow } = electron.remote |
16 | |
17 | window.addEventListener('resize', () => { |
18 | var wc = getCurrentWebContents() |
19 | wc && wc.getZoomFactor(zf => { |
20 | console.log(zf) |
21 | api.settings.sync.set({ |
22 | ticktack: { |
23 | electron: { |
24 | zoomFactor: zf, |
25 | windowBounds: getCurrentWindow().getBounds() |
26 | } |
27 | } |
28 | }) |
29 | }) |
30 | }) |
31 | |
32 | var zoomFactor = api.settings.sync.get('ticktack.electron.zoomFactor') |
33 | if (zoomFactor) { getCurrentWebContents().setZoomFactor(zoomFactor) } |
34 | |
35 | var bounds = api.settings.sync.get('ticktack.electron.windowBounds') |
36 | if (bounds) { getCurrentWindow().setBounds(bounds) } |
37 | } |
38 | } |
39 |
Built with git-ssb-web