You've already forked AstralRinth
forked from didirus/AstralRinth
More app fixes 0.9.0 (#3054)
* initial set of fixes (toggle sidebar, profile pagination) * more fixes, bump version * fix lint: * fix quick switcher ordering
This commit is contained in:
@@ -474,7 +474,11 @@ impl CacheValue {
|
||||
| CacheValue::DonationPlatforms(_) => DEFAULT_ID.to_string(),
|
||||
|
||||
CacheValue::FileHash(hash) => {
|
||||
format!("{}-{}", hash.size, hash.path.replace(".disabled", ""))
|
||||
format!(
|
||||
"{}-{}",
|
||||
hash.size,
|
||||
hash.path.trim_end_matches(".disabled")
|
||||
)
|
||||
}
|
||||
CacheValue::FileUpdate(hash) => {
|
||||
format!("{}-{}-{}", hash.hash, hash.loader, hash.game_version)
|
||||
|
||||
@@ -122,10 +122,12 @@ impl State {
|
||||
|
||||
#[tracing::instrument]
|
||||
async fn initialize_state() -> crate::Result<Arc<Self>> {
|
||||
tracing::info!("Connecting to app database");
|
||||
let pool = db::connect().await?;
|
||||
|
||||
legacy_converter::migrate_legacy_data(&pool).await?;
|
||||
|
||||
tracing::info!("Fetching app settings");
|
||||
let mut settings = Settings::get(&pool).await?;
|
||||
|
||||
let fetch_semaphore =
|
||||
@@ -135,6 +137,7 @@ impl State {
|
||||
let api_semaphore =
|
||||
FetchSemaphore(Semaphore::new(settings.max_concurrent_downloads));
|
||||
|
||||
tracing::info!("Initializing directories");
|
||||
DirectoryInfo::move_launcher_directory(
|
||||
&mut settings,
|
||||
&pool,
|
||||
@@ -145,6 +148,7 @@ impl State {
|
||||
|
||||
let discord_rpc = DiscordGuard::init()?;
|
||||
|
||||
tracing::info!("Initializing file watcher");
|
||||
let file_watcher = fs_watcher::init_watcher().await?;
|
||||
fs_watcher::watch_profiles_init(&file_watcher, &directories).await;
|
||||
|
||||
|
||||
@@ -664,7 +664,7 @@ impl Profile {
|
||||
path: format!(
|
||||
"{}/{folder}/{}",
|
||||
self.path,
|
||||
file_name.replace(".disabled", "")
|
||||
file_name.trim_end_matches(".disabled")
|
||||
),
|
||||
file_name: file_name.to_string(),
|
||||
project_type,
|
||||
@@ -725,8 +725,9 @@ impl Profile {
|
||||
let info_index = file_info.iter().position(|x| x.hash == hash.hash);
|
||||
let file = info_index.map(|x| file_info.remove(x));
|
||||
|
||||
if let Some(initial_file_index) =
|
||||
keys.iter().position(|x| x.path == hash.path)
|
||||
if let Some(initial_file_index) = keys
|
||||
.iter()
|
||||
.position(|x| x.path == hash.path.trim_end_matches(".disabled"))
|
||||
{
|
||||
let initial_file = keys.remove(initial_file_index);
|
||||
|
||||
@@ -890,7 +891,7 @@ impl Profile {
|
||||
let path = crate::api::profile::get_full_path(profile_path).await?;
|
||||
|
||||
let new_path = if project_path.ends_with(".disabled") {
|
||||
project_path.replace(".disabled", "")
|
||||
project_path.trim_end_matches(".disabled").to_string()
|
||||
} else {
|
||||
format!("{project_path}.disabled")
|
||||
};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
//! Theseus settings file
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
// Types
|
||||
/// Global Theseus settings
|
||||
@@ -13,10 +15,10 @@ pub struct Settings {
|
||||
pub collapsed_navigation: bool,
|
||||
pub advanced_rendering: bool,
|
||||
pub native_decorations: bool,
|
||||
pub toggle_sidebar: bool,
|
||||
|
||||
pub telemetry: bool,
|
||||
pub discord_rpc: bool,
|
||||
pub developer_mode: bool,
|
||||
pub personalized_ads: bool,
|
||||
|
||||
pub onboarded: bool,
|
||||
@@ -32,6 +34,16 @@ pub struct Settings {
|
||||
pub custom_dir: Option<String>,
|
||||
pub prev_custom_dir: Option<String>,
|
||||
pub migrated: bool,
|
||||
|
||||
pub developer_mode: bool,
|
||||
pub feature_flags: HashMap<FeatureFlag, bool>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Eq, Hash, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum FeatureFlag {
|
||||
PagePath,
|
||||
ProjectBackground,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
@@ -48,7 +60,7 @@ impl Settings {
|
||||
json(extra_launch_args) extra_launch_args, json(custom_env_vars) custom_env_vars,
|
||||
mc_memory_max, mc_force_fullscreen, mc_game_resolution_x, mc_game_resolution_y, hide_on_process_start,
|
||||
hook_pre_launch, hook_wrapper, hook_post_exit,
|
||||
custom_dir, prev_custom_dir, migrated
|
||||
custom_dir, prev_custom_dir, migrated, json(feature_flags) feature_flags, toggle_sidebar
|
||||
FROM settings
|
||||
"
|
||||
)
|
||||
@@ -63,6 +75,7 @@ impl Settings {
|
||||
collapsed_navigation: res.collapsed_navigation == 1,
|
||||
advanced_rendering: res.advanced_rendering == 1,
|
||||
native_decorations: res.native_decorations == 1,
|
||||
toggle_sidebar: res.toggle_sidebar == 1,
|
||||
telemetry: res.telemetry == 1,
|
||||
discord_rpc: res.discord_rpc == 1,
|
||||
developer_mode: res.developer_mode == 1,
|
||||
@@ -95,6 +108,11 @@ impl Settings {
|
||||
custom_dir: res.custom_dir,
|
||||
prev_custom_dir: res.prev_custom_dir,
|
||||
migrated: res.migrated == 1,
|
||||
feature_flags: res
|
||||
.feature_flags
|
||||
.as_ref()
|
||||
.and_then(|x| serde_json::from_str(x).ok())
|
||||
.unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -108,6 +126,7 @@ impl Settings {
|
||||
let default_page = self.default_page.as_str();
|
||||
let extra_launch_args = serde_json::to_string(&self.extra_launch_args)?;
|
||||
let custom_env_vars = serde_json::to_string(&self.custom_env_vars)?;
|
||||
let feature_flags = serde_json::to_string(&self.feature_flags)?;
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
@@ -143,7 +162,10 @@ impl Settings {
|
||||
|
||||
custom_dir = $23,
|
||||
prev_custom_dir = $24,
|
||||
migrated = $25
|
||||
migrated = $25,
|
||||
|
||||
toggle_sidebar = $26,
|
||||
feature_flags = $27
|
||||
",
|
||||
max_concurrent_writes,
|
||||
max_concurrent_downloads,
|
||||
@@ -169,7 +191,9 @@ impl Settings {
|
||||
self.hooks.post_exit,
|
||||
self.custom_dir,
|
||||
self.prev_custom_dir,
|
||||
self.migrated
|
||||
self.migrated,
|
||||
self.toggle_sidebar,
|
||||
feature_flags
|
||||
)
|
||||
.execute(exec)
|
||||
.await?;
|
||||
@@ -185,6 +209,7 @@ pub enum Theme {
|
||||
Dark,
|
||||
Light,
|
||||
Oled,
|
||||
System,
|
||||
}
|
||||
|
||||
impl Theme {
|
||||
@@ -193,6 +218,7 @@ impl Theme {
|
||||
Theme::Dark => "dark",
|
||||
Theme::Light => "light",
|
||||
Theme::Oled => "oled",
|
||||
Theme::System => "system",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,6 +227,7 @@ impl Theme {
|
||||
"dark" => Theme::Dark,
|
||||
"light" => Theme::Light,
|
||||
"oled" => Theme::Oled,
|
||||
"system" => Theme::System,
|
||||
_ => Theme::Dark,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user