Autosync first edition
This commit is contained in:
+10
-12
@@ -1,8 +1,4 @@
|
||||
//#![windows_subsystem = "windows"]
|
||||
use mimalloc::MiMalloc;
|
||||
|
||||
#[global_allocator]
|
||||
static GLOBAL: MiMalloc = MiMalloc;
|
||||
#![windows_subsystem = "windows"]
|
||||
mod data_provider;
|
||||
mod dictionary;
|
||||
mod dictionary_test;
|
||||
@@ -36,7 +32,11 @@ use iced::{keyboard, Subscription, Theme};
|
||||
use iced_core::Size;
|
||||
use iced_core::window::Position;
|
||||
use rusqlite::Connection;
|
||||
use mimalloc::MiMalloc;
|
||||
use crate::data_provider::sqlite::default_connection;
|
||||
|
||||
#[global_allocator]
|
||||
static GLOBAL: MiMalloc = MiMalloc;
|
||||
const USER_FONT: Font = Font::with_name("Noto Sans JP");
|
||||
|
||||
fn main() -> iced::Result {
|
||||
@@ -72,17 +72,14 @@ pub struct AppState {
|
||||
|
||||
impl AppState {
|
||||
pub fn new() -> Self {
|
||||
let path = app_data_dir();
|
||||
let db_file = path.join("data.db");
|
||||
let connection = Connection::open(db_file).unwrap();
|
||||
connection.execute("PRAGMA foreign_keys = ON;", []).unwrap();
|
||||
|
||||
|
||||
Self {
|
||||
dictionary: vec![],
|
||||
card_sets: vec![],
|
||||
word_groups: vec![],
|
||||
connection,
|
||||
sync_data: AppSettings { key: None },
|
||||
connection: default_connection(),
|
||||
sync_data: AppSettings { key: None, auto_web_fetch: false },
|
||||
activity: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -102,5 +99,6 @@ fn fill_state(state: &mut AppState) {
|
||||
|
||||
fn load_settings(connection: &Connection) -> AppSettings {
|
||||
let key = get_setting("SYNC_KEY".to_string(), connection);
|
||||
AppSettings { key }
|
||||
let fetch = get_setting("AUTO_WEB_FETCH".to_string(), connection).unwrap_or("false".to_string()).parse::<bool>().unwrap();
|
||||
AppSettings { key, auto_web_fetch: fetch }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user