Introduce MaybeError type
This commit is contained in:
1 parent
d836b57d2a
commit
a60ed37cd4
16 files changed
+127
-93
No files matched your search
@@ -1,12 +1,12 @@
|
||||
use crate::app::AppState;
|
||||
use crate::core::srs::{AppendMode, OrderMode};
|
||||
use crate::data::Id;
|
||||
use crate::data::entities::{CardStatistics, DeckSettings};
|
||||
use crate::data::Id;
|
||||
use crate::data_provider::card_sets::update_deck;
|
||||
use crate::data_provider::card_stats::{add_stat_list, load_stats_of_deck};
|
||||
use crate::navigation::Page::{History, PreviousPage, Repetition, RepetitionSettings};
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::notification::{NotificationData, NotificationRequest};
|
||||
use crate::notification::{MaybeError, NotificationRequest};
|
||||
use crate::pages::history::HistoryState;
|
||||
use crate::pages::repetition::RepetitionState;
|
||||
use crate::pages::repetition_settings::RepetitionSettingsState;
|
||||
@@ -16,17 +16,17 @@ use crate::push_error_task;
|
||||
use crate::styling::*;
|
||||
use chrono::{Days, Local, Utc};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use iced::widget::button::{danger, Status};
|
||||
pub use iced::widget::button::{Catalog, Style};
|
||||
use iced::widget::button::{Status, danger};
|
||||
use iced::widget::tooltip::Position::Top;
|
||||
use iced::widget::{
|
||||
Column, Row, button, column, container, lazy, radio, row, scrollable, space, svg, text,
|
||||
text_input, tooltip,
|
||||
button, column, container, lazy, radio, row, scrollable, space, svg, text, text_input, tooltip,
|
||||
Column, Row,
|
||||
};
|
||||
use iced::{Background, Border, Center, Color, Element, Fill, Length, Shadow, Task, Theme};
|
||||
use iced_core::Padding;
|
||||
use iced_core::border::Radius;
|
||||
use iced_core::svg::Handle;
|
||||
use iced_core::Padding;
|
||||
use parking_lot::Mutex;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
@@ -562,7 +562,7 @@ impl RepetitionsState {
|
||||
}
|
||||
|
||||
impl RepetitionsState {
|
||||
fn append_all_words(state: &mut AppState, deck: &DeckViewData) -> Result<(), NotificationData> {
|
||||
fn append_all_words(state: &mut AppState, deck: &DeckViewData) -> MaybeError {
|
||||
let existing = &deck.existing_words_indices;
|
||||
let mut created_set = HashSet::with_capacity(existing.len());
|
||||
existing.iter().for_each(|c| {
|
||||
@@ -580,7 +580,7 @@ impl RepetitionsState {
|
||||
state: &mut AppState,
|
||||
deck: &DeckSettings,
|
||||
indices: impl Iterator<Item = usize>,
|
||||
) -> Result<(), NotificationData> {
|
||||
) -> MaybeError {
|
||||
let words = &state.dictionary;
|
||||
let stats = &mut indices
|
||||
.map(|i| {
|
||||
@@ -618,7 +618,7 @@ impl RepetitionsState {
|
||||
self.selected_deck_index = None;
|
||||
}
|
||||
|
||||
fn fill_deck_word_indices(&mut self) -> Result<(), NotificationData> {
|
||||
fn fill_deck_word_indices(&mut self) -> MaybeError {
|
||||
let state = &self.state.lock();
|
||||
let mut deck = self.selected_deck().unwrap().clone();
|
||||
let added: Vec<_> = load_stats_of_deck(&deck, &state.connection)?
|
||||
|
||||
Reference in new issue
Block a user