git.lucas.co / cce-designer
graphic design tool
git clone https://git.lucas.co/cce-designer.git

commit9c22a8de001ab03087104c3bb54b9270d3a0a094
parentbccc70ee9c
authorLucas Galante <[email protected]>
date2026-07-05 13:07
refactor: migrate recent files list to shared cce-ui KDL implementation

 src/project.rs | 34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/src/project.rs b/src/project.rs
index a0dae7f..8ef2af4 100644
--- a/src/project.rs
+++ b/src/project.rs
@@ -50,38 +50,16 @@ impl State {
         self.window.set_title(&title);
     }
 
-    fn get_recent_files_path() -> Option<std::path::PathBuf> {
-        std::env::var("HOME").ok().map(|h| {
-            let mut path = std::path::PathBuf::from(h);
-            path.push(".config");
-            path.push("cce");
-            path.push("cce-designer");
-            path.push("recent_files.json");
-            path
-        })
-    }
-
     pub(crate) fn load_recent_files() -> Vec<std::path::PathBuf> {
-        if let Some(path) = Self::get_recent_files_path() {
-            if let Ok(file) = std::fs::File::open(path) {
-                if let Ok(list) = serde_json::from_reader::<_, Vec<String>>(file) {
-                    return list.into_iter().map(std::path::PathBuf::from).collect();
-                }
-            }
-        }
-        Vec::new()
+        cce_ui::config::load_recent_files()
+            .into_iter()
+            .map(std::path::PathBuf::from)
+            .collect()
     }
 
     fn save_recent_files(files: &[std::path::PathBuf]) {
-        if let Some(path) = Self::get_recent_files_path() {
-            if let Some(parent) = path.parent() {
-                let _ = std::fs::create_dir_all(parent);
-            }
-            if let Ok(file) = std::fs::File::create(path) {
-                let list: Vec<String> = files.iter().map(|p| p.to_string_lossy().to_string()).collect();
-                let _ = serde_json::to_writer_pretty(file, &list);
-            }
-        }
+        let string_files: Vec<String> = files.iter().map(|p| p.to_string_lossy().to_string()).collect();
+        cce_ui::config::save_recent_files(&string_files);
     }
 
     pub(crate) fn add_recent_file(&mut self, path: std::path::PathBuf) {