Fix deck filter

This commit is contained in:
micialware committed 2026-09-11 14:02:57 +03:00
1 parent cbf49412ec
commit e5622c70de
1 file changed
+5 -2
+5 -2
View File
@@ -1,3 +1,4 @@
use std::collections::HashMap;
use crate::app::AppState; use crate::app::AppState;
use crate::core::srs::OrderModule::{Fsrs, RandomSRS, SemiRandomSRS, WorstWordsSRS}; use crate::core::srs::OrderModule::{Fsrs, RandomSRS, SemiRandomSRS, WorstWordsSRS};
use crate::core::srs::{ use crate::core::srs::{
@@ -13,6 +14,7 @@ use log::info;
use rhai::{Engine, Scope}; use rhai::{Engine, Scope};
use std::sync::Arc; use std::sync::Arc;
use std::time::Instant; use std::time::Instant;
use crate::data::Id;
#[derive(Clone)] #[derive(Clone)]
pub struct DeckData { pub struct DeckData {
@@ -154,10 +156,11 @@ impl DeckData {
if let Ok(ast) = ast { if let Ok(ast) = ast {
let groups = state.word_groups.read().iter().cloned().collect::<Vec<_>>(); let groups = state.word_groups.read().iter().cloned().collect::<Vec<_>>();
let dictionary = &state.dictionary.read(); let dictionary = &state.dictionary.read();
let fields : HashMap<Id, String> = HashMap::from_iter(state.custom_fields.read().iter().map(|f| (f.id, f.identifier.clone())));
let query = dictionary.query_par(Arc::new(move |word| { let query = dictionary.query_par(Arc::new(move |word| {
let mut more = rhai::Map::new(); let mut more = rhai::Map::new();
for iced in &word.additional { for kv in &word.additional {
more.insert(iced.0.clone().into(), iced.1.clone().into()); more.insert(fields[&kv.0].clone().into(), kv.1.clone().into());
} }
let mut scope = Scope::new(); let mut scope = Scope::new();
let group_name = groups[groups let group_name = groups[groups