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();
|
||||
|
||||
Reference in New Issue
Block a user