Replace deprecated getWebContents API

This commit is contained in:
Manav Mehta
2020-06-22 14:03:44 +05:30
committed by Anders Kaseorg
parent 6a7f26d7e8
commit e97ab2e6dd
3 changed files with 5 additions and 5 deletions

View File

@@ -216,7 +216,7 @@ export default class WebView extends BaseComponent {
focus(): void { focus(): void {
// Focus Webview and it's contents when Window regain focus. // 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 // HACK: webContents.isFocused() seems to be true even without the element
// being in focus. So, we check against `document.activeElement`. // being in focus. So, we check against `document.activeElement`.
if (webContents && this.$el !== document.activeElement) { if (webContents && this.$el !== document.activeElement) {

View File

@@ -717,7 +717,7 @@ class ServerManagerView {
updateGeneralSettings(setting: string, value: unknown): void { updateGeneralSettings(setting: string, value: unknown): void {
if (this.getActiveWebview()) { if (this.getActiveWebview()) {
const webContents = this.getActiveWebview().getWebContents(); const webContents = remote.webContents.fromId(this.getActiveWebview().getWebContentsId());
webContents.send(setting, value); webContents.send(setting, value);
} }
} }
@@ -917,7 +917,7 @@ class ServerManagerView {
ipcRenderer.on('toggle-dnd', (event: Event, state: boolean, newSettings: DNDSettings) => { ipcRenderer.on('toggle-dnd', (event: Event, state: boolean, newSettings: DNDSettings) => {
this.toggleDNDButton(state); this.toggleDNDButton(state);
ipcRenderer.send('forward-message', 'toggle-silent', newSettings.silent); 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); webContents.send('toggle-dnd', state, newSettings);
}); });
@@ -969,7 +969,7 @@ class ServerManagerView {
ipcRenderer.on('focus-webview-with-id', (event: Event, webviewId: number) => { ipcRenderer.on('focus-webview-with-id', (event: Event, webviewId: number) => {
const webviews: NodeListOf<Electron.WebviewTag> = document.querySelectorAll('webview'); const webviews: NodeListOf<Electron.WebviewTag> = document.querySelectorAll('webview');
webviews.forEach(webview => { webviews.forEach(webview => {
const currentId = webview.getWebContents().id; const currentId = webview.getWebContentsId();
const tabId = webview.getAttribute('data-tab-id'); const tabId = webview.getAttribute('data-tab-id');
const concurrentTab: HTMLButtonElement = document.querySelector(`div[data-tab-id="${tabId}"]`); const concurrentTab: HTMLButtonElement = document.querySelector(`div[data-tab-id="${tabId}"]`);
if (currentId === webviewId) { if (currentId === webviewId) {

View File

@@ -207,7 +207,7 @@ function toggleTray(): void {
const selector = 'webview:not([class*=disabled])'; const selector = 'webview:not([class*=disabled])';
const webview: WebviewTag = document.querySelector(selector); const webview: WebviewTag = document.querySelector(selector);
const webContents = webview.getWebContents(); const webContents = remote.webContents.fromId(webview.getWebContentsId());
webContents.send('toggletray', state); webContents.send('toggletray', state);
} }