Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 6510416

Browse files
committed
add hide endpoint and event
1 parent dc70e45 commit 6510416

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/server/api/window.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ router.post('/close', (req, res) => {
4040
return res.sendStatus(200)
4141
})
4242

43+
router.post('/hide', (req, res) => {
44+
const {id} = req.body
45+
46+
if (state.windows[id]) {
47+
state.windows[id].hide()
48+
}
49+
return res.sendStatus(200)
50+
})
51+
4352
router.get('/current', (req, res) => {
4453
const currentWindow = Object.values(state.windows).find(window => window.id === BrowserWindow.getFocusedWindow().id)
4554
// Find object key with matching value
@@ -219,6 +228,13 @@ router.post('/open', (req, res) => {
219228
})
220229
})
221230

231+
window.on('hide', (evt) => {
232+
notifyLaravel('events', {
233+
event: 'Native\\Laravel\\Events\\Windows\\WindowHidden',
234+
payload: [id]
235+
})
236+
})
237+
222238
// Append the window id to the url
223239
url += (url.indexOf('?') === -1 ? '?' : '&') + '_windowId=' + id
224240

0 commit comments

Comments
 (0)