Commit a49e41106a

a49e41106a6254f3104d38762198ecba4539d857

parent: 6221eb407a

Unsigned

Siriusmart <71584876+Siriusmart@users.noreply.github.com> · 2022-11-19 17:01 UTC

image lazy loading v0.5.1

Layout: unified · split

Cargo.lock +20 −21
@@ -235,9 +235,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
235 235
236[[package]] 236[[package]]
237name = "cxx" 237name = "cxx"
238version = "1.0.81" 238version = "1.0.82"
239source = "registry+https://github.com/rust-lang/crates.io-index" 239source = "registry+https://github.com/rust-lang/crates.io-index"
240checksum = "97abf9f0eca9e52b7f81b945524e76710e6cb2366aead23b7d4fbf72e281f888" 240checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453"
241dependencies = [ 241dependencies = [
242 "cc", 242 "cc",
243 "cxxbridge-flags", 243 "cxxbridge-flags",
@@ -247,9 +247,9 @@ dependencies = [
247 247
248[[package]] 248[[package]]
249name = "cxx-build" 249name = "cxx-build"
250version = "1.0.81" 250version = "1.0.82"
251source = "registry+https://github.com/rust-lang/crates.io-index" 251source = "registry+https://github.com/rust-lang/crates.io-index"
252checksum = "7cc32cc5fea1d894b77d269ddb9f192110069a8a9c1f1d441195fba90553dea3" 252checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0"
253dependencies = [ 253dependencies = [
254 "cc", 254 "cc",
255 "codespan-reporting", 255 "codespan-reporting",
@@ -262,15 +262,15 @@ dependencies = [
262 262
263[[package]] 263[[package]]
264name = "cxxbridge-flags" 264name = "cxxbridge-flags"
265version = "1.0.81" 265version = "1.0.82"
266source = "registry+https://github.com/rust-lang/crates.io-index" 266source = "registry+https://github.com/rust-lang/crates.io-index"
267checksum = "8ca220e4794c934dc6b1207c3b42856ad4c302f2df1712e9f8d2eec5afaacf1f" 267checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71"
268 268
269[[package]] 269[[package]]
270name = "cxxbridge-macro" 270name = "cxxbridge-macro"
271version = "1.0.81" 271version = "1.0.82"
272source = "registry+https://github.com/rust-lang/crates.io-index" 272source = "registry+https://github.com/rust-lang/crates.io-index"
273checksum = "b846f081361125bfc8dc9d3940c84e1fd83ba54bbca7b17cd29483c828be0704" 273checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470"
274dependencies = [ 274dependencies = [
275 "proc-macro2", 275 "proc-macro2",
276 "quote", 276 "quote",
@@ -693,9 +693,9 @@ dependencies = [
693 693
694[[package]] 694[[package]]
695name = "indexmap" 695name = "indexmap"
696version = "1.9.1" 696version = "1.9.2"
697source = "registry+https://github.com/rust-lang/crates.io-index" 697source = "registry+https://github.com/rust-lang/crates.io-index"
698checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" 698checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
699dependencies = [ 699dependencies = [
700 "autocfg", 700 "autocfg",
701 "hashbrown", 701 "hashbrown",
@@ -1071,11 +1071,10 @@ dependencies = [
1071 1071
1072[[package]] 1072[[package]]
1073name = "rayon" 1073name = "rayon"
1074version = "1.5.3" 1074version = "1.6.0"
1075source = "registry+https://github.com/rust-lang/crates.io-index" 1075source = "registry+https://github.com/rust-lang/crates.io-index"
1076checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" 1076checksum = "1e060280438193c554f654141c9ea9417886713b7acd75974c85b18a69a88e0b"
1077dependencies = [ 1077dependencies = [
1078 "autocfg",
1079 "crossbeam-deque", 1078 "crossbeam-deque",
1080 "either", 1079 "either",
1081 "rayon-core", 1080 "rayon-core",
@@ -1083,9 +1082,9 @@ dependencies = [
1083 1082
1084[[package]] 1083[[package]]
1085name = "rayon-core" 1084name = "rayon-core"
1086version = "1.9.3" 1085version = "1.10.1"
1087source = "registry+https://github.com/rust-lang/crates.io-index" 1086source = "registry+https://github.com/rust-lang/crates.io-index"
1088checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" 1087checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3"
1089dependencies = [ 1088dependencies = [
1090 "crossbeam-channel", 1089 "crossbeam-channel",
1091 "crossbeam-deque", 1090 "crossbeam-deque",
@@ -1113,9 +1112,9 @@ dependencies = [
1113 1112
1114[[package]] 1113[[package]]
1115name = "reqwest" 1114name = "reqwest"
1116version = "0.11.12" 1115version = "0.11.13"
1117source = "registry+https://github.com/rust-lang/crates.io-index" 1116source = "registry+https://github.com/rust-lang/crates.io-index"
1118checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" 1117checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c"
1119dependencies = [ 1118dependencies = [
1120 "base64", 1119 "base64",
1121 "bytes", 1120 "bytes",
@@ -1236,9 +1235,9 @@ dependencies = [
1236 1235
1237[[package]] 1236[[package]]
1238name = "serde_json" 1237name = "serde_json"
1239version = "1.0.87" 1238version = "1.0.88"
1240source = "registry+https://github.com/rust-lang/crates.io-index" 1239source = "registry+https://github.com/rust-lang/crates.io-index"
1241checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" 1240checksum = "8e8b3801309262e8184d9687fb697586833e939767aea0dda89f5a8e650e8bd7"
1242dependencies = [ 1241dependencies = [
1243 "itoa", 1242 "itoa",
1244 "ryu", 1243 "ryu",
@@ -1433,9 +1432,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
1433 1432
1434[[package]] 1433[[package]]
1435name = "tokio" 1434name = "tokio"
1436version = "1.21.2" 1435version = "1.22.0"
1437source = "registry+https://github.com/rust-lang/crates.io-index" 1436source = "registry+https://github.com/rust-lang/crates.io-index"
1438checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" 1437checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3"
1439dependencies = [ 1438dependencies = [
1440 "autocfg", 1439 "autocfg",
1441 "bytes", 1440 "bytes",
docs/src/README.md +3 −1
@@ -48,7 +48,9 @@ The YouTube TUI allows you to browse YouTube with (almost) all of it's features,
48 48
49### What it doesn't have 49### What it doesn't have
50 50
51- Vim-like commands (first priority) 51- Next page button in pages (first priority)
52- Lazy image loading (first priority)
53- Vim-like commands (will implement)
52- Channel search (will implement) 54- Channel search (will implement)
53- Channel videos sorting (will implement) 55- Channel videos sorting (will implement)
54- Subscriptions (will implement) 56- Subscriptions (will implement)
docs/src/changelogs.md +8 −1
@@ -1,6 +1,13 @@
1# Changelogs 1# Changelogs
2 2
3## v0.5.0 3## v0.5.1
4
5#### Added
6
7- Image lazy loading (will not rerender image if already rendered)
8- Optional features that can be disabled
9
10### v0.5.0
4 11
5#### Added 12#### Added
6 13
docs/src/installation.md +7 −1
@@ -2,6 +2,8 @@
2 2
3It's about download (or building) the binary and putting them in an easily accessible location (like `/bin/`). 3It's about download (or building) the binary and putting them in an easily accessible location (like `/bin/`).
4 4
5The YouTube TUI is not tested for Windows.
6
5## Install from Crates.io (recommended) 7## Install from Crates.io (recommended)
6 8
7Crates.io is a repository for programs written in Rust, and the YouTube TUI is avaliable <a href="https://crates.io/crates/youtube-tui" target=_blank>*there*</a>. 9Crates.io is a repository for programs written in Rust, and the YouTube TUI is avaliable <a href="https://crates.io/crates/youtube-tui" target=_blank>*there*</a>.
@@ -62,10 +64,14 @@ cargo install youtube-tui --all-features # install with all features (even if no
62 64
63### `halfblock` (default) 65### `halfblock` (default)
64 66
65Display images through HalfBlocks, work best in terminals with TrueColour support (so would not recommend for Windows users). 67Display images through HalfBlocks, work best in terminals with TrueColour support.
66 68
67### `sixel` (default) 69### `sixel` (default)
68 70
69Display images with Sixels, allows the display of images at full definition. Not present on windows. 71Display images with Sixels, allows the display of images at full definition. Not present on windows.
70 72
71Enabling this will also enable `halfblock`. 73Enabling this will also enable `halfblock`.
74
75Requires <a href="https://github.com/saitoha/libsixel" target=_blank>`libsixel`</a>.
76
77> `sixel` and `halfblock` does not compile on Windows.
src/global/structs/status.rs +3
@@ -4,6 +4,8 @@ use typemap::Key;
4#[derive(Clone)] 4#[derive(Clone)]
5pub struct Status { 5pub struct Status {
6 pub popup_opened: bool, 6 pub popup_opened: bool,
7 /// to prevent rerendering the same image
8 pub render_image: bool,
7} 9}
8 10
9impl Key for Status { 11impl Key for Status {
@@ -14,6 +16,7 @@ impl Default for Status {
14 fn default() -> Self { 16 fn default() -> Self {
15 Self { 17 Self {
16 popup_opened: false, 18 popup_opened: false,
19 render_image: true,
17 } 20 }
18 } 21 }
19} 22}
src/global/structs/tasks.rs +14 −1
@@ -16,6 +16,7 @@ pub enum Task {
16 RenderOnly(usize, usize), 16 RenderOnly(usize, usize),
17 LoadPage(Page), 17 LoadPage(Page),
18 ClearPage, 18 ClearPage,
19 LazyRendered,
19} 20}
20 21
21/// multiple tasks joined together, with duplicates removed 22/// multiple tasks joined together, with duplicates removed
@@ -25,6 +26,7 @@ pub struct TaskQueue {
25 pub reload: bool, 26 pub reload: bool,
26 pub load_page: Option<Page>, 27 pub load_page: Option<Page>,
27 pub clear_all: bool, 28 pub clear_all: bool,
29 pub lazy_rendered: bool,
28} 30}
29 31
30impl Default for TaskQueue { 32impl Default for TaskQueue {
@@ -34,6 +36,7 @@ impl Default for TaskQueue {
34 reload: false, 36 reload: false,
35 load_page: None, 37 load_page: None,
36 clear_all: false, 38 clear_all: false,
39 lazy_rendered: false,
37 } 40 }
38 } 41 }
39} 42}
@@ -56,6 +59,7 @@ impl TaskQueue {
56 }, 59 },
57 Task::LoadPage(page) => self.load_page = Some(page), 60 Task::LoadPage(page) => self.load_page = Some(page),
58 Task::ClearPage => self.clear_all = true, 61 Task::ClearPage => self.clear_all = true,
62 Task::LazyRendered => self.lazy_rendered = true,
59 // _ => {} 63 // _ => {}
60 } 64 }
61 } 65 }
@@ -74,6 +78,15 @@ impl TaskQueue {
74 terminal.clear()?; 78 terminal.clear()?;
75 } 79 }
76 80
81 if self.lazy_rendered {
82 framework
83 .data
84 .global
85 .get_mut::<Status>()
86 .unwrap()
87 .render_image = false;
88 }
89
77 // save state in history, then replace all items by whats in the new page and run `.load()` on them 90 // save state in history, then replace all items by whats in the new page and run `.load()` on them
78 if let Some(page) = self.load_page { 91 if let Some(page) = self.load_page {
79 *framework.data.global.get_mut::<Message>().unwrap() = 92 *framework.data.global.get_mut::<Message>().unwrap() =
@@ -87,7 +100,7 @@ impl TaskQueue {
87 100
88 let state = page_config.to_state(framework); 101 let state = page_config.to_state(framework);
89 framework.set_state(state); 102 framework.set_state(state);
90 framework.data.state.get_mut::<Status>().unwrap().reset(); 103 framework.data.global.get_mut::<Status>().unwrap().reset();
91 *framework.data.state.get_mut::<Page>().unwrap() = page; 104 *framework.data.state.get_mut::<Page>().unwrap() = page;
92 Self::render_force_clear(framework, terminal)?; 105 Self::render_force_clear(framework, terminal)?;
93 *framework.data.global.get_mut::<Message>().unwrap() = Message::None; 106 *framework.data.global.get_mut::<Message>().unwrap() = Message::None;
src/init.rs +1 −1
@@ -69,6 +69,7 @@ pub fn init(framework: &mut Framework) -> Result<(), Box<dyn Error>> {
69 .data 69 .data
70 .global 70 .global
71 .insert::<CommandsConfig>(CommandsConfig::from(*CommandsConfigSerde::load()?)); 71 .insert::<CommandsConfig>(CommandsConfig::from(*CommandsConfigSerde::load()?));
72 framework.data.global.insert::<Status>(Status::default());
72 73
73 framework.data.state.insert::<Tasks>(Tasks::default()); 74 framework.data.state.insert::<Tasks>(Tasks::default());
74 framework.data.state.insert::<Page>(Page::default()); 75 framework.data.state.insert::<Page>(Page::default());
@@ -77,7 +78,6 @@ pub fn init(framework: &mut Framework) -> Result<(), Box<dyn Error>> {
77 .data 78 .data
78 .state 79 .state
79 .insert::<MinDimentions>(MinDimentions::default()); 80 .insert::<MinDimentions>(MinDimentions::default());
80 framework.data.state.insert::<Status>(Status::default());
81 81
82 Ok(()) 82 Ok(())
83} 83}
src/items/channeldisplay.rs +22 −13
@@ -5,7 +5,7 @@ use crate::{
5 functions::download_all_images, 5 functions::download_all_images,
6 structs::{ 6 structs::{
7 ChannelDisplayPageType, InvidiousClient, Item, KeyAction, Message, Page, 7 ChannelDisplayPageType, InvidiousClient, Item, KeyAction, Message, Page,
8 SingleItemPage, Task, Tasks, 8 SingleItemPage, Status, Task, Tasks,
9 }, 9 },
10 }, 10 },
11}; 11};
@@ -25,6 +25,7 @@ pub enum ChannelDisplay {
25 None, 25 None,
26 Main { 26 Main {
27 channel: Item, 27 channel: Item,
28 iteminfo: ItemInfo,
28 }, 29 },
29 Videos { 30 Videos {
30 videos: Vec<Item>, 31 videos: Vec<Item>,
@@ -133,7 +134,7 @@ impl FrameworkItem for ChannelDisplay {
133 .border_style(border_style); 134 .border_style(border_style);
134 frame.render_widget(block, area); 135 frame.render_widget(block, area);
135 } 136 }
136 Self::Main { channel } => { 137 Self::Main { iteminfo, .. } => {
137 let block = Block::default() 138 let block = Block::default()
138 .border_type(appearance.borders) 139 .border_type(appearance.borders)
139 .borders(Borders::ALL) 140 .borders(Borders::ALL)
@@ -141,10 +142,7 @@ impl FrameworkItem for ChannelDisplay {
141 let inner = block.inner(area); 142 let inner = block.inner(area);
142 143
143 frame.render_widget(block, area); 144 frame.render_widget(block, area);
144 ItemInfo { 145 iteminfo.render(frame, framework, inner, popup_render, info);
145 item: Some(channel.clone()),
146 }
147 .render(frame, framework, inner, popup_render, info);
148 } 146 }
149 Self::Videos { 147 Self::Videos {
150 textlist, 148 textlist,
@@ -237,6 +235,12 @@ impl FrameworkItem for ChannelDisplay {
237 .unwrap() 235 .unwrap()
238 .priority 236 .priority
239 .push(Task::RenderAll); 237 .push(Task::RenderAll);
238 framework
239 .data
240 .global
241 .get_mut::<Status>()
242 .unwrap()
243 .render_image = true;
240 iteminfo.item = Some(videos[textlist.selected].clone()); 244 iteminfo.item = Some(videos[textlist.selected].clone());
241 } 245 }
242 } 246 }
@@ -279,6 +283,12 @@ impl FrameworkItem for ChannelDisplay {
279 .unwrap() 283 .unwrap()
280 .priority 284 .priority
281 .push(Task::RenderAll); 285 .push(Task::RenderAll);
286 framework
287 .data
288 .global
289 .get_mut::<Status>()
290 .unwrap()
291 .render_image = true;
282 iteminfo.item = Some(playlists[textlist.selected].clone()); 292 iteminfo.item = Some(playlists[textlist.selected].clone());
283 } 293 }
284 } 294 }
@@ -310,7 +320,10 @@ impl FrameworkItem for ChannelDisplay {
310 mainconfig.image_index, 320 mainconfig.image_index,
311 ); 321 );
312 download_all_images(vec![(&channel).into()]); 322 download_all_images(vec![(&channel).into()]);
313 *self = Self::Main { channel } 323 *self = Self::Main {
324 iteminfo: ItemInfo::new(Some(channel.clone())),
325 channel,
326 }
314 } 327 }
315 ChannelDisplayPageType::Videos => { 328 ChannelDisplayPageType::Videos => {
316 let videos = framework 329 let videos = framework
@@ -331,9 +344,7 @@ impl FrameworkItem for ChannelDisplay {
331 .border_type(appearance.borders) 344 .border_type(appearance.borders)
332 .style(Style::default().fg(appearance.colors.text)) 345 .style(Style::default().fg(appearance.colors.text))
333 .items(&videos)?, 346 .items(&videos)?,
334 iteminfo: ItemInfo { 347 iteminfo: ItemInfo::new(videos.first().cloned()),
335 item: videos.first().cloned(),
336 },
337 grid: Grid::new( 348 grid: Grid::new(
338 vec![Constraint::Percentage(60), Constraint::Percentage(40)], 349 vec![Constraint::Percentage(60), Constraint::Percentage(40)],
339 vec![Constraint::Percentage(100)], 350 vec![Constraint::Percentage(100)],
@@ -361,9 +372,7 @@ impl FrameworkItem for ChannelDisplay {
361 .border_type(appearance.borders) 372 .border_type(appearance.borders)
362 .style(Style::default().fg(appearance.colors.text)) 373 .style(Style::default().fg(appearance.colors.text))
363 .items(&playlists)?, 374 .items(&playlists)?,
364 iteminfo: ItemInfo { 375 iteminfo: ItemInfo::new(playlists.first().cloned()),
365 item: playlists.first().cloned(),
366 },
367 grid: Grid::new( 376 grid: Grid::new(
368 vec![Constraint::Percentage(60), Constraint::Percentage(40)], 377 vec![Constraint::Percentage(60), Constraint::Percentage(40)],
369 vec![Constraint::Percentage(100)], 378 vec![Constraint::Percentage(100)],
src/items/iteminfo.rs +31 −5
@@ -9,13 +9,14 @@ use viuer::{print_from_file, Config};
9 9
10use crate::{ 10use crate::{
11 config::{AppearanceConfig, MainConfig}, 11 config::{AppearanceConfig, MainConfig},
12 global::structs::{Item, Status}, 12 global::structs::{Item, Status, Task, Tasks},
13}; 13};
14 14
15/// an item info displays info of any `Item`s 15/// an item info displays info of any `Item`s
16#[derive(Clone)] 16#[derive(Clone)]
17pub struct ItemInfo { 17pub struct ItemInfo {
18 pub item: Option<Item>, 18 pub item: Option<Item>,
19 pub lazy_scroll: u16,
19} 20}
20 21
21impl FrameworkItem for ItemInfo { 22impl FrameworkItem for ItemInfo {
@@ -38,12 +39,14 @@ impl FrameworkItem for ItemInfo {
38 }; 39 };
39 40
40 let main_config = framework.data.global.get::<MainConfig>().unwrap(); 41 let main_config = framework.data.global.get::<MainConfig>().unwrap();
41 let appearance = framework.data.global.get::<AppearanceConfig>().unwrap(); 42 let status = framework.data.global.get::<Status>().unwrap();
42 43
43 // The scroll (space above) text info will be the height of the image, but if the image fail to display, the scroll will be 0 44 // The scroll (space above) text info will be the height of the image, but if the image fail to display, the scroll will be 0
44 let scroll = if cfg!(any(feature = "halfblock", feature = "sixel")) 45 let scroll = if !status.render_image {
46 self.lazy_scroll
47 } else if cfg!(any(feature = "halfblock", feature = "sixel"))
45 && main_config.images.display() 48 && main_config.images.display()
46 && !framework.data.state.get::<Status>().unwrap().popup_opened 49 && !status.popup_opened
47 { 50 {
48 let mut scroll = 0; 51 let mut scroll = 0;
49 52
@@ -74,6 +77,13 @@ impl FrameworkItem for ItemInfo {
74 77
75 if let Ok((_, height)) = print_from_file(thumbnail_path, &config) { 78 if let Ok((_, height)) = print_from_file(thumbnail_path, &config) {
76 scroll = height as u16; 79 scroll = height as u16;
80 framework
81 .data
82 .state
83 .get_mut::<Tasks>()
84 .unwrap()
85 .priority
86 .push(Task::LazyRendered);
77 } else { 87 } else {
78 scroll = 0; 88 scroll = 0;
79 } 89 }
@@ -84,6 +94,10 @@ impl FrameworkItem for ItemInfo {
84 0 94 0
85 }; 95 };
86 96
97 self.lazy_scroll = scroll;
98
99 let appearance = framework.data.global.get::<AppearanceConfig>().unwrap();
100
87 // Each "span" contains a string and a Style, and they are one line max each 101 // Each "span" contains a string and a Style, and they are one line max each
88 // A "text" is used for descriptions in video/playlist and channels, and starts a new line if the old one runs out 102 // A "text" is used for descriptions in video/playlist and channels, and starts a new line if the old one runs out
89 let (spans, text) = match item { 103 let (spans, text) = match item {
@@ -359,6 +373,18 @@ impl FrameworkItem for ItemInfo {
359 373
360impl Default for ItemInfo { 374impl Default for ItemInfo {
361 fn default() -> Self { 375 fn default() -> Self {
362 Self { item: None } 376 Self {
377 item: None,
378 lazy_scroll: 0,
379 }
380 }
381}
382
383impl ItemInfo {
384 pub fn new(item: Option<Item>) -> Self {
385 Self {
386 item,
387 ..Default::default()
388 }
363 } 389 }
364} 390}
src/items/itemlist.rs +7 −1
@@ -14,7 +14,7 @@ use crate::{
14 structs::{ 14 structs::{
15 ChannelDisplayPage, ChannelDisplayPageType, FullPlaylistItem, FullVideoItem, 15 ChannelDisplayPage, ChannelDisplayPageType, FullPlaylistItem, FullVideoItem,
16 InvidiousClient, Item, KeyAction, MainMenuPage, MiniChannelItem, MiniPlaylistItem, 16 InvidiousClient, Item, KeyAction, MainMenuPage, MiniChannelItem, MiniPlaylistItem,
17 MiniVideoItem, Page, SingleItemPage, Task, Tasks, WatchHistory, 17 MiniVideoItem, Page, SingleItemPage, Status, Task, Tasks, WatchHistory,
18 }, 18 },
19 }, 19 },
20}; 20};
@@ -264,6 +264,12 @@ impl FrameworkItem for ItemList {
264 264
265 // only create a render task if the key event actually changed something 265 // only create a render task if the key event actually changed something
266 if updated { 266 if updated {
267 framework
268 .data
269 .global
270 .get_mut::<Status>()
271 .unwrap()
272 .render_image = true;
267 self.info.item = Some(self.items[self.textlist.selected].clone()); 273 self.info.item = Some(self.items[self.textlist.selected].clone());
268 framework 274 framework
269 .data 275 .data
src/items/searchfilters.rs +5 −7
@@ -188,7 +188,7 @@ impl FrameworkItem for SearchFilter {
188 fn select(&mut self, framework: &mut tui_additions::framework::FrameworkClean) -> bool { 188 fn select(&mut self, framework: &mut tui_additions::framework::FrameworkClean) -> bool {
189 framework 189 framework
190 .data 190 .data
191 .state 191 .global
192 .get_mut::<Status>() 192 .get_mut::<Status>()
193 .unwrap() 193 .unwrap()
194 .popup_opened = true; 194 .popup_opened = true;
@@ -220,12 +220,10 @@ impl FrameworkItem for SearchFilter {
220 } 220 }
221 221
222 fn deselect(&mut self, framework: &mut tui_additions::framework::FrameworkClean) -> bool { 222 fn deselect(&mut self, framework: &mut tui_additions::framework::FrameworkClean) -> bool {
223 framework 223 *framework.data.global.get_mut::<Status>().unwrap() = Status {
224 .data 224 popup_opened: false,
225 .state 225 render_image: true,
226 .get_mut::<Status>() 226 };
227 .unwrap()
228 .popup_opened = false;
229 227
230 // refresh page only if changed and enabled in options 228 // refresh page only if changed and enabled in options
231 let search_options = framework.data.state.get::<Search>().unwrap().clone(); 229 let search_options = framework.data.state.get::<Search>().unwrap().clone();
src/items/singleitem.rs +12 −8
@@ -4,7 +4,7 @@ use crate::{
4 global::{ 4 global::{
5 functions::download_all_images, 5 functions::download_all_images,
6 structs::{ 6 structs::{
7 InvidiousClient, Item, KeyAction, Message, Page, SingleItemPage, Task, Tasks, 7 InvidiousClient, Item, KeyAction, Message, Page, SingleItemPage, Status, Task, Tasks,
8 WatchHistory, 8 WatchHistory,
9 }, 9 },
10 }, 10 },
@@ -168,13 +168,11 @@ impl SinglePlaylistItem {
168 mainconfig: &MainConfig, 168 mainconfig: &MainConfig,
169 playlist_items: &[Item], 169 playlist_items: &[Item],
170 ) -> Self { 170 ) -> Self {
171 let hovered_video = ItemInfo { 171 let hovered_video = ItemInfo::new(if playlist_items.is_empty() {
172 item: if playlist_items.is_empty() { 172 None
173 None 173 } else {
174 } else { 174 Some(playlist_items[0].clone())
175 Some(playlist_items[0].clone()) 175 });
176 },
177 };
178 Self { 176 Self {
179 commands_view: TextList::default() 177 commands_view: TextList::default()
180 .items(&commands.playlist.iter().map(|command| &command.0).collect()) 178 .items(&commands.playlist.iter().map(|command| &command.0).collect())
@@ -763,6 +761,12 @@ impl FrameworkItem for SingleItem {
763 }; 761 };
764 762
765 if updated { 763 if updated {
764 framework
765 .data
766 .global
767 .get_mut::<Status>()
768 .unwrap()
769 .render_image = true;
766 framework 770 framework
767 .data 771 .data
768 .state 772 .state
src/run.rs +19 −1
@@ -5,7 +5,7 @@ use tui_additions::framework::{Framework, FrameworkDirection};
5 5
6use crate::{ 6use crate::{
7 config::KeyBindingsConfig, 7 config::KeyBindingsConfig,
8 global::structs::{KeyAction, MainMenuPage, Message, Page, Task, Tasks}, 8 global::structs::{KeyAction, MainMenuPage, Message, Page, Status, Task, Tasks},
9}; 9};
10 10
11/// the main event loop of the program 11/// the main event loop of the program
@@ -91,6 +91,12 @@ pub fn run(
91 "This is already the beginning of history", 91 "This is already the beginning of history",
92 )) 92 ))
93 } else { 93 } else {
94 framework
95 .data
96 .global
97 .get_mut::<Status>()
98 .unwrap()
99 .render_image = true;
94 framework 100 framework
95 .data 101 .data
96 .state 102 .state
@@ -107,6 +113,12 @@ pub fn run(
107 "This is already the beginning of history", 113 "This is already the beginning of history",
108 )) 114 ))
109 } else { 115 } else {
116 framework
117 .data
118 .global
119 .get_mut::<Status>()
120 .unwrap()
121 .render_image = true;
110 framework 122 framework
111 .data 123 .data
112 .state 124 .state
@@ -153,6 +165,12 @@ pub fn run(
153 .unwrap() 165 .unwrap()
154 .priority 166 .priority
155 .push(Task::RenderAll); 167 .push(Task::RenderAll);
168 framework
169 .data
170 .global
171 .get_mut::<Status>()
172 .unwrap()
173 .render_image = true;
156 } 174 }
157 _ => {} 175 _ => {}
158 } 176 }