mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
iOS: Work around webview reload bug
This commit is contained in:
parent
91a1353ef3
commit
442c918dea
@ -87,6 +87,14 @@ const ExtendedWebView = (props: Props, ref: Ref<WebViewControl>) => {
|
||||
return Setting.value('env') === 'dev' || (!!props.hasPluginScripts && Setting.value('plugins.enableWebviewDebugging'));
|
||||
}, [props.hasPluginScripts]);
|
||||
|
||||
const [reloadCounter, setReloadCounter] = useState(0);
|
||||
const refreshWebView = useCallback(() => {
|
||||
// Reload the WebView after a brief delay. See https://github.com/react-native-webview/react-native-webview/issues/3524
|
||||
shim.setTimeout(() => {
|
||||
setReloadCounter(counter => counter + 1);
|
||||
}, 150);
|
||||
}, []);
|
||||
|
||||
// - `setSupportMultipleWindows` must be `true` for security reasons:
|
||||
// https://github.com/react-native-webview/react-native-webview/releases/tag/v11.0.0
|
||||
|
||||
@ -99,6 +107,7 @@ const ExtendedWebView = (props: Props, ref: Ref<WebViewControl>) => {
|
||||
// (the default deaccelerates too quickly).
|
||||
return (
|
||||
<WebView
|
||||
key={`webview-${reloadCounter}`}
|
||||
style={{
|
||||
// `backgroundColor: transparent` prevents a white fhash on iOS.
|
||||
// It seems that `backgroundColor: theme.backgroundColor` does not
|
||||
@ -123,6 +132,8 @@ const ExtendedWebView = (props: Props, ref: Ref<WebViewControl>) => {
|
||||
onMessage={props.onMessage}
|
||||
onError={props.onError ?? onError}
|
||||
onLoadEnd={props.onLoadEnd}
|
||||
onContentProcessDidTerminate={refreshWebView}
|
||||
onRenderProcessGone={refreshWebView}
|
||||
decelerationRate='normal'
|
||||
/>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user