Apply so many more lints manually
Some checks failed
Monorepo build / test-all (push) Successful in 20s
Monorepo build / build-flake (push) Failing after 5s

This commit was merged in pull request #431.
This commit is contained in:
2026-08-22 18:32:17 -04:00
parent 00d5a4eee9
commit 0a4fda7be0
19 changed files with 87 additions and 78 deletions

View File

@@ -32,6 +32,6 @@ pub fn measured(_attr: TokenStream, item: TokenStream) -> TokenStream {
}
};
func.block = Box::new(new_block);
*func.block = new_block;
quote! { #func }.into()
}

View File

@@ -13,6 +13,7 @@ pub fn __measured_end(name: &str, start: f64) {
gloo_console::log!(format!("[PERF] {}: {:.3}ms", name, end - start));
}
#[allow(clippy::missing_panics_doc)]
pub fn navigate_to(path: &str) {
match web_sys::window() {
Some(window) => {

View File

@@ -2,9 +2,17 @@ use gloo_net::http::{QueryParams, Request, RequestBuilder, Response};
use http::StatusCode;
use serde::{Serialize, de::DeserializeOwned};
use thiserror::Error;
use visions_types::{SessionId, InvitationId, SPAConfig, AuthRequest, AuthResponse, CreateUserRequest, StartRegisterPasskeyResponse, StartRegisterPasskeyRequest, UserId, FinishRegisterPasskeyRequest, StartPasskeyAuthResponse, AuthenticationId, FinishPasskeyAuthRequest, UserOverview, Invitation, CreateInvitationRequest, GameOverview, GameId, CreateGameRequest, CharacterId, SaveCharacterRequest, CharacterFilter, Location, CardId, CreateCardRequest, Card, UpdateCardRequest, Tabletop, ImageId, SetTabletopImageRequest, SceneFilter, Scene, ImageFilter, Image, ImageAddRequest, CreateSceneRequest, SceneId};
use visions_types::{
AuthRequest, AuthResponse, AuthenticationId, Card, CardId, CharacterFilter, CharacterId,
CreateCardRequest, CreateGameRequest, CreateInvitationRequest, CreateSceneRequest,
CreateUserRequest, FinishPasskeyAuthRequest, FinishRegisterPasskeyRequest, GameId,
GameOverview, Image, ImageAddRequest, ImageFilter, ImageId, Invitation, InvitationId, Location,
SPAConfig, SaveCharacterRequest, Scene, SceneFilter, SceneId, SessionId,
SetTabletopImageRequest, StartPasskeyAuthResponse, StartRegisterPasskeyRequest,
StartRegisterPasskeyResponse, UpdateCardRequest, UserId, UserOverview,
};
use wasm_bindgen::JsValue;
use webauthn_rs_proto::{RegisterPublicKeyCredential, PublicKeyCredential};
use webauthn_rs_proto::{PublicKeyCredential, RegisterPublicKeyCredential};
use crate::systems::{Character, SystemName, UnsupportedGameType};
@@ -350,9 +358,8 @@ impl AuthedClient {
query_params.append("user_id", user_id.as_str());
}
let sheets: Vec<visions_types::Character> = self
.get(&format!("/api/characters?{query_params}"))
.await?;
let sheets: Vec<visions_types::Character> =
self.get(&format!("/api/characters?{query_params}")).await?;
Ok(sheets.into_iter().flat_map(Character::try_from).collect())
}
@@ -373,10 +380,12 @@ impl AuthedClient {
.await
}
/*
pub async fn get_tabletop(&self, game_id: &GameId) -> Result<Tabletop, ClientError> {
self.get(&format!("/api/games/{}/tabletop", game_id.to_string()))
.await
}
*/
pub async fn set_tabletop_image_url(
&self,

View File

@@ -39,7 +39,7 @@ pub fn DragSource(DragSourceProps { item, children }: &DragSourceProps) -> Html
html! {
<div draggable="true" ondragstart={
Callback::from(clone!(item,
move |e: DragEvent| on_drag_item(e, item.clone())
move |e: DragEvent| on_drag_item(&e, &item)
))
}>
{children.clone()}
@@ -47,7 +47,7 @@ pub fn DragSource(DragSourceProps { item, children }: &DragSourceProps) -> Html
}
}
fn on_drag_item(e: DragEvent, item: DraggableItem) {
fn on_drag_item(e: &DragEvent, item: &DraggableItem) {
let result: Result<(), DragError> =
e.data_transfer()
.ok_or(DragError::NoData)
@@ -102,7 +102,7 @@ pub fn DropTarget(
}))}
ondrop={Callback::from(clone!((current_styles, on_drop), move |e: DragEvent| {
current_styles.set(css!());
on_drop_item(e, on_drop.clone());
on_drop_item(&e, &on_drop);
})
)}
class={classes!(class.clone(), (*current_styles).clone())}
@@ -112,7 +112,7 @@ pub fn DropTarget(
}
}
fn on_drop_item(e: DragEvent, callback: Callback<DraggableItem>) {
fn on_drop_item(e: &DragEvent, callback: &Callback<DraggableItem>) {
let result: Result<DraggableItem, DragError> = e
.data_transfer()
.ok_or(DragError::NoData)

View File

@@ -27,8 +27,8 @@ pub use image_table::*;
mod player_list;
pub use player_list::*;
mod swatch;
pub use swatch::*;
// mod swatch;
// pub use swatch::*;
mod tabletop;
pub use tabletop::*;
@@ -37,8 +37,8 @@ mod tooltip;
#[allow(unused)]
pub use tooltip::*;
mod tab_view;
pub use tab_view::*;
// mod tab_view;
// pub use tab_view::*;
mod user_list;
pub use user_list::*;

View File

@@ -152,7 +152,8 @@ fn TabletopLayer(
let height = title_ref
.cast::<HtmlDivElement>()
.map_or(0, |element| element.offset_height());
title_height.set(height as usize);
let height: usize = height.try_into().unwrap_or(0);
title_height.set(height);
}),
);

