Clippy code cleanup

This commit is contained in:
2026-08-15 13:22:59 +03:00
parent 9917702c4c
commit e676898135
22 changed files with 290 additions and 171 deletions
+23 -21
View File
@@ -1,9 +1,12 @@
use crate::data_provider::history::{get_history_of_set, history_dir};
use crate::data_provider::sqlite::{create_db, default_connection};
use crate::data_provider::web_api::{get_local_version, get_web_version, load_data, set_local_version};
use crate::dictionary::{app_data_dir, DictionaryMessage, DictionaryState};
use crate::data_provider::web_api::{
get_local_version, get_web_version, load_data, set_local_version,
};
use crate::dictionary::{DictionaryMessage, DictionaryState, app_data_dir};
use crate::dictionary_test::{DictionaryQuizMessage, DictionaryQuizState};
use crate::history::{HistoryMessage, HistoryState};
use crate::import::{ImportMessage, ImportState};
use crate::message_navigation;
use crate::navigation::Page::*;
use crate::navigation::RootMessage::{DataLoaded, Keyboard, UpdateData};
@@ -27,7 +30,6 @@ use reqwest::Error;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::time::Instant;
use crate::import::{ImportMessage, ImportState};
impl Default for ScreenState {
fn default() -> Self {
@@ -99,7 +101,9 @@ impl ScreenState {
final_task = Task::batch([
reading_additional_task,
Task::perform(Self::load_web_backup(key), |result| {
if let Ok(update) = result && update {
if let Ok(update) = result
&& update
{
UpdateData
} else {
RootMessage::None
@@ -118,23 +122,21 @@ impl ScreenState {
async fn load_additional_data() -> RootMessage {
let directory = history_dir();
let mut map = HashMap::new();
for file in directory.read_dir().unwrap() {
if let Ok(file) = file {
let mut vec = vec![];
let history_file_name = file.file_name().into_string().unwrap();
let id = history_file_name[4..history_file_name.len() - 12]
.parse::<u32>()
.unwrap();
for file in directory.read_dir().unwrap().flatten() {
let mut vec = vec![];
let history_file_name = file.file_name().into_string().unwrap();
let id = history_file_name[4..history_file_name.len() - 12]
.parse::<u32>()
.unwrap();
let history = get_history_of_set(id);
let by_date = history.chunk_by(|x, x1| {
x.timestamp.naive_local().date() == x1.timestamp.naive_local().date()
});
for group in by_date {
vec.push((group[0].timestamp.naive_local().date(), group.len() as u32));
}
map.insert(id, vec);
let history = get_history_of_set(id);
let by_date = history.chunk_by(|x, x1| {
x.timestamp.naive_local().date() == x1.timestamp.naive_local().date()
});
for group in by_date {
vec.push((group[0].timestamp.naive_local().date(), group.len() as u32));
}
map.insert(id, vec);
}
DataLoaded(map)
}
@@ -146,7 +148,7 @@ impl ScreenState {
println!("Web version is newer than local version");
load_data(string, true).await;
set_local_version(web).await;
}else {
} else {
return Ok(false);
}
Ok(true)
@@ -164,7 +166,7 @@ impl ScreenState {
return Task::none();
}
if let UpdateData = message{
if let UpdateData = message {
println!("Loading data");
let mut state = self.app_state.lock().unwrap();
let path = app_data_dir();