mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-26 01:23:32 +00:00
Replace deprecated getWebContents API
This commit is contained in:
committed by
Anders Kaseorg
parent
6a7f26d7e8
commit
e97ab2e6dd
@@ -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) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user