refactor: update icon handling in tray methods to accept IVerge reference and improve logging #5379 (#5387)

* refactor: update icon handling in tray methods to accept IVerge reference and improve logging #5379

* refactor: simplify icon retrieval logic in Tray implementation
This commit is contained in:
Tunglies
2025-11-10 19:06:37 +08:00
committed by GitHub
parent 7d42d5cb0f
commit 33f575ed4d
5 changed files with 47 additions and 30 deletions
+11 -4
View File
@@ -106,10 +106,17 @@ pub fn find_target_icons(target: &str) -> Result<Option<String>> {
let icon_path = fs::read_dir(&icons_dir)?
.filter_map(|entry| entry.ok().map(|e| e.path()))
.find(|path| {
path.file_prefix().is_some_and(|prefix| prefix == target)
&& path
.extension()
.is_some_and(|ext| ext == "ico" || ext == "png")
let prefix_matches = path
.file_prefix()
.and_then(|p| p.to_str())
.is_some_and(|prefix| prefix.starts_with(target));
let ext_matches = path
.extension()
.and_then(|e| e.to_str())
.is_some_and(|ext| {
ext.eq_ignore_ascii_case("ico") || ext.eq_ignore_ascii_case("png")
});
prefix_matches && ext_matches
});
icon_path