First database deunwrap

This commit is contained in:
micialware committed 2026-08-24 17:33:21 +03:00
1 parent 3cbdf0803b
commit 06bf9138c0
6 files changed
+45 -23

No files matched your search

+11 -6
View File
@@ -1,8 +1,10 @@
use crate::app::AppState;
use crate::data::entities::DeckSettings;
use crate::data_provider::card_sets::{delete_set, update_deck};
use crate::data_provider::card_stats::{delete_stats, load_stats_of_deck};
use crate::navigation::Page::PreviousPage;
use crate::navigation::{NavigatedPage, Page, RootMessage};
use crate::notification::NotificationRequest;
use crate::pages::repetition_settings::RepetitionSettingsMessage::*;
use crate::styling::*;
use iced::widget::button::danger;
@@ -10,12 +12,10 @@ 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::{Padding, Theme, color};
use iced_core::{color, Padding, Theme};
use parking_lot::Mutex;
use std::sync::Arc;
use std::time::Duration;
use crate::app::AppState;
use crate::data::entities::DeckSettings;
pub struct RepetitionSettingsState {
set: DeckSettings,
@@ -61,7 +61,9 @@ impl NavigatedPage<RepetitionSettingsMessage> for RepetitionSettingsState {
Back => {}
Save => {
let mut state = self.state.lock();
update_deck(&mut self.set, &state.connection);
if let Err(e) = update_deck(&mut self.set, &state.connection) {
return Task::done(RootMessage::PushNotification(NotificationRequest::Error(e)));
}
if self.filter_changed {
update_deck_stats(&self.set, &state);
}
@@ -95,7 +97,10 @@ impl NavigatedPage<RepetitionSettingsMessage> for RepetitionSettingsState {
});
}
let mut state = self.state.lock();
delete_set(&self.set, &state.connection);
if let Err(e) = delete_set(&self.set, &state.connection) {
return Task::done(RootMessage::PushNotification(NotificationRequest::Error(e)));
}
state.decks.remove(self.index);
return Task::done(RootMessage::RepetitionSettings(Back));
}
+4 -1
View File
@@ -27,6 +27,7 @@ use iced_core::svg::Handle;
use parking_lot::Mutex;
use std::ops::Deref;
use std::sync::Arc;
use crate::notification::NotificationRequest;
#[derive(Clone)]
pub struct RepetitionsState {
@@ -146,7 +147,9 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
let mut deck = self.selected_deck().unwrap().clone();
let mut state = self.state.lock();
{
update_deck(&mut deck.general_settings, &state.connection);
if let Err(e) = update_deck(&mut deck.general_settings, &state.connection){
return Task::done(RootMessage::PushNotification(NotificationRequest::Error(e)))
}
if let Some(index) = deck.index {
state.decks[index] = deck.general_settings.clone();
} else {