Remove silent unwrap in data providers

This commit is contained in:
micialware committed 2026-08-19 23:37:59 +03:00
1 parent 01f0999772
commit de2dbaf6c1
6 files changed
+47 -64

No files matched your search

+17 -4
View File
@@ -210,9 +210,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
SaveGroup => {
let state = &mut self.state.lock().unwrap();
let connection = &state.connection;
let mut group = state
.word_groups[self.selected_group_index]
.clone();
let mut group = state.word_groups[self.selected_group_index].clone();
update_group(&mut group, connection);
state.word_groups[self.selected_group_index] = group;
@@ -274,7 +272,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
self.groups_panel(),
row![horizontal().width(8), self.words_list(),],
row![
button("Добавить слово").style(jl_button).on_press(NewWord),
self.add_word_button(),
horizontal().width(Fill),
button("Импорт").style(text).on_press(ToImport),
]
@@ -598,6 +596,21 @@ impl DictionaryState {
space().into()
}
}
fn add_word_button(&self) -> iced::Element<'_, DictionaryMessage> {
let state = self.state.lock().unwrap();
let group_id = state.word_groups[self.selected_group_index].id;
let button = button("Добавить слово")
.style(jl_button);
if group_id.is_valid() {
return
button.on_press(NewWord)
.into();
}
button.into()
}
}
pub fn split_with_coma(ts: &str) -> Vec<String> {