Skip to content

Commit 1de4f88

Browse files
committed
webview: Address deprecation of WebContents.goBack et al.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent ab4381a commit 1de4f88

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/renderer/js/components/webview.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ export default class WebView {
184184
}
185185

186186
back(): void {
187-
if (this.getWebContents().canGoBack()) {
188-
this.getWebContents().goBack();
187+
if (this.getWebContents().navigationHistory.canGoBack()) {
188+
this.getWebContents().navigationHistory.goBack();
189189
this.focus();
190190
}
191191
}
@@ -194,12 +194,15 @@ export default class WebView {
194194
const $backButton = document.querySelector(
195195
"#actions-container #back-action",
196196
)!;
197-
$backButton.classList.toggle("disable", !this.getWebContents().canGoBack());
197+
$backButton.classList.toggle(
198+
"disable",
199+
!this.getWebContents().navigationHistory.canGoBack(),
200+
);
198201
}
199202

200203
forward(): void {
201-
if (this.getWebContents().canGoForward()) {
202-
this.getWebContents().goForward();
204+
if (this.getWebContents().navigationHistory.canGoForward()) {
205+
this.getWebContents().navigationHistory.goForward();
203206
}
204207
}
205208

0 commit comments

Comments
 (0)