Skip to content

Commit

Permalink
Replace deprecated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
manavmehta committed Jun 22, 2020
1 parent 5943c21 commit 7907455
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/renderer/js/components/webview.ts
Expand Up @@ -216,7 +216,7 @@ export default class WebView extends BaseComponent {

focus(): void {
// Focus Webview and it's contents when Window regain focus.
const webContents = this.$el.getWebContents();
const webContents = remote.webContents.fromId(this.$el.getWebContentsId());
// HACK: webContents.isFocused() seems to be true even without the element
// being in focus. So, we check against `document.activeElement`.
if (webContents && this.$el !== document.activeElement) {
Expand Down
6 changes: 3 additions & 3 deletions app/renderer/js/main.ts
Expand Up @@ -717,7 +717,7 @@ class ServerManagerView {

updateGeneralSettings(setting: string, value: unknown): void {
if (this.getActiveWebview()) {
const webContents = this.getActiveWebview().getWebContents();
const webContents = remote.webContents.fromId(this.getActiveWebview().getWebContentsId());
webContents.send(setting, value);
}
}
Expand Down Expand Up @@ -917,7 +917,7 @@ class ServerManagerView {
ipcRenderer.on('toggle-dnd', (event: Event, state: boolean, newSettings: DNDSettings) => {
this.toggleDNDButton(state);
ipcRenderer.send('forward-message', 'toggle-silent', newSettings.silent);
const webContents = this.getActiveWebview().getWebContents();
const webContents = remote.webContents.fromId(this.getActiveWebview().getWebContentsId());
webContents.send('toggle-dnd', state, newSettings);
});

Expand Down Expand Up @@ -969,7 +969,7 @@ class ServerManagerView {
ipcRenderer.on('focus-webview-with-id', (event: Event, webviewId: number) => {
const webviews: NodeListOf<Electron.WebviewTag> = document.querySelectorAll('webview');
webviews.forEach(webview => {
const currentId = webview.getWebContents().id;
const currentId = webview.getWebContentsId();
const tabId = webview.getAttribute('data-tab-id');
const concurrentTab: HTMLButtonElement = document.querySelector(`div[data-tab-id="${tabId}"]`);
if (currentId === webviewId) {
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/js/tray.ts
Expand Up @@ -207,7 +207,7 @@ function toggleTray(): void {

const selector = 'webview:not([class*=disabled])';
const webview: WebviewTag = document.querySelector(selector);
const webContents = webview.getWebContents();
const webContents = remote.webContents.fromId(webview.getWebContentsId());
webContents.send('toggletray', state);
}

Expand Down
36 changes: 18 additions & 18 deletions app/renderer/js/utils/link-util.ts
Expand Up @@ -19,24 +19,24 @@ export async function openBrowser(url: URL): Promise<void> {
);
const file = path.join(dir, 'redirect.html');
fs.writeFileSync(file, `\
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="Refresh" content="0; url=${escape(url.href)}" />
<title>Redirecting</title>
<style>
html {
font-family: menu, "Helvetica Neue", sans-serif;
}
</style>
</head>
<body>
<p>Opening <a href="${escape(url.href)}">${escape(url.href)}</a>…</p>
</body>
</html>
`);
shell.openItem(file);
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="Refresh" content="0; url=${escape(url.href)}" />
<title>Redirecting</title>
<style>
html {
font-family: menu, "Helvetica Neue", sans-serif;
}
</style>
</head>
<body>
<p>Opening <a href="${escape(url.href)}">${escape(url.href)}</a>…</p>
</body>
</html>
`);
await shell.openExternal(file); // Check
setTimeout(() => {
fs.unlinkSync(file);
fs.rmdirSync(dir);
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -181,7 +181,7 @@
"@typescript-eslint/parser": "^2.30.0",
"devtron": "^1.4.0",
"dotenv": "^8.2.0",
"electron": "^8.3.3",
"electron": "^9.0.4",
"electron-builder": "^22.6.0",
"electron-connect": "^0.6.3",
"electron-notarize": "^0.3.0",
Expand Down

0 comments on commit 7907455

Please sign in to comment.