From 4aa8a51aa12cf926354dc4719a5b3bba534daabb Mon Sep 17 00:00:00 2001 From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com> Date: Fri, 17 Jan 2025 02:54:44 +0200 Subject: [PATCH] refactor(window-state): Simplify denylist handling and error management in with_denylist method --- plugins/window-state/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/window-state/src/lib.rs b/plugins/window-state/src/lib.rs index 365d86f0..52eb3771 100644 --- a/plugins/window-state/src/lib.rs +++ b/plugins/window-state/src/lib.rs @@ -41,8 +41,6 @@ pub enum Error { Tauri(#[from] tauri::Error), #[error(transparent)] SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - Glob(#[from] glob::PatternError), } pub type Result = std::result::Result; @@ -347,15 +345,17 @@ impl Builder { /// Sets a list of windows that shouldn't be tracked and managed by this plugin /// For example, splash screen windows. It also supports glob patterns for flexible window matching. - pub fn with_denylist(mut self, denylist: &mut [&str]) -> Result { + pub fn with_denylist(mut self, denylist: &[&str]) -> Self { + let mut denylist = denylist.to_vec(); denylist.sort(); let mut denylist_patterns = Vec::new(); for pattern in denylist { - denylist_patterns.push(glob::Pattern::new(pattern)?); + denylist_patterns + .push(glob::Pattern::new(pattern).expect("Failed to parse glob pattern")); } self.denylist = denylist_patterns; - Ok(self) + self } /// Adds the given window label to a list of windows to skip initial state restore.