scripting: soft and hard reload

This commit is contained in:
jean-emmanuel 2022-11-07 13:07:02 +01:00
parent a77a9c01dd
commit a90211223f
2 changed files with 6 additions and 4 deletions

View file

@ -352,8 +352,9 @@ Run `callback` function as if executed by another that widget matches specified
----
#### `reload()`
#### `reload(keepState)`
- `keepState` (optional): `true` by default, set to false to discard the client's state.
Reload the client application (retains session and state). Cannot be called from the `onCreate` property.
Reload the client application. Cannot be called from the `onCreate` property.
If the event that triggered the script's execution was not initiated by a user interaction, this function will have no effect.

View file

@ -530,7 +530,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.reload = ()=>{
this.sandbox.contentWindow.reload = (keepState = true)=>{
this.checkContext('reload')
@ -540,7 +540,8 @@ class ScriptVm extends Vm {
var widget = this.getWidget()
widget.errorProp('onCreate', '', 'reload() cannot be called from onCreate')
} else if (options.send){
ipc.trigger('reload')
if (keepState) ipd.trigger('reload')
else window.location.href = window.location.href
}