* Load a new URL in the webview. * @param newUrl The new URL to load in the webview.
(newUrl: string, reason: string)
| 429 | * @param newUrl The new URL to load in the webview. |
| 430 | */ |
| 431 | loadUrl(newUrl: string, reason: string) { |
| 432 | const defaultSearchAtom = this.env.getSettingsKeyAtom("web:defaultsearch"); |
| 433 | const searchTemplate = globalStore.get(defaultSearchAtom); |
| 434 | const nextUrl = this.ensureUrlScheme(newUrl, searchTemplate); |
| 435 | console.log("webview loadUrl", reason, nextUrl, "cur=", this.webviewRef.current.getURL()); |
| 436 | if (!this.webviewRef.current) { |
| 437 | return; |
| 438 | } |
| 439 | if (this.webviewRef.current.getURL() != nextUrl) { |
| 440 | fireAndForget(() => this.webviewRef.current.loadURL(nextUrl)); |
| 441 | } |
| 442 | if (newUrl != nextUrl) { |
| 443 | globalStore.set(this.url, nextUrl); |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | /** |
| 448 | * Load a new URL in the webview and return a promise. |
no test coverage detected