|
|
@@ -23,6 +23,7 @@ type SongData = {
|
|
|
active: boolean;
|
|
|
parentActive: boolean;
|
|
|
highlight: boolean;
|
|
|
+ queuePosition: number;
|
|
|
};
|
|
|
|
|
|
type Separator = {
|
|
|
@@ -35,6 +36,29 @@ const isSeparator = (item: ItemData | Separator): item is Separator => !Reflect.
|
|
|
|
|
|
const itemKey = (index: number, data: ItemData[]): number => data[index].id;
|
|
|
|
|
|
+const queueSymbols = [
|
|
|
+ '⑴',
|
|
|
+ '⑵',
|
|
|
+ '⑶',
|
|
|
+ '⑷',
|
|
|
+ '⑸',
|
|
|
+ '⑹',
|
|
|
+ '⑺',
|
|
|
+ '⑻',
|
|
|
+ '⑼',
|
|
|
+ '⑽',
|
|
|
+ '⑾',
|
|
|
+ '⑿',
|
|
|
+ '⒀',
|
|
|
+ '⒁',
|
|
|
+ '⒂',
|
|
|
+ '⒃',
|
|
|
+ '⒄',
|
|
|
+ '⒅',
|
|
|
+ '⒆',
|
|
|
+ '⒇',
|
|
|
+];
|
|
|
+
|
|
|
const Row = namedMemo<{ index: number; data: ItemData[]; style: CSSProperties }>(
|
|
|
'Song',
|
|
|
({ index, data, style }) => {
|
|
|
@@ -46,9 +70,14 @@ const Row = namedMemo<{ index: number; data: ItemData[]; style: CSSProperties }>
|
|
|
</Styled.Separator>
|
|
|
);
|
|
|
}
|
|
|
- const { song, active, parentActive, highlight } = item;
|
|
|
+ const { song, active, parentActive, highlight, queuePosition } = item;
|
|
|
return (
|
|
|
<Styled.Song active={active} parentActive={parentActive} style={style} highlight={highlight}>
|
|
|
+ <Styled.QueuePosition invert={active && !parentActive}>
|
|
|
+ {queuePosition >= 0 && queuePosition < queueSymbols.length
|
|
|
+ ? queueSymbols[queuePosition]
|
|
|
+ : ''}
|
|
|
+ </Styled.QueuePosition>
|
|
|
<NoWrapFill>
|
|
|
{song.track ? `${song.track} - ` : ''}
|
|
|
{song.title || 'Untitled Track'}
|
|
|
@@ -60,7 +89,7 @@ const Row = namedMemo<{ index: number; data: ItemData[]; style: CSSProperties }>
|
|
|
|
|
|
export const Songs: React.FC<Props> = ({ active: parentActive }) => {
|
|
|
const globalState = useContext(StateContext);
|
|
|
- const { songId: playingSongId } = globalState.player;
|
|
|
+ const { songId: playingSongId, queue } = globalState.player;
|
|
|
|
|
|
const state = useContext(CmusUIStateContext);
|
|
|
const { activeArtist, activeAlbum, activeSongId } = state.library;
|
|
|
@@ -74,6 +103,7 @@ export const Songs: React.FC<Props> = ({ active: parentActive }) => {
|
|
|
active: song.id === activeSongId,
|
|
|
parentActive,
|
|
|
highlight: song.id === playingSongId,
|
|
|
+ queuePosition: queue.indexOf(song.id),
|
|
|
}));
|
|
|
|
|
|
if (activeAlbum !== null) {
|
|
|
@@ -84,7 +114,7 @@ export const Songs: React.FC<Props> = ({ active: parentActive }) => {
|
|
|
(last, [album, group], index) => [...last, { id: -index, album }, ...group],
|
|
|
[],
|
|
|
);
|
|
|
- }, [parentActive, activeSongId, playingSongId, filteredSongs, activeAlbum]);
|
|
|
+ }, [parentActive, activeSongId, playingSongId, filteredSongs, activeAlbum, queue]);
|
|
|
|
|
|
const getItemSize = useCallback(
|
|
|
(index: number): number => lineHeight * (isSeparator(itemData[index]) ? 2 : 1),
|