diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 9ec2220..92c4e0d 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -180,6 +180,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bitflags" version = "1.3.2" @@ -3718,12 +3724,15 @@ dependencies = [ [[package]] name = "tokio-gemini" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5aea8fd82d63287b051d76b86e0497105564cb8fa269d43bf369a2d1b93bb5d" +checksum = "bab37428a69ae0349cf6dd0182a6da06f065aa8c40ca18d9414a02e6fb49d875" dependencies = [ + "base64ct", + "bytes", "mime", "num_enum 0.7.3", + "sha2", "tokio", "tokio-rustls", "url", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index c27bfb6..867512e 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -36,7 +36,7 @@ tokio-rustls = { version = "0.26.0", default-features = false, features = [ bytes = "1.7.1" reqwest = "0.12.5" -tokio-gemini = "0.1.0" +tokio-gemini = "0.3.0" url = "2.5.2" mime = "0.3.17" diff --git a/src-tauri/src/process_input/process_url.rs b/src-tauri/src/process_input/process_url.rs index 425f1ad..e707d7d 100644 --- a/src-tauri/src/process_input/process_url.rs +++ b/src-tauri/src/process_input/process_url.rs @@ -1,9 +1,7 @@ use crate::types::VigiError; -use bytes::Bytes; use insecure_gemini_client::insecure_gemini_client_config; use mime::Mime; use reqwest::header::CONTENT_TYPE; -use tokio::io::AsyncReadExt; use url::Url; use super::{insecure_gemini_client, ReqResult}; @@ -47,13 +45,8 @@ async fn process_gemini(url: String) -> Result { let mime_type = res.mime().map_err(|_| VigiError::InvalidMimeType)?; - let mut buffer = Vec::new(); - - let tls_stream = res.body(); - tls_stream - .read_to_end(&mut buffer) - .await - .map_err(|_| VigiError::Network)?; - - Ok((mime_type, Bytes::from(buffer).into())) + Ok(( + mime_type, + res.bytes().await.map_err(|_| VigiError::Network)?.into(), + )) } diff --git a/src-tauri/src/types.rs b/src-tauri/src/types.rs index d4454b3..a492924 100644 --- a/src-tauri/src/types.rs +++ b/src-tauri/src/types.rs @@ -199,16 +199,19 @@ impl VigiState { } pub fn remove_tab(&mut self, index: usize) -> Result<(), VigiError> { - if self.current_tab_index >= index { - if self.current_tab_index > 0 { - self.select_tab(self.current_tab_index - 1)?; - } - } - self.cached_inputs .remove(&self.tabs.get(index).ok_or(VigiError::GetTab)?.url); self.tabs.remove(index); + + if self.current_tab_index >= index { + if self.current_tab_index > 0 { + self.select_tab(self.current_tab_index - 1)?; + } else { + self.update_top_bar_input(); + } + } + write_tabs(&self.local_tabs_path, &self.tabs)?; Ok(())