mirror of
https://github.com/TxtDot/vigi.git
synced 2024-12-03 16:26:21 +03:00
fix: tab removing
This commit is contained in:
parent
135cb5c1a2
commit
60534158d7
4 changed files with 25 additions and 20 deletions
13
src-tauri/Cargo.lock
generated
13
src-tauri/Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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<ReqResult, VigiError> {
|
|||
|
||||
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(),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
|
|
Loading…
Add table
Reference in a new issue