mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
Fixed some redundant code (#5577)
* Fixed some redundant code, index.ts (Check line 210) Also prefixed 'event' in line 226 and 232 with _ since they are unused * Fixed a wrongful autoimport * Removed a finished FIXME * Name the function and fix typo Co-authored-by: Labhansh Agrawal <labhansh.agrawal@gmail.com>
This commit is contained in:
parent
e9841db526
commit
31f357a0ba
1 changed files with 14 additions and 17 deletions
31
app/index.ts
31
app/index.ts
|
|
@ -206,11 +206,12 @@ app.on('ready', () =>
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
app.on('open-file', (event, path) => {
|
/**
|
||||||
|
* Get last focused BrowserWindow or create new if none and callback
|
||||||
|
* @param callback Function to call with the BrowserWindow
|
||||||
|
*/
|
||||||
|
function GetWindow(callback: (win: BrowserWindow) => void) {
|
||||||
const lastWindow = app.getLastFocusedWindow();
|
const lastWindow = app.getLastFocusedWindow();
|
||||||
const callback = (win: BrowserWindow) => {
|
|
||||||
win.rpc.emit('open file', {path});
|
|
||||||
};
|
|
||||||
if (lastWindow) {
|
if (lastWindow) {
|
||||||
callback(lastWindow);
|
callback(lastWindow);
|
||||||
} else if (!lastWindow && {}.hasOwnProperty.call(app, 'createWindow')) {
|
} else if (!lastWindow && {}.hasOwnProperty.call(app, 'createWindow')) {
|
||||||
|
|
@ -220,20 +221,16 @@ app.on('open-file', (event, path) => {
|
||||||
// sets his callback to an app.windowCallback property.
|
// sets his callback to an app.windowCallback property.
|
||||||
app.windowCallback = callback;
|
app.windowCallback = callback;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.on('open-file', (_event, path) => {
|
||||||
|
GetWindow((win: BrowserWindow) => {
|
||||||
|
win.rpc.emit('open file', {path});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('open-url', (event, sshUrl) => {
|
app.on('open-url', (_event, sshUrl) => {
|
||||||
const lastWindow = app.getLastFocusedWindow();
|
GetWindow((win: BrowserWindow) => {
|
||||||
const callback = (win: BrowserWindow) => {
|
|
||||||
win.rpc.emit('open ssh', sshUrl);
|
win.rpc.emit('open ssh', sshUrl);
|
||||||
};
|
});
|
||||||
if (lastWindow) {
|
|
||||||
callback(lastWindow);
|
|
||||||
} else if (!lastWindow && {}.hasOwnProperty.call(app, 'createWindow')) {
|
|
||||||
app.createWindow(callback);
|
|
||||||
} else {
|
|
||||||
// If createWindow doesn't exist yet ('ready' event was not fired),
|
|
||||||
// sets his callback to an app.windowCallback property.
|
|
||||||
app.windowCallback = callback;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue