Skip to content

Commit

Permalink
feat(main): store window bounds on move & resize
Browse files Browse the repository at this point in the history
  • Loading branch information
antonreshetov committed Mar 29, 2022
1 parent a89367b commit 3d1e88d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import os from 'os'
import { store } from './store'
import { createApiServer } from './services/api/server'
import { createDb } from './services/db'
import { debounce } from 'lodash'

const isDev = process.env.NODE_ENV === 'development'

Expand Down Expand Up @@ -32,11 +33,14 @@ function createWindow () {
mainWindow.loadFile(path.resolve(app.getAppPath(), 'renderer/index.html'))
}

mainWindow.on('close', () => {
store.app.set('bounds', mainWindow.getBounds())
})
mainWindow.on('resize', () => storeBounds(mainWindow))
mainWindow.on('move', () => storeBounds(mainWindow))
}

const storeBounds = debounce((mainWindow: BrowserWindow) => {
store.app.set('bounds', mainWindow.getBounds())
}, 300)

app.whenReady().then(async () => {
createWindow()

Expand Down

0 comments on commit 3d1e88d

Please sign in to comment.