Formatting
This commit is contained in:
1 parent
3f43676580
commit
878ff3f1e4
6 files changed
+31
-11
No files matched your search
@@ -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();
|
||||
}
|
||||
@@ -27,9 +27,11 @@ pub async fn get_voice(text: &str) -> Result<BufReader<File>, ()> {
|
||||
.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(|_| ())?;
|
||||
}
|
||||
|
||||
+12
-1
@@ -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
@@ -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;
|
||||
|
||||
@@ -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
@@ -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)]
|
||||
|
||||
Reference in new issue
Block a user