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(
458458 *framework.data.global.get_mut::<Message>().unwrap() = message.clone();
459459 },
460460 ))));
461 tasks.last.push(Task::RenderAll);
461 // tasks.last.push(Task::RenderAll);
462462 } else {
463463 *framework.data.global.get_mut::<Message>().unwrap() = message;
464464 framework
src/global/structs/tasks.rs +1 −4
@@ -60,7 +60,6 @@ pub struct TaskQueue {
6060 pub load_page: Option<Page>,
6161 pub clear_all: bool,
6262 pub lazy_rendered: bool,
63 pub reload_render: bool,
6463 pub commands: Vec<String>,
6564 pub custom_functions: Vec<TaskFunction>,
6665}
@@ -73,7 +72,6 @@ impl Default for TaskQueue {
7372 load_page: None,
7473 clear_all: false,
7574 lazy_rendered: false,
76 reload_render: true,
7775 commands: Vec::new(),
7876 custom_functions: Vec::new(),
7977 }
@@ -194,8 +192,8 @@ impl TaskQueue {
194192 &mut framework.data.state.get_mut::<StateEnvs>().unwrap().0,
195193 );
196194
195 Self::render_force_clear(framework, terminal)?;
197196 // reload simply runs `.load()` on all items
198 if self.reload_render {
199197 *framework.data.global.get_mut::<Message>().unwrap() =
200198 Message::Message(String::from("Reloading page..."));
201199 Self::render_force_clear(framework, terminal)?;
@@ -206,7 +204,6 @@ impl TaskQueue {
206204 Message::None
207205 };
208206 self.render = RenderTask::All;
209 }
210207
211208 let status = framework.data.global.get_mut::<Status>().unwrap();
212209 status.provider_updated = true;
src/global/traits/collection.rs +17 −12
@@ -55,10 +55,14 @@ where
5555
5656 /// add an item to watch history
5757 fn push(&mut self, item: T) -> Result<(), Box<dyn Error>> {
58 // let info = home_dir().unwrap().join(".local/share/youtube-tui/info/");
59
6058 // 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
6266 if let Some(index) = self
6367 .items_mut()
6468 .iter_mut()
@@ -67,17 +71,18 @@ where
6771 self.items_mut().remove(index);
6872 }
6973
70 /*
71 let mut file = OpenOptions::new()
72 .write(true)
73 .create(true)
74 .truncate(true)
75 .open(info.join(format!("{id}.json")))?;
76 let item_string = serde_json::to_string(&item)?;
77 file.write_all(item_string.as_bytes())?;
74 // TODO use central cache struct
75 if !info.exists() {
76 let mut file = OpenOptions::new()
77 .write(true)
78 .create(true)
79 .truncate(true)
80 .open(info)?;
81 let item_string = serde_json::to_string(&item)?;
82 file.write_all(item_string.as_bytes())?;
83 }
7884
7985 self.items_mut().push(item);
80 */
8186
8287 Ok(())
8388 }