Commit da35256989
Unsigned
Layout: unified · split
src/global/structs/subscriptions.rs +21
| @@ -235,10 +235,31 @@ fn sync_one( | |||
| 235 | })]); | 235 | })]); |
| 236 | } | 236 | } |
| 237 | } | 237 | } |
| 238 | |||
| 239 | if let Some(channel) = &channel { | ||
| 240 | let _ = update_channel_cache(channel, image_index); | ||
| 241 | } | ||
| 238 | 242 | ||
| 239 | Ok((videos, channel)) | 243 | Ok((videos, channel)) |
| 240 | } | 244 | } |
| 241 | 245 | ||
| 246 | fn update_channel_cache(channel: &FullChannelItem, image_index: usize) -> Result<(), Box<dyn Error>> { | ||
| 247 | let home_dir = home_dir().unwrap(); | ||
| 248 | let cache_path = home_dir.join(format!(".cache/youtube-tui/channels/{}.json", channel.id)); | ||
| 249 | |||
| 250 | if let Some(parent) = cache_path.parent() { | ||
| 251 | fs::create_dir_all(parent)?; | ||
| 252 | } | ||
| 253 | |||
| 254 | let item = crate::global::structs::Item::from_full_channel( | ||
| 255 | crate::global::traits::SearchProviderWrapper::channel(&channel.id)?, | ||
| 256 | image_index, | ||
| 257 | ); | ||
| 258 | |||
| 259 | fs::write(&cache_path, serde_json::to_string(&item)?)?; | ||
| 260 | Ok(()) | ||
| 261 | } | ||
| 262 | |||
| 242 | #[derive(Clone, Serialize, Deserialize)] | 263 | #[derive(Clone, Serialize, Deserialize)] |
| 243 | pub struct SubItem { | 264 | pub struct SubItem { |
| 244 | pub channel: FullChannelItem, | 265 | pub channel: FullChannelItem, |