feat(core): improve config dump when patched
This commit is contained in:
parent
e151364014
commit
7f3c70c8df
|
@ -75,7 +75,7 @@ impl ConfigStore for PatchedConfigStore {
|
||||||
|
|
||||||
// Check if a patch should be applied
|
// Check if a patch should be applied
|
||||||
if let Some(patch) = self.patches.iter().find(|patch| (patch.should_patch)(app)) {
|
if let Some(patch) = self.patches.iter().find(|patch| (patch.should_patch)(app)) {
|
||||||
(patch.apply)(active_config)
|
(patch.apply)(active_config, patch.name)
|
||||||
} else {
|
} else {
|
||||||
active_config
|
active_config
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,5 +48,5 @@ pub struct PatchDefinition {
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
pub is_enabled: fn() -> bool,
|
pub is_enabled: fn() -> bool,
|
||||||
pub should_patch: fn(app: &AppProperties) -> bool,
|
pub should_patch: fn(app: &AppProperties) -> bool,
|
||||||
pub apply: fn(config: Arc<dyn Config>) -> Arc<dyn Config>,
|
pub apply: fn(config: Arc<dyn Config>, name: &str) -> Arc<dyn Config>,
|
||||||
}
|
}
|
|
@ -26,14 +26,17 @@ macro_rules! generate_patchable_config {
|
||||||
pub struct $struct_name {
|
pub struct $struct_name {
|
||||||
base: Arc<dyn Config>,
|
base: Arc<dyn Config>,
|
||||||
patch: Patches,
|
patch: Patches,
|
||||||
|
patched_label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl $struct_name {
|
impl $struct_name {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn patch(base: Arc<dyn Config>, patch: Patches) -> Self {
|
pub fn patch(base: Arc<dyn Config>, name: &str, patch: Patches) -> Self {
|
||||||
|
let patched_label = format!("{} (PATCHED: {})", base.label(), name);
|
||||||
Self {
|
Self {
|
||||||
base,
|
base,
|
||||||
patch,
|
patch,
|
||||||
|
patched_label,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +64,7 @@ macro_rules! generate_patchable_config {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn label(&self) -> &str {
|
fn label(&self) -> &str {
|
||||||
self.base.label()
|
&self.patched_label
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_paths(&self) -> &[String] {
|
fn match_paths(&self) -> &[String] {
|
||||||
|
|
|
@ -27,9 +27,10 @@ pub fn patch() -> PatchDefinition {
|
||||||
name: module_path!().split(":").last().unwrap_or("unknown"),
|
name: module_path!().split(":").last().unwrap_or("unknown"),
|
||||||
is_enabled: || cfg!(target_os = "windows"),
|
is_enabled: || cfg!(target_os = "windows"),
|
||||||
should_patch: |app| app.title.unwrap_or_default().contains("OneNote"),
|
should_patch: |app| app.title.unwrap_or_default().contains("OneNote"),
|
||||||
apply: |base| {
|
apply: |base, name| {
|
||||||
Arc::new(PatchedConfig::patch(
|
Arc::new(PatchedConfig::patch(
|
||||||
base,
|
base,
|
||||||
|
name,
|
||||||
Patches {
|
Patches {
|
||||||
key_delay: Some(Some(10)),
|
key_delay: Some(Some(10)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user