Skip to content

Commit

Permalink
fix(parser): ThumbnailView background color (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha authored Jul 11, 2024
1 parent 7d03469 commit 0f8f92a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
12 changes: 7 additions & 5 deletions src/parser/classes/CollectionThumbnailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class CollectionThumbnailView extends YTNode {
static type = 'CollectionThumbnailView';

primary_thumbnail: ThumbnailView | null;
stack_color: {
stack_color?: {
light_theme: number;
dark_theme: number;
};
Expand All @@ -15,9 +15,11 @@ export default class CollectionThumbnailView extends YTNode {
super();

this.primary_thumbnail = Parser.parseItem(data.primaryThumbnail, ThumbnailView);
this.stack_color = {
light_theme: data.stackColor.lightTheme,
dark_theme: data.stackColor.darkTheme
};
if (data.stackColor) {
this.stack_color = {
light_theme: data.stackColor.lightTheme,
dark_theme: data.stackColor.darkTheme
};
}
}
}
12 changes: 7 additions & 5 deletions src/parser/classes/ThumbnailBadgeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class ThumbnailBadgeView extends YTNode {
icon_name: string;
text: string;
badge_style: string;
background_color: {
background_color?: {
light_theme: number;
dark_theme: number;
};
Expand All @@ -18,9 +18,11 @@ export default class ThumbnailBadgeView extends YTNode {
this.icon_name = data.icon.sources[0].clientResource.imageName;
this.text = data.text;
this.badge_style = data.badgeStyle;
this.background_color = {
light_theme: data.backgroundColor.lightTheme,
dark_theme: data.backgroundColor.darkTheme
};
if (data.backgroundColor) {
this.background_color = {
light_theme: data.backgroundColor.lightTheme,
dark_theme: data.backgroundColor.darkTheme
};
}
}
}
12 changes: 7 additions & 5 deletions src/parser/classes/ThumbnailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class ThumbnailView extends YTNode {

image: Thumbnail[];
overlays: (ThumbnailOverlayBadgeView | ThumbnailHoverOverlayView)[];
background_color: {
background_color?: {
light_theme: number;
dark_theme: number;
};
Expand All @@ -19,9 +19,11 @@ export default class ThumbnailView extends YTNode {

this.image = Thumbnail.fromResponse(data.image);
this.overlays = Parser.parseArray(data.overlays, [ ThumbnailOverlayBadgeView, ThumbnailHoverOverlayView ]);
this.background_color = {
light_theme: data.backgroundColor.lightTheme,
dark_theme: data.backgroundColor.darkTheme
};
if (data.backgroundColor) {
this.background_color = {
light_theme: data.backgroundColor.lightTheme,
dark_theme: data.backgroundColor.darkTheme
};
}
}
}

0 comments on commit 0f8f92a

Please sign in to comment.