Skip to content

Commit

Permalink
refactor: simplify handle_event_loop
Browse files Browse the repository at this point in the history
  • Loading branch information
geieredgar committed Jun 7, 2021
1 parent 5cba6eb commit 010bcdc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changes/simplify-handle-event-loop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-runtime-wry": patch
---

Update `wry` to v0.9.x and Replace `dispatch_script` and `evaluate_script` with `eval` in `handle_event_loop`.
2 changes: 1 addition & 1 deletion core/tauri-runtime-wry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
readme = "README.md"

[dependencies]
wry = { version = "0.9.2", default-features = false, features = [ "file-drop", "protocol", "win32" ] }
wry = { version = "0.9.x", default-features = false, features = [ "file-drop", "protocol", "win32" ] }
tauri-runtime = { version = "0.1.1", path = "../tauri-runtime" }
tauri-utils = { version = "1.0.0-beta.0", path = "../tauri-utils" }
uuid = { version = "0.8.2", features = [ "v4" ] }
Expand Down
10 changes: 3 additions & 7 deletions core/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,12 +1167,6 @@ fn handle_event_loop(
} = context;
*control_flow = ControlFlow::Wait;

for (_, w) in webviews.iter() {
if let Err(e) = w.inner.evaluate_script() {
eprintln!("{}", e);
}
}

match event {
#[cfg(feature = "menu")]
Event::MenuEvent {
Expand Down Expand Up @@ -1362,7 +1356,9 @@ fn handle_event_loop(
if let Some(webview) = webviews.get_mut(&id) {
match webview_message {
WebviewMessage::EvaluateScript(script) => {
let _ = webview.inner.dispatch_script(&script);
if let Err(e) = webview.inner.eval(&script) {
eprintln!("{}", e);
}
}
WebviewMessage::Print => {
let _ = webview.inner.print();
Expand Down

0 comments on commit 010bcdc

Please sign in to comment.