fix(music-together): typing

This commit is contained in:
JellyBrick
2024-01-05 23:01:55 +09:00
parent 3810955e56
commit 895386f6f8
11 changed files with 232 additions and 127 deletions

View File

@ -1,15 +1,21 @@
export const mapQueueItem = <T>(map: (item: any | null) => T, array: any[]): T[] => array
import {
ItemPlaylistPanelVideoRenderer,
PlaylistPanelVideoWrapperRenderer,
QueueItem
} from '@/types/datahost-get-state';
export const mapQueueItem = <T>(map: (item?: ItemPlaylistPanelVideoRenderer) => T, array: QueueItem[]): T[] => array
.map((item) => {
if ('playlistPanelVideoWrapperRenderer' in item) {
const keys = Object.keys(item.playlistPanelVideoWrapperRenderer.primaryRenderer);
return item.playlistPanelVideoWrapperRenderer.primaryRenderer[keys[0]];
const keys = Object.keys(item.playlistPanelVideoWrapperRenderer!.primaryRenderer) as (keyof PlaylistPanelVideoWrapperRenderer['primaryRenderer'])[];
return item.playlistPanelVideoWrapperRenderer!.primaryRenderer[keys[0]];
}
if ('playlistPanelVideoRenderer' in item) {
return item.playlistPanelVideoRenderer;
}
console.error('Music Together: Unknown item', item);
return null;
return undefined;
})
.map(map);