From 1de4f88c6cee28216f936d37f1823527d1f15458 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 27 Feb 2025 17:04:06 -0800 Subject: [PATCH] webview: Address deprecation of WebContents.goBack et al. Signed-off-by: Anders Kaseorg --- app/renderer/js/components/webview.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/renderer/js/components/webview.ts b/app/renderer/js/components/webview.ts index 90d782f2..b6d656f8 100644 --- a/app/renderer/js/components/webview.ts +++ b/app/renderer/js/components/webview.ts @@ -184,8 +184,8 @@ export default class WebView { } back(): void { - if (this.getWebContents().canGoBack()) { - this.getWebContents().goBack(); + if (this.getWebContents().navigationHistory.canGoBack()) { + this.getWebContents().navigationHistory.goBack(); this.focus(); } } @@ -194,12 +194,15 @@ export default class WebView { const $backButton = document.querySelector( "#actions-container #back-action", )!; - $backButton.classList.toggle("disable", !this.getWebContents().canGoBack()); + $backButton.classList.toggle( + "disable", + !this.getWebContents().navigationHistory.canGoBack(), + ); } forward(): void { - if (this.getWebContents().canGoForward()) { - this.getWebContents().goForward(); + if (this.getWebContents().navigationHistory.canGoForward()) { + this.getWebContents().navigationHistory.goForward(); } }