Fix up the warnings

This commit is contained in:
2026-03-20 11:21:28 -04:00
parent 187633c533
commit 9c3b61a365
3 changed files with 17 additions and 19 deletions

View File

@@ -76,11 +76,11 @@ impl Application {
ui.horizontal(|ui| {
ui.label("Save location: ");
ui.label(self.download_path.as_deref().unwrap_or("None"));
if ui.button("Browse").clicked() {
if let Some(path) = rfd::FileDialog::new().pick_folder() {
if ui.button("Browse").clicked()
&& let Some(path) = rfd::FileDialog::new().pick_folder()
{
self.download_path = Some(path.display().to_string());
}
}
});
ui.horizontal(|ui| {
@@ -143,7 +143,7 @@ impl Application {
);
let img = ColorImage::from_rgb(
[1, 1],
&img_data.as_bytes(),
img_data.as_bytes(),
);
let handle = ctx.load_texture(
format!("preview_{}", file.name),

View File

@@ -11,7 +11,7 @@ async fn main() {
eframe::run_native(
"File-serve GUI v3",
options,
Box::new(|cc| Ok(Box::new(app::Application::new(&cc)))),
Box::new(|cc| Ok(Box::new(app::Application::new(cc)))),
)
.expect("Failed to start application");
}

View File

@@ -1,5 +1,3 @@
use std::ops::Deref;
use crate::util::clamp;
use eframe::egui;
use serde::Deserialize;
@@ -33,7 +31,7 @@ pub struct SearchContext {
pub is_searching: bool,
pub server_url: String,
pub query: String,
search_rx: Option<mpsc::Receiver<Result<(Vec<FileEntry>, Metadata), String>>>,
search_rx: Option<mpsc::Receiver<Result<Root, String>>>,
pub search_results: Vec<FileEntry>,
pub page: usize,
pub per_page: usize,
@@ -77,11 +75,11 @@ impl SearchContext {
}
pub fn start_search(&mut self) -> String {
let page = self.page.clone();
let page_size = self.per_page.clone();
let page = self.page;
let page_size = self.per_page;
let query = self.query.clone();
let url = self.server_url.clone();
let (tx, rx) = mpsc::channel::<Result<(Vec<FileEntry>, Metadata), String>>(1);
let (tx, rx) = mpsc::channel::<Result<Root, String>>(1);
self.search_rx = Some(rx);
self.is_searching = true;
@@ -105,13 +103,13 @@ impl SearchContext {
let mut clear_rx = false;
if let Some(rx) = self.search_rx.as_mut() {
match rx.try_recv() {
Ok(Ok(results)) => {
Ok(Ok(root)) => {
// Ok recv, ok results
self.search_results = results.0.clone();
self.search_results = root.results.clone();
return_str = "Ready!".to_string();
self.total_pages = results.1.total_pages;
self.page = results.1.page;
self.per_page = results.1.page_size;
self.total_pages = root.metadata.total_pages;
self.page = root.metadata.page;
self.per_page = root.metadata.page_size;
self.is_searching = false;
clear_rx = true;
}
@@ -145,7 +143,7 @@ pub async fn search_files(
query: String,
page: usize,
page_size: usize,
) -> Result<(Vec<FileEntry>, Metadata), String> {
) -> Result<Root, String> {
let full_url = format!("{}?q={}&p={}&s={}", url, query, page, page_size);
let client = match reqwest::Client::builder()
@@ -178,5 +176,5 @@ pub async fn search_files(
}
};
Ok((results.results, results.metadata))
Ok(results)
}