Formatting

This commit is contained in:
micialware committed 2026-08-20 16:23:22 +03:00
1 parent 3f43676580
commit 878ff3f1e4
6 files changed
+35 -15

No files matched your search

+9 -2
View File
@@ -86,8 +86,15 @@ pub fn delete_stats(stat: &[CardStatistics], connection: &Connection) {
if stat.is_empty() {
return;
}
let ids = stat.iter().map(|s| s.id.into()).collect::<Vec<String>>().join(", ");
let ids = stat
.iter()
.map(|s| s.id.into())
.collect::<Vec<String>>()
.join(", ");
connection
.execute(format!("DELETE FROM card_stats WHERE id in {ids}").as_str(), ())
.execute(
format!("DELETE FROM card_stats WHERE id in {ids}").as_str(),
(),
)
.unwrap();
}
+8 -6
View File
@@ -8,7 +8,7 @@ pub async fn get_voice(text: &str) -> Result<BufReader<File>, ()> {
let mut path = app_data_dir();
path.push("voice");
if !path.exists() {
std::fs::create_dir(path.clone()).map_err(|_|())?;
std::fs::create_dir(path.clone()).map_err(|_| ())?;
}
let hash = format!("{}.wav", hex::encode(Sha256::digest(text.as_bytes())));
path.push(hash);
@@ -20,19 +20,21 @@ pub async fn get_voice(text: &str) -> Result<BufReader<File>, ()> {
.send()
.await;
let query = query.map_err(|_|())?.text().await.map_err(|_|())?;
let query = query.map_err(|_| ())?.text().await.map_err(|_| ())?;
// Synthesis
let audio = client
.post(format!("{engine_url}/synthesis?speaker=11"))
.header("Content-Type", "application/json")
.body(query)
.send()
.await.map_err(|_|())?
.await
.map_err(|_| ())?
.bytes()
.await.map_err(|_|())?;
.await
.map_err(|_| ())?;
tokio::fs::write(&path, &audio).await.map_err(|_|())?;
tokio::fs::write(&path, &audio).await.map_err(|_| ())?;
}
Ok(BufReader::new(File::open(path).map_err(|_|())?))
Ok(BufReader::new(File::open(path).map_err(|_| ())?))
}
+12 -1
View File
@@ -364,7 +364,17 @@ impl DeckData {
let state_locked = state.lock();
let stats = load_stats_of_deck(settings, &state_locked.connection);
let words = stats.iter().map(|stat| state_locked.dictionary.binary_search_by_key(&stat.word_id, |w| w.id).unwrap()).map(|index| &state_locked.dictionary[index]).cloned().collect();
let words = stats
.iter()
.map(|stat| {
state_locked
.dictionary
.binary_search_by_key(&stat.word_id, |w| w.id)
.unwrap()
})
.map(|index| &state_locked.dictionary[index])
.cloned()
.collect();
Self {
set: stats,
@@ -381,6 +391,7 @@ impl DeckData {
settings: settings.clone(),
}
}
pub fn next(&mut self) -> (WordData, CardStatistics) {
let index = match self.order_module.clone() {
OrderModule::SemiRandomSRS(mut module) => {
+2 -2
View File
@@ -9,8 +9,8 @@ use chrono::Local;
use iced::alignment::Horizontal::Center;
use iced::keyboard::key::Physical::Code;
use iced::widget::text::Style;
use iced::widget::{button, column, container, row, rule, space, text, tooltip, Column};
use iced::{alignment, keyboard, Element, Fill, Task, Theme};
use iced::widget::{Column, button, column, container, row, rule, space, text, tooltip};
use iced::{Element, Fill, Task, Theme, alignment, keyboard};
use parking_lot::Mutex;
use rodio::MixerDeviceSink;
use std::collections::HashSet;
+2 -2
View File
@@ -1,3 +1,4 @@
use crate::AppState;
use crate::data_provider::card_sets::{delete_set, update_deck};
use crate::data_provider::card_stats::{delete_stats, load_stats_of_deck};
use crate::lang::DeckSettings;
@@ -5,13 +6,12 @@ use crate::navigation::Page::PreviousPage;
use crate::navigation::{NavigatedPage, Page, RootMessage};
use crate::repetition_settings::RepetitionSettingsMessage::*;
use crate::styling::*;
use crate::AppState;
use iced::widget::button::danger;
use iced::widget::text_input::Catalog;
use iced::widget::{button, column, row, scrollable, space, text, text_input};
use iced::{Element, Task};
use iced_core::Length::Fill;
use iced_core::{color, Padding, Theme};
use iced_core::{Padding, Theme, color};
use parking_lot::Mutex;
use std::sync::Arc;
use std::time::Duration;
+2 -2
View File
@@ -88,7 +88,8 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
self.decks.remove(index);
self.clear_selection();
} else {
self.decks[self.selected_deck_index.unwrap()].general_settings = state.decks[index].clone();
self.decks[self.selected_deck_index.unwrap()].general_settings =
state.decks[index].clone();
drop(state);
self.fill_deck_word_indices();
}
@@ -625,7 +626,6 @@ impl RepetitionsState {
deck.existing_words_indices = Some(added);
deck.available_words_indices = Some(total);
self.decks[self.selected_deck_index.unwrap()] = deck;
}
}
#[derive(Clone)]