Partial AppState rewrite
This commit is contained in:
1 parent
29a90d48d9
commit
0c4aec3dc0
13 files changed
+75
-49
No files matched your search
@@ -30,7 +30,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DictionaryState {
|
||||
state: Arc<Mutex<AppState>>,
|
||||
state: AppState,
|
||||
include_map: Vec<bool>,
|
||||
tag_map: HashMap<String, bool>,
|
||||
reverse: bool,
|
||||
@@ -300,7 +300,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
||||
}
|
||||
|
||||
impl DictionaryState {
|
||||
pub fn new(state: Arc<Mutex<AppState>>) -> Self {
|
||||
pub fn new(state: AppState) -> Self {
|
||||
let len = state.lock().dictionary.len();
|
||||
|
||||
let mut result = DictionaryState {
|
||||
|
||||
@@ -48,7 +48,7 @@ impl NavigatedPage<HistoryMessage> for HistoryState {
|
||||
}
|
||||
|
||||
impl HistoryState {
|
||||
pub fn new(id: crate::data::Id, state: Arc<Mutex<AppState>>) -> Self {
|
||||
pub fn new(id: crate::data::Id, state: AppState) -> Self {
|
||||
let state = state.lock();
|
||||
let history = get_history_of_set(id).unwrap_or_default();
|
||||
let words = history
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ const DEFAULT_FIELDS: [&str; 6] = ["key", "value", "tags", "reading", "context",
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ImportState {
|
||||
state: Arc<Mutex<AppState>>,
|
||||
state: AppState,
|
||||
path: Option<PathBuf>,
|
||||
import_data: Option<ImportData>,
|
||||
selected_index: usize,
|
||||
@@ -318,7 +318,7 @@ impl ImportState {
|
||||
}
|
||||
|
||||
impl ImportState {
|
||||
pub fn new(state: Arc<Mutex<AppState>>) -> ImportState {
|
||||
pub fn new(state: AppState) -> ImportState {
|
||||
ImportState {
|
||||
state,
|
||||
path: None,
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::sync::Arc;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
pub struct RepetitionState {
|
||||
state: Arc<Mutex<AppState>>,
|
||||
state: AppState,
|
||||
pub settings: DeckSettings,
|
||||
pub set: DeckData,
|
||||
current_word: WordData,
|
||||
@@ -104,7 +104,7 @@ impl NavigatedPage<RepetitionMessage> for RepetitionState {
|
||||
impl RepetitionState {
|
||||
pub(crate) fn new(
|
||||
set: DeckSettings,
|
||||
state: Arc<Mutex<AppState>>,
|
||||
state: AppState,
|
||||
) -> Result<RepetitionState, NotificationData> {
|
||||
let mut card_set = DeckData::new(&set, state.clone())?;
|
||||
let (word, stat) = card_set.next();
|
||||
|
||||
@@ -21,14 +21,14 @@ use std::time::Duration;
|
||||
pub struct RepetitionSettingsState {
|
||||
set: DeckSettings,
|
||||
index: usize,
|
||||
state: Arc<Mutex<AppState>>,
|
||||
state: AppState,
|
||||
real_delete: bool,
|
||||
correct_filter: bool,
|
||||
filter_changed: bool,
|
||||
}
|
||||
|
||||
impl RepetitionSettingsState {
|
||||
pub(crate) fn new(index: usize, state: Arc<Mutex<AppState>>) -> RepetitionSettingsState {
|
||||
pub(crate) fn new(index: usize, state: AppState) -> RepetitionSettingsState {
|
||||
let set;
|
||||
{
|
||||
let local_state = state.lock();
|
||||
|
||||
@@ -36,7 +36,7 @@ pub struct RepetitionsState {
|
||||
word_id_index_map: HashMap<Id, usize>,
|
||||
selected_deck_index: Option<usize>,
|
||||
decks: Vec<DeckViewData>,
|
||||
state: Arc<Mutex<AppState>>,
|
||||
state: AppState,
|
||||
}
|
||||
|
||||
impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
||||
@@ -257,7 +257,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
||||
}
|
||||
|
||||
impl RepetitionsState {
|
||||
pub(crate) fn new(state: Arc<Mutex<AppState>>) -> RepetitionsState {
|
||||
pub(crate) fn new(state: AppState) -> RepetitionsState {
|
||||
let state_ = state.lock();
|
||||
let mut map = HashMap::with_capacity(state_.dictionary.len());
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::sync::Arc;
|
||||
pub struct SelectorState {
|
||||
pub set: KanaSet,
|
||||
is_writing: bool,
|
||||
state: Arc<Mutex<AppState>>,
|
||||
state: AppState,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -114,7 +114,7 @@ impl NavigatedPage<SelectorMessage> for SelectorState {
|
||||
}
|
||||
|
||||
impl SelectorState {
|
||||
pub fn new(state: Arc<Mutex<AppState>>) -> Self {
|
||||
pub fn new(state: AppState) -> Self {
|
||||
Self {
|
||||
set: Default::default(),
|
||||
is_writing: false,
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ pub enum SyncMessage {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct SyncState {
|
||||
state: Arc<Mutex<AppState>>,
|
||||
state: AppState,
|
||||
auto_fetch: bool,
|
||||
frozen: bool,
|
||||
progress: f32,
|
||||
@@ -177,7 +177,7 @@ impl NavigatedPage<SyncMessage> for SyncState {
|
||||
}
|
||||
|
||||
impl SyncState {
|
||||
pub fn new(state: Arc<Mutex<AppState>>) -> SyncState {
|
||||
pub fn new(state: AppState) -> SyncState {
|
||||
let auto_fetch;
|
||||
{
|
||||
auto_fetch = state.lock().sync_data.auto_web_fetch;
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ use std::sync::Arc;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct WordState {
|
||||
state: Arc<Mutex<AppState>>,
|
||||
state: AppState,
|
||||
index: usize,
|
||||
word: WordData,
|
||||
}
|
||||
@@ -136,7 +136,7 @@ impl NavigatedPage<WordMessage> for WordState {
|
||||
}
|
||||
|
||||
impl WordState {
|
||||
pub(crate) fn new(word: WordData, index: usize, state: Arc<Mutex<AppState>>) -> WordState {
|
||||
pub(crate) fn new(word: WordData, index: usize, state: AppState) -> WordState {
|
||||
WordState { state, index, word }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user