diff --git a/src/data_provider/card_stats.rs b/src/data_provider/card_stats.rs index 625c793..bddae92 100644 --- a/src/data_provider/card_stats.rs +++ b/src/data_provider/card_stats.rs @@ -39,28 +39,6 @@ pub fn add_stat(stat: &mut CardStatistics, connection: &Connection) { stat.id = index; } -pub fn update_stat(stat: &mut CardStatistics, connection: &Connection){ - if stat.id == 0 { - add_stat(stat, &connection); - } - - else { - connection - .execute( - "UPDATE card_stats SET word_id = ?1, set_id = ?2, score = ?3, last_opened = ?4 WHERE id = ?5", - ( - &stat.word_id, - &stat.set_id, - &stat.score, - &stat.last_open, - &stat.id - ), - ) - .unwrap_or_else(|e| {println!("{}", e); 0}); - } -} - - pub fn update_stat_score(stat: &CardStatistics, connection: &Connection){ connection .execute( diff --git a/src/data_provider/voice.rs b/src/data_provider/voice.rs index 89ad580..8ef9e26 100644 --- a/src/data_provider/voice.rs +++ b/src/data_provider/voice.rs @@ -1,9 +1,8 @@ use crate::dictionary::app_data_dir; -use rodio::Decoder; +use reqwest::Client; use sha2::{Digest, Sha256}; use std::fs::File; use std::io::BufReader; -use reqwest::Client; pub async fn get_voice(text: &str) -> BufReader { let mut path = app_data_dir(); diff --git a/src/data_provider/words.rs b/src/data_provider/words.rs index b81d89e..5202248 100644 --- a/src/data_provider/words.rs +++ b/src/data_provider/words.rs @@ -124,13 +124,13 @@ pub fn load_words(connection: &Connection) -> Vec { .unwrap(); let word_iter = stmt .query_map([], |row| { - let addinionals: String = row.get(4)?; + let additional: String = row.get(4)?; Ok(WordData { id: row.get(0)?, key: row.get(1)?, value: row.get(2)?, tags: row.get(3)?, - additional: serde_json::from_str::>(&addinionals).unwrap(), + additional: serde_json::from_str::>(&additional).unwrap(), group_id: row.get(5)?, }) }) diff --git a/src/lang.rs b/src/lang.rs index e0ad0de..a8b8bfb 100644 --- a/src/lang.rs +++ b/src/lang.rs @@ -397,7 +397,7 @@ impl CardSet { } fn history_len(&self) -> usize { - return min(MAX_HISTORY_LEN, (self.set.len() as f32 * MAX_HISTORY_LEN_PART) as usize); + min(MAX_HISTORY_LEN, (self.set.len() as f32 * MAX_HISTORY_LEN_PART) as usize) } pub fn len(&self) -> usize { diff --git a/src/main.rs b/src/main.rs index bc415a0..be1cc6f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -151,10 +151,10 @@ impl ScreenState { fn handle_keyboard(&mut self, message: Event) -> Task { let page = self.stack.last_mut().unwrap(); - return match page { + match page { Repetition(page) => page.press(&message), _ => Task::none(), - }; + } } } @@ -206,7 +206,7 @@ trait NavigatedPage { } pub trait KeyPressedPage { - fn press(&mut self, message: &keyboard::Event) -> Task; + fn press(&mut self, message: &Event) -> Task; } /*pub fn danger_button(x: &Theme, status: Status) -> Style{ diff --git a/src/randomizer.rs b/src/randomizer.rs index a6becf6..5290609 100644 --- a/src/randomizer.rs +++ b/src/randomizer.rs @@ -1,6 +1,6 @@ pub mod randomizer { - use crate::randomizer::randomizer::RandomizerMessage::{Back, Start}; + use crate::randomizer::randomizer::RandomizerMessage::{Back, Start, Edit}; use crate::{NavigatedPage, Page, RootMessage}; use iced::widget::{button, container, text_editor}; use iced::Task; @@ -21,7 +21,7 @@ pub mod randomizer { impl NavigatedPage for RandomizerState { fn navigate(&self, message: &RandomizerMessage) -> Option { - if let RandomizerMessage::Back = message { + if let Back = message { return Some(Page::PreviousPage); } None @@ -41,11 +41,11 @@ pub mod randomizer { pub fn update(&mut self, message: RandomizerMessage) -> Task { match message { - RandomizerMessage::Edit(action) => { + Edit(action) => { self.text.perform(action); self.list = self.text.text().split("\n").map(|s| s.to_string()).collect(); }, - RandomizerMessage::Start => { + Start => { self.list.shuffle(&mut rand::rng()); self.text = text_editor::Content::with_text(self.list.join("\n").as_str()); } @@ -58,7 +58,7 @@ pub mod randomizer { container( iced::widget::column![ button("Назад").on_press(Back), - text_editor(&self.text).on_action(RandomizerMessage::Edit + text_editor(&self.text).on_action(Edit ).width(400).height(400).placeholder("Каждый элемент с новой строки"), button("Перемешать").on_press(Start), ] diff --git a/src/repetition.rs b/src/repetition.rs index 871b4a3..8ee5e9f 100644 --- a/src/repetition.rs +++ b/src/repetition.rs @@ -15,7 +15,6 @@ use tokio::task::spawn_blocking; pub struct RepetitionState { pub settings: CardSetSettings, pub set: CardSet, - pub state: Arc>, current_word: WordData, current_statistic: CardStatistics, open: bool, @@ -43,7 +42,6 @@ impl RepetitionState { RepetitionState { settings: set, set: card_set, - state, current_word: word, current_statistic: stat, open: false, @@ -86,7 +84,7 @@ impl RepetitionState { self.answer(WordOpenMode::None) } else { self.open = true; - return Task::none(); + Task::none() } } @@ -223,7 +221,7 @@ impl RepetitionState { } impl KeyPressedPage for RepetitionState { - fn press(&mut self, message: &keyboard::Event) -> iced::Task { + fn press(&mut self, message: &keyboard::Event) -> Task { if let keyboard::Event::KeyPressed { key: _, modified_key: _, diff --git a/src/repetitions.rs b/src/repetitions.rs index c1c833c..61199f1 100644 --- a/src/repetitions.rs +++ b/src/repetitions.rs @@ -287,6 +287,6 @@ impl CardSetSettings { } pub fn require_speech(&self) -> bool { - return self.forward == "speech" || self.backward == "speech" + self.forward == "speech" || self.backward == "speech" } } diff --git a/src/word.rs b/src/word.rs index e1b294f..8efdf3c 100644 --- a/src/word.rs +++ b/src/word.rs @@ -110,10 +110,10 @@ impl WordState { } fn get_view_for_more(&self, value: (&String, &String)) -> Element<'_, WordMessage> { - return match value.0.as_str() { + match value.0.as_str() { "reading" => self.reading_field(value), _ => space().into(), - }; + } } fn reading_field(&self, value: (&String, &String)) -> Element<'_, WordMessage> {