View File

@@ -10,7 +10,7 @@ use gloo_console::log;
use serde::{Deserialize, Serialize};
use utils::Bounded;
use uuid::Uuid;
use visions_types::{identifier, GameMessage, GameRequest, SessionId};
use visions_types::{GameMessage, GameRequest, SessionId, identifier};
use wasm_sockets::{ConnectionStatus, EventClient, Message};
use web_sys::CloseEvent;
use yew::prelude::*;
@@ -143,6 +143,7 @@ pub struct WebsocketClient {
socket: Rc<RefCell<EventClient>>,
}
#[allow(clippy::missing_fields_in_debug)]
impl fmt::Debug for WebsocketClient {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("WebsocketClient")
@@ -152,7 +153,7 @@ impl fmt::Debug for WebsocketClient {
}
impl WebsocketClient {
pub fn send(&self, message: GameRequest) {
pub fn send(&self, message: &GameRequest) {
let status = { self.socket.borrow().status.borrow().clone() };
if status == ConnectionStatus::Connected {
self.socket

View File

@@ -1,3 +1,4 @@
#![allow(clippy::non_std_lazy_statics)]
use lazy_static::lazy_static;
use stylist::css;
use yew::{Classes, classes};
@@ -141,6 +142,7 @@ pub fn border_invisible() -> Classes {
))
}
/*
pub fn border_primary(hoverable: bool) -> Classes {
classes!(
border_default(hoverable),
@@ -152,7 +154,9 @@ pub fn border_primary(hoverable: bool) -> Classes {
)
)
}
*/
/*
pub fn border_warning(hoverable: bool) -> Classes {
classes!(
border_default(hoverable),
@@ -163,3 +167,4 @@ pub fn border_warning(hoverable: bool) -> Classes {
)
)
}
*/

View File

@@ -18,7 +18,7 @@ use state::StateProvider;
use crate::{
client::UnauthedClient,
views::{Admin, CharacterView, Design, GameDetailsView, GameView, Landing, NewUser},
views::{Admin, CharacterView, GameDetailsView, GameView, Landing, NewUser},
};
#[derive(Clone, Debug, Routable, PartialEq)]
@@ -32,12 +32,11 @@ enum Route {
#[at("/characters/:id")]
Character { id: String },
#[at("/design")]
DesignRoot,
#[at("/design/*")]
Design,
// #[at("/design")]
// DesignRoot,
// #[at("/design/*")]
// Design,
#[at("/game-edit/:id")]
GameEdit { id: String },
@@ -92,7 +91,7 @@ fn switch(route: Route) -> Html {
Route::Character { id } => {
html! { <CharacterView id={Prop::from(CharacterId::from(id))} /> }
}
Route::DesignRoot | Route::Design => html! { <Design /> },
// Route::DesignRoot | Route::Design => html! { <Design /> },
Route::Game { id } => html! { <GameView game_id={Prop::from(GameId::from(id))} /> },
Route::GameEdit { id } => html! { <GameDetailsView id={Prop::from(GameId::from(id))} /> },
Route::NewUser { id } => html! { <NewUser id={InvitationId::from(id)} /> },

View File

@@ -56,15 +56,6 @@ impl AppState {
self.config.enable_passkeys
}
#[deprecated]
pub fn authed_client(&self) -> Option<&AuthedClient> {
if let Client::Authed(client) = &self.connection {
Some(client)
} else {
None
}
}
pub fn client(&self) -> &Client {
&self.connection
}

View File

@@ -92,7 +92,7 @@ pub fn FullSheet(FullSheetProps { sheet, on_save }: &FullSheetProps) -> Html {
(view_state.clone(), on_save.clone()),
|value: String, (state, on_save)| {
let mut sheet = state.character.clone();
sheet.name = value.clone();
sheet.name.clone_from(&value);
on_save.emit(CharacterDetails::Candela(sheet));
},
);
@@ -101,7 +101,7 @@ pub fn FullSheet(FullSheetProps { sheet, on_save }: &FullSheetProps) -> Html {
(view_state.clone(), on_save.clone()),
|value: String, (state, on_save)| {
let mut sheet = state.character.clone();
sheet.role = value.clone();
sheet.role.clone_from(&value);
on_save.emit(CharacterDetails::Candela(sheet));
},
);
@@ -110,7 +110,7 @@ pub fn FullSheet(FullSheetProps { sheet, on_save }: &FullSheetProps) -> Html {
(view_state.clone(), on_save.clone()),
|value: String, (state, on_save)| {
let mut sheet = state.character.clone();
sheet.specialty = value.clone();
sheet.specialty.clone_from(&value);
on_save.emit(CharacterDetails::Candela(sheet));
},
);

View File

@@ -11,6 +11,8 @@ use wasm_bindgen::JsValue;
use yew::prelude::*;
use crate::components::DropMenuOption;
use crate::systems::candela::Candela;
use crate::systems::cypher::Cypher;
#[derive(Debug, Error)]
#[error("Unsupported game type")]
@@ -83,7 +85,8 @@ impl DropMenuOption for SystemName {
SystemName::Cypher => {
html! { <option value="cypher" selected={selected}>{"Cypher System"}</option> }
}
}.clone()
}
.clone()
}
fn from_str(s: &str) -> SystemName {
@@ -133,7 +136,7 @@ impl Character {
// }
// }
pub fn player_sidebar(&self, on_save: Callback<Character>) -> Html {
pub fn player_sidebar(&self, on_save: &Callback<Character>) -> Html {
let on_save = Callback::from({
let character = self.clone();
let on_save = on_save.clone();
@@ -177,7 +180,7 @@ impl Character {
}
}
pub fn full_sheet(&self, on_save: Callback<Character>) -> Html {
pub fn full_sheet(&self, on_save: &Callback<Character>) -> Html {
let on_save: Callback<CharacterDetails> = Callback::from({
let character = self.clone();
let on_save = on_save.clone();
@@ -238,8 +241,8 @@ impl TryFrom<visions_types::Character> for Character {
let details = serde_json::from_slice::<CharacterDetails>(&sheet.data).unwrap_or({
match system {
SystemName::Candela => CharacterDetails::Candela(Default::default()),
SystemName::Cypher => CharacterDetails::Cypher(Default::default()),
SystemName::Candela => CharacterDetails::Candela(Candela::default()),
SystemName::Cypher => CharacterDetails::Cypher(Cypher::default()),
}
});

View File

@@ -6,11 +6,7 @@ pub enum AuthenticationOption {
Password,
}
pub const AUTHENTICATION_OPTIONS: [AuthenticationOption; 2] = [
AuthenticationOption::Passkey,
AuthenticationOption::Password,
];
/*
impl AuthenticationOption {
pub fn id(&self) -> &str {
match self {
@@ -19,6 +15,7 @@ impl AuthenticationOption {
}
}
}
*/
impl From<&str> for AuthenticationOption {
fn from(value: &str) -> Self {
@@ -36,6 +33,7 @@ impl From<AttrValue> for AuthenticationOption {
}
}
/*
#[derive(PartialEq, Properties)]
pub struct AuthenticationOptionElementProps {
pub option: AuthenticationOption,
@@ -50,3 +48,4 @@ pub fn AuthenticationOptionElement(
AuthenticationOption::Password => html! { "Password" },
}
}
*/

View File

@@ -3,12 +3,7 @@ use gloo_console::error;
use visions_types::CharacterId;
use yew::prelude::*;
use crate::{
client::Client,
clone,
state::AppState,
systems::Character,
};
use crate::{client::Client, clone, state::AppState, systems::Character};
#[derive(Properties, PartialEq)]
pub struct CharacterViewProps {
@@ -36,7 +31,7 @@ pub fn CharacterView(CharacterViewProps { id }: &CharacterViewProps) -> Html {
);
match *character_ref {
Some(ref character) => character.full_sheet(on_save),
Some(ref character) => character.full_sheet(&on_save),
_ => html! { <div>{"Loading character sheet"}</div> },
}
}

View File

@@ -1,13 +1,13 @@
use std::rc::Rc;
use glimmer_yew_deprecated::prelude::*;
use visions_types::{GameOverview, GameId, UserOverview, UserId};
use visions_types::{GameId, GameOverview, UserId, UserOverview};
use yew::prelude::*;
use std::collections::HashSet;
use crate::{
client::{Client, ClientError},
client::Client,
clone,
state::AppState,
views::{GmView, PlayerView, SpectatorView},
@@ -150,8 +150,7 @@ fn request_game_overview(client: Client, game_id: GameId, state: UseReducerHandl
match &client {
Client::Authed(authed_client) => match authed_client.game_overview(&game_id).await {
Ok(game) => state.dispatch(StateAction::SetOverview(game)),
Err(ClientError::NotFound) => state.dispatch(StateAction::SetNotFound),
Err(_) => state.dispatch(StateAction::SetNotFound),
_ => state.dispatch(StateAction::SetNotFound),
},
Client::Unauthed(_) => {
// For unauthenticated users, we can't fetch the game overview via REST

View File

@@ -2,8 +2,8 @@ use glimmer_yew_deprecated::prelude::*;
use gloo_console::error;
use stylist::css;
use visions_types::{
Card, CardId, GameId, GameMessage, GameOverview, GameRequest, ImageFilter, ImageId, Location,
SceneId, Tabletop,
Card, CardId, GameId, GameMessage, GameOverview, GameRequest, ImageId, Location, SceneId,
Tabletop,
};
use wasm_sockets::ConnectionStatus;
use yew::prelude::*;
@@ -12,8 +12,8 @@ use crate::{
client::{AuthedClient, Client},
clone,
components::{
CardElement, DragSource, DraggableItem, DropTarget, TabletopElement, WebsocketClient,
WebsocketProvider, WebsocketState, use_websocket,
CardElement, DragSource, DraggableItem, DropTarget, TabletopElement, WebsocketProvider,
WebsocketState, use_websocket,
},
systems::Character,
};
@@ -37,15 +37,15 @@ impl ViewState {
fn new(game_id: GameId) -> Self {
Self {
game_id,
scene_title: Default::default(),
background_url: Default::default(),
scene: Default::default(),
available_scenes: Default::default(),
scene_images: Default::default(),
characters: Default::default(),
tabletop_image: Default::default(),
cards: Default::default(),
sidebar_card: Default::default(),
scene_title: Option::default(),
background_url: Option::default(),
scene: Option::default(),
available_scenes: Vec::default(),
scene_images: Vec::default(),
characters: Vec::default(),
tabletop_image: Option::default(),
cards: Vec::default(),
sidebar_card: Option::default(),
open_to_spectators: false,
}
}
@@ -289,7 +289,7 @@ fn GmView_(
if let Some(ref socket) = socket_state.socket
&& socket_state.status == ConnectionStatus::Connected
{
socket.send(GameRequest::JoinGame(game_id.clone()));
socket.send(&GameRequest::JoinGame(game_id.clone()));
}
}),
);
@@ -535,7 +535,7 @@ fn MenuSidebar(
.map(|image| {
(
AttrValue::from(image.id.to_string()),
render_thumbnail(thumbnail_style.clone(), image.url.clone()),
render_thumbnail(&thumbnail_style, image.url.clone()),
)
})
.collect();
@@ -663,6 +663,7 @@ fn ScenesPage(
}
}
/*
fn get_tabletop(client: AuthedClient, game_id: GameId, state: UseReducerHandle<ViewState>) {
wasm_bindgen_futures::spawn_local(async move {
let Tabletop {
@@ -699,7 +700,9 @@ fn get_tabletop(client: AuthedClient, game_id: GameId, state: UseReducerHandle<V
}
});
}
*/
/*
fn on_drop_handler(
socket: WebsocketClient,
view_state: UseReducerHandle<ViewState>,
@@ -711,7 +714,9 @@ fn on_drop_handler(
DraggableItem::Image(_) => {}
}
}
*/
/*
fn move_card_to(
_socket: WebsocketClient,
_view_state: UseReducerHandle<ViewState>,
@@ -727,7 +732,8 @@ fn move_card_to(
*/
todo!()
}
*/
fn render_thumbnail(styles: Classes, url: String) -> Html {
fn render_thumbnail(styles: &Classes, url: String) -> Html {
html! { <Image class={styles.clone()} {url} /> }
}

View File

@@ -4,8 +4,8 @@ pub use admin::Admin;
mod character;
pub use character::CharacterView;
mod design;
pub use design::Design;
// mod design;
// pub use design::Design;
mod game_view;
pub use game_view::GameView;

View File

@@ -189,7 +189,7 @@ fn Sidebar(
Some(charsheet) => html! {
<>
<DropTarget on_drop={on_drop_on_character}>
{charsheet.player_sidebar(on_save_character.clone())}
{charsheet.player_sidebar(on_save_character)}
<List<Card>
elements={Prop::from(cards)}
on_select={on_select_card}
@@ -228,7 +228,7 @@ fn PlayerView_(
if let Some(ref socket) = socket_state.socket
&& socket_state.status == ConnectionStatus::Connected
{
socket.send(GameRequest::JoinGame(game_id.clone()));
socket.send(&GameRequest::JoinGame(game_id.clone()));
}
},
);

View File

@@ -100,7 +100,7 @@ fn SpectatorView_(SpectatorViewProps_ { state }: &SpectatorViewProps_) -> Html {
if let Some(ref socket) = socket_state.socket
&& socket_state.status == ConnectionStatus::Connected
{
socket.send(GameRequest::JoinGame(game_id.clone()));
socket.send(&GameRequest::JoinGame(game_id.clone()));
}
},
);