Browse Source

fix async on linux

Lucas Nogueira 1 year ago
parent
commit
a1fae1baf3
2 changed files with 11 additions and 1 deletions
  1. 10 0
      core/tauri/src/ipc/protocol.rs
  2. 1 1
      examples/api/src-tauri/src/cmd.rs

+ 10 - 0
core/tauri/src/ipc/protocol.rs

@@ -48,6 +48,16 @@ pub fn get<R: Runtime>(manager: Arc<AppManager<R>>, label: String) -> UriSchemeP
     match *request.method() {
       Method::POST => {
         if let Some(webview) = manager.get_webview(&label) {
+          #[cfg(target_os = "linux")]
+          let respond = {
+            let webview_ = webview.clone();
+            move |response| {
+              let _ = webview_.run_on_main_thread(move || {
+                respond(response);
+              });
+            }
+          };
+
           match parse_invoke_request(&manager, request) {
             Ok(request) => {
               #[cfg(feature = "tracing")]

+ 1 - 1
examples/api/src-tauri/src/cmd.rs

@@ -47,6 +47,6 @@ pub fn perform_request(endpoint: String, body: RequestBody) -> ApiResponse {
 }
 
 #[command]
-pub fn download() -> Vec<u8> {
+pub async fn download() -> Vec<u8> {
   vec![1, 2, 3]
 }