fix: resolve clippy warnings
This commit is contained in:
1 parent
0ec95e51e4
commit
4f597d04b2
12 files changed
+48
-42
No files matched your search
+7
-11
@@ -147,7 +147,7 @@ impl App {
|
||||
self.screenshots_state.request_visible_loads();
|
||||
self.create_screenshot_protocols();
|
||||
self.throbber_tick = self.throbber_tick.wrapping_add(1);
|
||||
if self.throbber_tick % 8 == 0 {
|
||||
if self.throbber_tick.is_multiple_of(8) {
|
||||
self.throbber_state.calc_next();
|
||||
}
|
||||
|
||||
@@ -241,13 +241,10 @@ impl App {
|
||||
let mut next_y: u16 = 1;
|
||||
for event in all_errors {
|
||||
let elapsed_ms = event.pushed_at.elapsed().as_millis();
|
||||
match popup_area(frame.area(), &event.message, next_y, elapsed_ms) {
|
||||
Some(area) => {
|
||||
next_y = next_y.saturating_add(area.height + 1);
|
||||
frame.render_widget(ErrorPopup::new(event.clone()), area);
|
||||
self.render_error_effect(frame, area, &event, elapsed_ms);
|
||||
}
|
||||
None => {}
|
||||
if let Some(area) = popup_area(frame.area(), &event.message, next_y, elapsed_ms) {
|
||||
next_y = next_y.saturating_add(area.height + 1);
|
||||
frame.render_widget(ErrorPopup::new(event.clone()), area);
|
||||
self.render_error_effect(frame, area, &event, elapsed_ms);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,11 +392,10 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
if self.focused == FocusedArea::Account {
|
||||
if widgets::account::handle_key(&key_event, &mut self.account_state) {
|
||||
if self.focused == FocusedArea::Account
|
||||
&& widgets::account::handle_key(&key_event, &mut self.account_state) {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
if self.focused == FocusedArea::Settings {
|
||||
match widgets::details::handle_key(
|
||||
|
||||
@@ -62,6 +62,7 @@ impl ContentTab {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn render(
|
||||
frame: &mut Frame,
|
||||
area: Rect,
|
||||
|
||||
@@ -16,6 +16,8 @@ use crate::instance::mods::ModEntry;
|
||||
use crate::tui::theme::THEME;
|
||||
|
||||
type IconCell = (u8, u8, u8, u8, u8, u8);
|
||||
type PendingContent = Arc<Mutex<Option<(String, Vec<ModEntry>)>>>;
|
||||
type SnapshotRow = (String, String, bool, Option<Vec<Vec<IconCell>>>);
|
||||
|
||||
struct CachedList {
|
||||
entries: Vec<ModEntry>,
|
||||
@@ -30,7 +32,7 @@ pub struct ContentListState {
|
||||
pub loading: bool,
|
||||
pub search: super::search::SearchState,
|
||||
cache: HashMap<String, CachedList>,
|
||||
pending: Arc<Mutex<Option<(String, Vec<ModEntry>)>>>,
|
||||
pending: PendingContent,
|
||||
}
|
||||
|
||||
impl Default for ContentListState {
|
||||
@@ -338,7 +340,7 @@ pub fn render(
|
||||
|
||||
let count = filtered.len();
|
||||
|
||||
let snapshot: Vec<(String, String, bool, Option<Vec<Vec<IconCell>>>)> = filtered
|
||||
let snapshot: Vec<SnapshotRow> = filtered
|
||||
.iter()
|
||||
.map(|&i| {
|
||||
let entry = &state.entries[i];
|
||||
|
||||
@@ -14,6 +14,8 @@ use tui_widget_list::{ListBuilder, ListState as TuiListState, ListView};
|
||||
use crate::instance::log_files::{read_log_file, scan_log_files, LogFileEntry};
|
||||
use crate::tui::theme::THEME;
|
||||
|
||||
type PendingLogs = Arc<Mutex<Option<(String, Vec<LogFileEntry>)>>>;
|
||||
|
||||
pub struct LogsState {
|
||||
pub entries: Vec<LogFileEntry>,
|
||||
pub list_state: TuiListState,
|
||||
@@ -28,7 +30,7 @@ pub struct LogsState {
|
||||
pub search: super::search::SearchState,
|
||||
pub viewer_search: super::search::SearchState,
|
||||
selected_path: Option<std::path::PathBuf>,
|
||||
pending: Arc<Mutex<Option<(String, Vec<LogFileEntry>)>>>,
|
||||
pending: PendingLogs,
|
||||
rescan_counter: u8,
|
||||
instances_dir_cache: Option<std::path::PathBuf>,
|
||||
}
|
||||
@@ -116,7 +118,7 @@ impl LogsState {
|
||||
|
||||
pub fn try_rescan(&mut self) {
|
||||
self.rescan_counter = self.rescan_counter.wrapping_add(1);
|
||||
if self.rescan_counter % 120 != 0 {
|
||||
if !self.rescan_counter.is_multiple_of(120) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,15 @@ use ratatui::{
|
||||
|
||||
use crate::tui::theme::THEME;
|
||||
|
||||
type ContentFn<'a> = Box<dyn Fn(Rect, &mut Buffer) + 'a>;
|
||||
|
||||
pub struct PopupFrame<'a> {
|
||||
pub title: Line<'a>,
|
||||
pub border_color: Color,
|
||||
pub bg: Option<Color>,
|
||||
pub keybinds: Option<Line<'a>>,
|
||||
pub search_line: Option<Line<'a>>,
|
||||
pub content: Box<dyn Fn(Rect, &mut Buffer) + 'a>,
|
||||
pub content: ContentFn<'a>,
|
||||
}
|
||||
|
||||
impl<'a> Widget for PopupFrame<'a> {
|
||||
|
||||
@@ -42,18 +42,15 @@ pub enum WizardStep {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Default)]
|
||||
pub enum LoadState<T> {
|
||||
#[default]
|
||||
Idle,
|
||||
Loading,
|
||||
Loaded(T),
|
||||
Error(String),
|
||||
}
|
||||
|
||||
impl<T> Default for LoadState<T> {
|
||||
fn default() -> Self {
|
||||
LoadState::Idle
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct WizardState {
|
||||
@@ -255,7 +252,7 @@ fn handle_name_key(
|
||||
state.step = WizardStep::Loader;
|
||||
}
|
||||
_ => {
|
||||
state.name_state.handle_key_event(key_event.clone());
|
||||
state.name_state.handle_key_event(*key_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -785,7 +782,7 @@ fn compare_semver(a: &str, b: &str) -> std::cmp::Ordering {
|
||||
a_parts.len().cmp(&b_parts.len())
|
||||
}
|
||||
|
||||
fn sort_versions_semver(versions: &mut Vec<GameVersion>) {
|
||||
fn sort_versions_semver(versions: &mut [GameVersion]) {
|
||||
// Sort newest first (descending), so compare b vs a
|
||||
versions.sort_by(|a, b| compare_semver(&b.id, &a.id));
|
||||
}
|
||||
@@ -21,6 +21,8 @@ const MAX_CELL_WIDTH: u16 = 52;
|
||||
const NAME_ROW_HEIGHT: u16 = 1;
|
||||
const GAP: u16 = 1;
|
||||
|
||||
type PendingScreenshots = Arc<Mutex<Option<(String, Vec<ScreenshotEntry>)>>>;
|
||||
|
||||
pub struct ScreenshotsState {
|
||||
pub entries: Vec<ScreenshotEntry>,
|
||||
protocols: HashMap<usize, StatefulProtocol>,
|
||||
@@ -34,7 +36,7 @@ pub struct ScreenshotsState {
|
||||
pub scrollbar_state: ScrollbarState,
|
||||
pub search: super::search::SearchState,
|
||||
pub font_size: (u16, u16),
|
||||
pending_entries: Arc<Mutex<Option<(String, Vec<ScreenshotEntry>)>>>,
|
||||
pending_entries: PendingScreenshots,
|
||||
pending_images: Arc<Mutex<Vec<(usize, image::DynamicImage)>>>,
|
||||
}
|
||||
|
||||
@@ -167,7 +169,7 @@ impl ScreenshotsState {
|
||||
if self.cols == 0 {
|
||||
return 0;
|
||||
}
|
||||
(self.entries.len() + self.cols - 1) / self.cols
|
||||
self.entries.len().div_ceil(self.cols)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user