Rewrite for dictionary indexer
This commit is contained in:
+6
-9
@@ -150,8 +150,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
||||
v = v[..v.len() - 2].to_string()
|
||||
}
|
||||
|
||||
while v.contains(",,") {
|
||||
let index = v.find(",,").unwrap();
|
||||
while let Some(index) = v.find(",,") {
|
||||
v.remove(index);
|
||||
}
|
||||
|
||||
@@ -211,14 +210,12 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
||||
SaveGroup => {
|
||||
let state = &mut self.state.lock().unwrap();
|
||||
let connection = &state.connection;
|
||||
let group = &mut state
|
||||
.word_groups
|
||||
.get(self.selected_group_index)
|
||||
.unwrap()
|
||||
let mut group = state
|
||||
.word_groups[self.selected_group_index]
|
||||
.clone();
|
||||
|
||||
update_group(group, connection);
|
||||
state.word_groups[self.selected_group_index] = group.clone();
|
||||
update_group(&mut group, connection);
|
||||
state.word_groups[self.selected_group_index] = group;
|
||||
}
|
||||
SelectGroup(i) => {
|
||||
self.selected_group_index = i;
|
||||
@@ -316,7 +313,7 @@ impl DictionaryState {
|
||||
fn save_word(&mut self, i: usize) {
|
||||
let state = &mut self.state.lock().unwrap();
|
||||
let connection = &state.connection;
|
||||
let word = &mut state.dictionary.get(i).unwrap().clone();
|
||||
let word = &mut state.dictionary[i].clone();
|
||||
|
||||
update_word(word, connection);
|
||||
state.dictionary[i] = word.clone();
|
||||
|
||||
+2
-3
@@ -517,8 +517,7 @@ impl ImportState {
|
||||
.iter()
|
||||
.map(|name| (name.clone(), Vec::<usize>::with_capacity(1)))
|
||||
.collect::<Vec<_>>();
|
||||
for key in group.mapping.keys() {
|
||||
let endpoint = group.mapping.get(key).unwrap();
|
||||
for (key, endpoint) in &group.mapping {
|
||||
let property_index = group.fields.iter().position(|f| f == key).unwrap();
|
||||
let group_index = result
|
||||
.iter()
|
||||
@@ -538,7 +537,7 @@ impl ImportState {
|
||||
) -> String {
|
||||
let mut working_words = Vec::with_capacity(indices.len());
|
||||
for index in indices {
|
||||
let str = properties.get(*index).unwrap();
|
||||
let str = &properties[*index];
|
||||
if skip_empty && str.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
+1
-1
@@ -360,7 +360,7 @@ impl DeckData {
|
||||
let last_list: Vec<_> = settings
|
||||
.get_word_list(&state_locked)
|
||||
.iter()
|
||||
.map(|w| state_locked.dictionary.get(*w).unwrap())
|
||||
.map(|w| &state_locked.dictionary[*w])
|
||||
.cloned()
|
||||
.collect();
|
||||
let word_ids = last_list.iter().map(|l| l.id).collect::<Vec<Id>>();
|
||||
|
||||
+1
-1
@@ -581,7 +581,7 @@ impl RepetitionsState {
|
||||
let words = &state.dictionary;
|
||||
let stats = &mut indices
|
||||
.map(|i| {
|
||||
let word = words.get(i).unwrap();
|
||||
let word = &words[i];
|
||||
CardStatistics {
|
||||
id: 0.into(),
|
||||
word_id: word.id,
|
||||
|
||||
Reference in New Issue
Block a user