Skip to content

Commit 0cc61c9

Browse files
committed
Expose desktop shell version to the webapp within
1 parent c4d7ebd commit 0cc61c9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import * as path from 'path';
2-
32
import { app, BrowserWindow, shell } from 'electron';
43

4+
// tslint:disable-next-line:no-var-requires
5+
const packageJson = require('../package.json');
6+
57
const APP_URL = 'https://app.httptoolkit.tech';
68

79
// Keep a global reference of the window object, if you don't, the window will
@@ -51,6 +53,16 @@ app.on('activate', () => {
5153
});
5254

5355
app.on('web-contents-created', (_event, contents) => {
56+
contents.on('dom-ready', () => {
57+
// Define & announce the desktop shell version to the app
58+
// Not used now, intended to allow us to detect and prompt for updates
59+
// in future, if a certain desktop shell version is required.
60+
contents.executeJavaScript(`
61+
window.httpToolkitDesktopVersion = '${packageJson.version}';
62+
window.postMessage({ httpToolkitDesktopVersion: window.httpToolkitDesktopVersion }, '*');
63+
`);
64+
});
65+
5466
// Redirect all navigations & new windows to the system browser
5567
contents.on('will-navigate', (event, navigationUrl) => {
5668
const parsedUrl = new URL(navigationUrl);
@@ -69,4 +81,4 @@ app.on('web-contents-created', (_event, contents) => {
6981
shell.openExternal(navigationUrl);
7082
}
7183
});
72-
})
84+
});

tslint.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"no-unused-expression": true,
1515
"no-use-before-declare": true,
1616
"no-var-requires": true,
17-
"no-require-imports": true,
1817
"one-line": [true,
1918
"check-else",
2019
"check-whitespace",

0 commit comments

Comments
 (0)