1import PluginManager from '@/core/pluginManager'; 2import {useEffect, useState} from 'react'; 3 4export default function useTopListDetail( 5 topListItem: IMusic.IMusicTopListItem | null, 6 pluginHash: string, 7) { 8 const [mergedTopListItem, setMergedTopListItem] = 9 useState<ICommon.WithMusicList<IMusic.IMusicTopListItem> | null>( 10 topListItem, 11 ); 12 useEffect(() => { 13 if (topListItem === null) { 14 return; 15 } 16 PluginManager.getByHash(pluginHash) 17 ?.methods?.getTopListDetail(topListItem) 18 ?.then(_ => { 19 if (_) { 20 setMergedTopListItem(prev => ({ 21 ...(prev ?? {}), 22 ...(_ ?? {}), 23 })); 24 } 25 }); 26 }, []); 27 return mergedTopListItem; 28} 29