chore: PlaylistPanel fixes (#146)

* fix:`PlaylistPanel` possible content type mismatch

* fix: `PlaylistPanel` err when no continuation
This commit is contained in:
Patrick Kan
2022-08-19 17:52:47 +08:00
committed by GitHub
parent dc2f0055cc
commit b101a39d30

View File

@@ -3,6 +3,7 @@ import Text from './misc/Text';
import PlaylistPanelVideo from './PlaylistPanelVideo';
import { YTNode } from '../helpers';
import AutomixPreviewVideo from './AutomixPreviewVideo';
class PlaylistPanel extends YTNode {
static type = 'PlaylistPanel';
@@ -21,10 +22,10 @@ class PlaylistPanel extends YTNode {
super();
this.title = data.title;
this.title_text = new Text(data.titleText);
this.contents = Parser.parseArray<PlaylistPanelVideo>(data.contents, PlaylistPanelVideo);
this.contents = Parser.parseArray<PlaylistPanelVideo | AutomixPreviewVideo>(data.contents, [ PlaylistPanelVideo, AutomixPreviewVideo ]);
this.playlist_id = data.playlistId;
this.is_infinite = data.isInfinite;
this.continuation = data.continuations[0]?.nextRadioContinuationData?.continuation || data.continuations[0]?.nextContinuationData?.continuation;
this.continuation = data.continuations?.[0]?.nextRadioContinuationData?.continuation || data.continuations?.[0]?.nextContinuationData?.continuation;
this.is_editable = data.isEditable;
this.preview_description = data.previewDescription;
this.num_items_to_show = data.numItemsToShow;