fix: use generic SectionListRenderer

This commit is contained in:
ThetaDev 2022-11-11 00:21:01 +01:00
parent 2cd74b1da8
commit c80e302d72
4 changed files with 7 additions and 30 deletions

View file

@ -58,7 +58,7 @@ pub(crate) struct TabRenderer {
pub(crate) struct TabContent { pub(crate) struct TabContent {
#[serde(default)] #[serde(default)]
#[serde_as(as = "DefaultOnError")] #[serde_as(as = "DefaultOnError")]
pub section_list_renderer: Option<SectionListRenderer>, pub section_list_renderer: Option<ContentsRenderer<ItemSectionRendererWrap>>,
/// Seems to be currently A/B tested, as of 11.10.2022 /// Seems to be currently A/B tested, as of 11.10.2022
#[serde(default)] #[serde(default)]
#[serde_as(as = "DefaultOnError")] #[serde_as(as = "DefaultOnError")]
@ -83,12 +83,6 @@ pub(crate) struct ChannelTabWebCommandMetadata {
pub url: String, pub url: String,
} }
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct SectionListRenderer {
pub contents: Vec<ItemSectionRendererWrap>,
}
/// Seems to be currently A/B tested, as of 11.10.2022 /// Seems to be currently A/B tested, as of 11.10.2022
#[serde_as] #[serde_as]
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

View file

@ -5,7 +5,7 @@ use crate::serializer::{text::Text, MapResult, VecLogError};
use super::{ use super::{
music_item::{ItemSection, MusicResponseItem, MusicThumbnailRenderer}, music_item::{ItemSection, MusicResponseItem, MusicThumbnailRenderer},
ContentsRenderer, Tab, ContentsRenderer, SectionList, Tab,
}; };
/// Response model for YouTube Music artists /// Response model for YouTube Music artists
@ -22,12 +22,6 @@ pub(crate) struct Contents<T> {
pub single_column_browse_results_renderer: ContentsRenderer<Tab<SectionList<T>>>, pub single_column_browse_results_renderer: ContentsRenderer<Tab<SectionList<T>>>,
} }
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct SectionList<T> {
pub section_list_renderer: ContentsRenderer<T>,
}
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub(crate) struct Header { pub(crate) struct Header {

View file

@ -3,7 +3,7 @@ use serde_with::{serde_as, VecSkipError};
use crate::serializer::{ignore_any, text::Text}; use crate::serializer::{ignore_any, text::Text};
use super::{music_item::MusicShelf, ContentsRenderer, Tab}; use super::{music_item::MusicShelf, ContentsRenderer, SectionList, Tab};
/// Response model for YouTube Music search /// Response model for YouTube Music search
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
@ -15,13 +15,7 @@ pub(crate) struct MusicSearch {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub(crate) struct Contents { pub(crate) struct Contents {
pub tabbed_search_results_renderer: ContentsRenderer<Tab<SectionList>>, pub tabbed_search_results_renderer: ContentsRenderer<Tab<SectionList<ItemSection>>>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct SectionList {
pub section_list_renderer: ContentsRenderer<ItemSection>,
} }
#[allow(clippy::enum_variant_names)] #[allow(clippy::enum_variant_names)]

View file

@ -6,7 +6,8 @@ use crate::serializer::{ignore_any, MapResult, VecLogError};
use crate::util::MappingError; use crate::util::MappingError;
use super::{ use super::{
Alert, ContentsRenderer, ContinuationEndpoint, ResponseContext, Tab, Thumbnails, ThumbnailsWrap, Alert, ContentsRenderer, ContinuationEndpoint, ResponseContext, SectionList, Tab, Thumbnails,
ThumbnailsWrap,
}; };
#[serde_as] #[serde_as]
@ -33,13 +34,7 @@ pub(crate) struct PlaylistCont {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub(crate) struct Contents { pub(crate) struct Contents {
pub two_column_browse_results_renderer: ContentsRenderer<Tab<SectionList>>, pub two_column_browse_results_renderer: ContentsRenderer<Tab<SectionList<ItemSection>>>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct SectionList {
pub section_list_renderer: ContentsRenderer<ItemSection>,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]