Refactor config
This commit is contained in:
@@ -2,10 +2,17 @@ use crate::config::types::{ApplicationConfig, BasicConfig, PathConfig};
|
||||
use crate::constants::{APP_CONIFG_FILE_PATH, APP_DB_DATA_DIR};
|
||||
use color_eyre::Result;
|
||||
use std::path::PathBuf;
|
||||
use language_tags::LanguageTag;
|
||||
use ratatui::widgets::ListState;
|
||||
use serde_json;
|
||||
|
||||
pub mod types;
|
||||
|
||||
pub(crate) struct GameList<T> {
|
||||
games: Vec<T>,
|
||||
state: ListState,
|
||||
}
|
||||
|
||||
impl ApplicationConfig {
|
||||
pub fn get_config() -> Result<Self> {
|
||||
if APP_CONIFG_FILE_PATH.exists() {
|
||||
@@ -22,10 +29,12 @@ impl ApplicationConfig {
|
||||
}
|
||||
|
||||
fn new() -> Self {
|
||||
let default_locale = sys_locale::get_locale().unwrap_or(String::from("ja-JP"));
|
||||
let conf = Self {
|
||||
basic_config: BasicConfig {
|
||||
db_path: APP_DB_DATA_DIR.to_str().unwrap().to_string(),
|
||||
tick_rate: 250,
|
||||
locale: LanguageTag::parse(&default_locale).unwrap(),
|
||||
},
|
||||
path_config: PathConfig {
|
||||
dlsite_paths: vec![],
|
||||
|
||||
Reference in New Issue
Block a user