Silence warnings, run cargo fmt

This commit is contained in:
Evan Carroll 2026-01-18 16:27:31 -06:00
parent fe1c1d3655
commit af1c767f5f
77 changed files with 1904 additions and 903 deletions

View file

@ -99,8 +99,8 @@ fn RenderedPreview(#[prop(into)] avatar: Signal<Option<AvatarWithPaths>>) -> imp
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use wasm_bindgen::closure::Closure;
use wasm_bindgen::JsCast;
use wasm_bindgen::closure::Closure;
let image_cache: Rc<RefCell<HashMap<String, web_sys::HtmlImageElement>>> =
Rc::new(RefCell::new(HashMap::new()));
@ -134,36 +134,37 @@ fn RenderedPreview(#[prop(into)] avatar: Signal<Option<AvatarWithPaths>>) -> imp
ctx.fill_rect(0.0, 0.0, canvas_size as f64, canvas_size as f64);
// Helper to load and draw an image at a grid position
let draw_at_position = |path: &str,
pos: usize,
cache: &Rc<RefCell<HashMap<String, web_sys::HtmlImageElement>>>,
ctx: &web_sys::CanvasRenderingContext2d| {
let normalized_path = normalize_asset_path(path);
let mut cache_borrow = cache.borrow_mut();
let row = pos / 3;
let col = pos % 3;
let x = (col * cell_size) as f64;
let y = (row * cell_size) as f64;
let size = cell_size as f64;
let draw_at_position =
|path: &str,
pos: usize,
cache: &Rc<RefCell<HashMap<String, web_sys::HtmlImageElement>>>,
ctx: &web_sys::CanvasRenderingContext2d| {
let normalized_path = normalize_asset_path(path);
let mut cache_borrow = cache.borrow_mut();
let row = pos / 3;
let col = pos % 3;
let x = (col * cell_size) as f64;
let y = (row * cell_size) as f64;
let size = cell_size as f64;
if let Some(img) = cache_borrow.get(&normalized_path) {
if img.complete() && img.natural_width() > 0 {
let _ = ctx.draw_image_with_html_image_element_and_dw_and_dh(
img, x, y, size, size,
);
if let Some(img) = cache_borrow.get(&normalized_path) {
if img.complete() && img.natural_width() > 0 {
let _ = ctx.draw_image_with_html_image_element_and_dw_and_dh(
img, x, y, size, size,
);
}
} else {
let img = web_sys::HtmlImageElement::new().unwrap();
let trigger = set_redraw_trigger;
let onload = Closure::once(Box::new(move || {
trigger.update(|v| *v += 1);
}) as Box<dyn FnOnce()>);
img.set_onload(Some(onload.as_ref().unchecked_ref()));
onload.forget();
img.set_src(&normalized_path);
cache_borrow.insert(normalized_path, img);
}
} else {
let img = web_sys::HtmlImageElement::new().unwrap();
let trigger = set_redraw_trigger;
let onload = Closure::once(Box::new(move || {
trigger.update(|v| *v += 1);
}) as Box<dyn FnOnce()>);
img.set_onload(Some(onload.as_ref().unchecked_ref()));
onload.forget();
img.set_src(&normalized_path);
cache_borrow.insert(normalized_path, img);
}
};
};
// Draw layers in order: skin -> clothes -> accessories -> current emotion
for (pos, path) in av.skin_layer.iter().enumerate() {
@ -252,7 +253,7 @@ pub fn AvatarEditorPopup(
let (context_menu, set_context_menu) = signal(Option::<ContextMenuState>::None);
// Saving state
let (saving, set_saving) = signal(false);
let (_saving, set_saving) = signal(false);
// Helper to get current layer name for API calls
let get_current_layer_name = move || -> String {
@ -290,8 +291,9 @@ pub fn AvatarEditorPopup(
let response = Request::get("/api/inventory").send().await;
match response {
Ok(resp) if resp.ok() => {
if let Ok(data) =
resp.json::<chattyness_db::models::InventoryResponse>().await
if let Ok(data) = resp
.json::<chattyness_db::models::InventoryResponse>()
.await
{
set_inventory_items.set(data.items);
set_inventory_loaded.set(true);
@ -353,8 +355,14 @@ pub fn AvatarEditorPopup(
item.layer
.map(|l| match (l, layer) {
(chattyness_db::models::AvatarLayer::Skin, BaseLayer::Skin) => true,
(chattyness_db::models::AvatarLayer::Clothes, BaseLayer::Clothes) => true,
(chattyness_db::models::AvatarLayer::Accessories, BaseLayer::Accessories) => true,
(
chattyness_db::models::AvatarLayer::Clothes,
BaseLayer::Clothes,
) => true,
(
chattyness_db::models::AvatarLayer::Accessories,
BaseLayer::Accessories,
) => true,
_ => false,
})
.unwrap_or(false)