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

Hide window endpoints #17

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions dist/server/api/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ router.post('/close', (req, res) => {
}
return res.sendStatus(200);
});
router.post('/hide', (req, res) => {
const { id } = req.body;
if (state_1.default.windows[id]) {
state_1.default.windows[id].hide();
}
return res.sendStatus(200);
});
router.get('/current', (req, res) => {
const currentWindow = Object.values(state_1.default.windows).find(window => window.id === electron_1.BrowserWindow.getFocusedWindow().id);
const id = Object.keys(state_1.default.windows).find(key => state_1.default.windows[key] === currentWindow);
Expand Down Expand Up @@ -148,6 +155,12 @@ router.post('/open', (req, res) => {
payload: [id]
});
});
window.on('hide', (evt) => {
(0, utils_1.notifyLaravel)('events', {
event: 'Native\\Laravel\\Events\\Windows\\WindowHidden',
payload: [id]
});
});
url += (url.indexOf('?') === -1 ? '?' : '&') + '_windowId=' + id;
window.loadURL(url);
window.webContents.on('did-finish-load', () => {
Expand Down
16 changes: 16 additions & 0 deletions src/server/api/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ router.post('/close', (req, res) => {
return res.sendStatus(200)
})

router.post('/hide', (req, res) => {
const {id} = req.body

if (state.windows[id]) {
state.windows[id].hide()
}
return res.sendStatus(200)
})

router.get('/current', (req, res) => {
const currentWindow = Object.values(state.windows).find(window => window.id === BrowserWindow.getFocusedWindow().id)
// Find object key with matching value
Expand Down Expand Up @@ -219,6 +228,13 @@ router.post('/open', (req, res) => {
})
})

window.on('hide', (evt) => {
notifyLaravel('events', {
event: 'Native\\Laravel\\Events\\Windows\\WindowHidden',
payload: [id]
})
})

// Append the window id to the url
url += (url.indexOf('?') === -1 ? '?' : '&') + '_windowId=' + id

Expand Down