-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Use format_callback::format_raw for channels
#13288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use format_callback::format_raw for channels
#13288
Conversation
Package Changes Through 7900367There are 4 changes which include tauri with minor, @tauri-apps/api with minor, tauri-cli with patch, @tauri-apps/cli with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
crates/tauri/src/ipc/channel.rs
Outdated
| let _ = webview_clone.eval(format!( | ||
| "window['_{callback_id}']({{ end: true, index: {current_index} }})", | ||
| )); | ||
| let _ = webview_clone.eval(format!("window['_{callback_id}']()",)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand this change, is this some left over code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just a mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then why don't we remove it? let _ = webview_clone.eval(format!("",)); doesn't make sense either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, misunderstood. Fixed.
|
Also a change file like this one would be nice 🙃 |
|
I have applied the fixes and added a changelog. I have been unable to test these changes as when I run Following the |
What if you build the API and CLI and then go to the example/api directory and run |
The following works: Thanks for your help! |
|
Nice catch, good work 🙃 |
Right now when reloading the webview a channel from the previous page might fire. This will cause some JS code similar to
window[_some_id](...)to be injected into the page. Whenwindow[_some_id]evaluates it will beundefinedas the webview context was reset when the page was reloaded. This will cause the webview to crash, sometimes taking out other JS running on the page with it.This fix makes use of the existing
format_callback::format_rawfor parsing data back to the webview which has graceful handling on this condition.