Commit dba33247c8

dba33247c8ffec4eb100e066719c113a7ac90388

parent: 2d06ef1cc4

Unsigned

Siriusmart <sirius@siri.ws> · 2025-11-08 10:56 UTC

no longer uses ~/.cache

Layout: unified · split

src/global/functions/run_command.rs +1 −1
@@ -458,7 +458,7 @@ pub fn run_single_command(
458 *framework.data.global.get_mut::<Message>().unwrap() = message.clone(); 458 *framework.data.global.get_mut::<Message>().unwrap() = message.clone();
459 }, 459 },
460 )))); 460 ))));
461 tasks.last.push(Task::RenderAll); 461 // tasks.last.push(Task::RenderAll);
462 } else { 462 } else {
463 *framework.data.global.get_mut::<Message>().unwrap() = message; 463 *framework.data.global.get_mut::<Message>().unwrap() = message;
464 framework 464 framework
src/global/structs/tasks.rs +1 −4
@@ -60,7 +60,6 @@ pub struct TaskQueue {
60 pub load_page: Option<Page>, 60 pub load_page: Option<Page>,
61 pub clear_all: bool, 61 pub clear_all: bool,
62 pub lazy_rendered: bool, 62 pub lazy_rendered: bool,
63 pub reload_render: bool,
64 pub commands: Vec<String>, 63 pub commands: Vec<String>,
65 pub custom_functions: Vec<TaskFunction>, 64 pub custom_functions: Vec<TaskFunction>,
66} 65}
@@ -73,7 +72,6 @@ impl Default for TaskQueue {
73 load_page: None, 72 load_page: None,
74 clear_all: false, 73 clear_all: false,
75 lazy_rendered: false, 74 lazy_rendered: false,
76 reload_render: true,
77 commands: Vec::new(), 75 commands: Vec::new(),
78 custom_functions: Vec::new(), 76 custom_functions: Vec::new(),
79 } 77 }
@@ -194,8 +192,8 @@ impl TaskQueue {
194 &mut framework.data.state.get_mut::<StateEnvs>().unwrap().0, 192 &mut framework.data.state.get_mut::<StateEnvs>().unwrap().0,
195 ); 193 );
196 194
195 Self::render_force_clear(framework, terminal)?;
197 // reload simply runs `.load()` on all items 196 // reload simply runs `.load()` on all items
198 if self.reload_render {
199 *framework.data.global.get_mut::<Message>().unwrap() = 197 *framework.data.global.get_mut::<Message>().unwrap() =
200 Message::Message(String::from("Reloading page...")); 198 Message::Message(String::from("Reloading page..."));
201 Self::render_force_clear(framework, terminal)?; 199 Self::render_force_clear(framework, terminal)?;
@@ -206,7 +204,6 @@ impl TaskQueue {
206 Message::None 204 Message::None
207 }; 205 };
208 self.render = RenderTask::All; 206 self.render = RenderTask::All;
209 }
210 207
211 let status = framework.data.global.get_mut::<Status>().unwrap(); 208 let status = framework.data.global.get_mut::<Status>().unwrap();
212 status.provider_updated = true; 209 status.provider_updated = true;
src/global/traits/collection.rs +17 −12
@@ -55,10 +55,14 @@ where
55 55
56 /// add an item to watch history 56 /// add an item to watch history
57 fn push(&mut self, item: T) -> Result<(), Box<dyn Error>> { 57 fn push(&mut self, item: T) -> Result<(), Box<dyn Error>> {
58 // let info = home_dir().unwrap().join(".local/share/youtube-tui/info/");
59
60 // removes duplicates and place them on top (if exists) 58 // removes duplicates and place them on top (if exists)
61 let id = item.id().unwrap_or("invalid-dump"); 59 let id = match item.id() {
60 Some(t) => t,
61 None => return Ok(()) // TODO make error message
62 };
63
64 let info = home_dir().unwrap().join(".local/share/youtube-tui/info/").join(format!("{id}.json"));
65
62 if let Some(index) = self 66 if let Some(index) = self
63 .items_mut() 67 .items_mut()
64 .iter_mut() 68 .iter_mut()
@@ -67,17 +71,18 @@ where
67 self.items_mut().remove(index); 71 self.items_mut().remove(index);
68 } 72 }
69 73
70 /* 74 // TODO use central cache struct
71 let mut file = OpenOptions::new() 75 if !info.exists() {
72 .write(true) 76 let mut file = OpenOptions::new()
73 .create(true) 77 .write(true)
74 .truncate(true) 78 .create(true)
75 .open(info.join(format!("{id}.json")))?; 79 .truncate(true)
76 let item_string = serde_json::to_string(&item)?; 80 .open(info)?;
77 file.write_all(item_string.as_bytes())?; 81 let item_string = serde_json::to_string(&item)?;
82 file.write_all(item_string.as_bytes())?;
83 }
78 84
79 self.items_mut().push(item); 85 self.items_mut().push(item);
80 */
81 86
82 Ok(()) 87 Ok(())
83 } 88 }