Signed-off-by: mbrucedogs <mbrucedogs@gmail.com>
This commit is contained in:
parent
364f53fb21
commit
bc1f7cce88
@ -1,8 +1,8 @@
|
|||||||
import React, { useMemo, useCallback } from 'react';
|
import React, { useMemo, useCallback } from 'react';
|
||||||
import { IonItem, IonLabel } from '@ionic/react';
|
import { IonItem, IonLabel, IonIcon } from '@ionic/react';
|
||||||
import ActionButton from './ActionButton';
|
import ActionButton from './ActionButton';
|
||||||
import { useAppSelector } from '../../redux';
|
import { useAppSelector } from '../../redux';
|
||||||
import { selectQueue, selectFavorites, selectCurrentSinger } from '../../redux';
|
import { selectQueue, selectFavorites, selectCurrentSinger, selectTopPlayedArray } from '../../redux';
|
||||||
import { useActions } from '../../hooks/useActions';
|
import { useActions } from '../../hooks/useActions';
|
||||||
import { useModal } from '../../hooks/useModalContext';
|
import { useModal } from '../../hooks/useModalContext';
|
||||||
import { debugLog } from '../../utils/logger';
|
import { debugLog } from '../../utils/logger';
|
||||||
@ -10,6 +10,7 @@ import type { SongItemProps, QueueItem, Song } from '../../types';
|
|||||||
import { SongItemContext } from '../../types';
|
import { SongItemContext } from '../../types';
|
||||||
import { ActionButtonVariant, ActionButtonSize, ActionButtonIconSlot } from '../../types';
|
import { ActionButtonVariant, ActionButtonSize, ActionButtonIconSlot } from '../../types';
|
||||||
import { Icons } from '../../constants';
|
import { Icons } from '../../constants';
|
||||||
|
import { star } from 'ionicons/icons';
|
||||||
|
|
||||||
// Utility function to extract filename from path
|
// Utility function to extract filename from path
|
||||||
const extractFilename = (path: string): string => {
|
const extractFilename = (path: string): string => {
|
||||||
@ -29,11 +30,13 @@ export const SongInfoDisplay: React.FC<{
|
|||||||
showPath?: boolean;
|
showPath?: boolean;
|
||||||
showCount?: boolean;
|
showCount?: boolean;
|
||||||
showFullPath?: boolean;
|
showFullPath?: boolean;
|
||||||
|
showTopPlayedStar?: boolean;
|
||||||
}> = React.memo(({
|
}> = React.memo(({
|
||||||
song,
|
song,
|
||||||
showPath = false,
|
showPath = false,
|
||||||
showCount = false,
|
showCount = false,
|
||||||
showFullPath = false
|
showFullPath = false,
|
||||||
|
showTopPlayedStar = false
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<IonLabel>
|
<IonLabel>
|
||||||
@ -43,9 +46,19 @@ export const SongInfoDisplay: React.FC<{
|
|||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontSize: '1rem',
|
fontSize: '1rem',
|
||||||
color: 'var(--ion-color-dark)',
|
color: 'var(--ion-color-dark)',
|
||||||
marginBottom: '4px'
|
marginBottom: '4px',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '8px'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{showTopPlayedStar && (
|
||||||
|
<IonIcon
|
||||||
|
icon={star}
|
||||||
|
color="warning"
|
||||||
|
style={{ fontSize: '1rem' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{song.title}
|
{song.title}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -210,6 +223,7 @@ const SongItem: React.FC<SongItemProps> = React.memo(({
|
|||||||
const queue = useAppSelector(selectQueue);
|
const queue = useAppSelector(selectQueue);
|
||||||
const favorites = useAppSelector(selectFavorites);
|
const favorites = useAppSelector(selectFavorites);
|
||||||
const currentSingerName = useAppSelector(selectCurrentSinger);
|
const currentSingerName = useAppSelector(selectCurrentSinger);
|
||||||
|
const topPlayedArray = useAppSelector(selectTopPlayedArray);
|
||||||
|
|
||||||
// Get unified action handlers
|
// Get unified action handlers
|
||||||
const { handleAddToQueue, handleToggleFavorite, handleRemoveFromQueue } = useActions();
|
const { handleAddToQueue, handleToggleFavorite, handleRemoveFromQueue } = useActions();
|
||||||
@ -226,6 +240,11 @@ const SongItem: React.FC<SongItemProps> = React.memo(({
|
|||||||
[favorites, song.path]
|
[favorites, song.path]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isInTopPlayed = useMemo(() =>
|
||||||
|
(Object.values(topPlayedArray) as Song[]).some(topSong => topSong.path === song.path),
|
||||||
|
[topPlayedArray, song.path]
|
||||||
|
);
|
||||||
|
|
||||||
// Find queue item key for removal (only needed for queue context)
|
// Find queue item key for removal (only needed for queue context)
|
||||||
const queueItemKey = useMemo(() =>
|
const queueItemKey = useMemo(() =>
|
||||||
context === SongItemContext.QUEUE
|
context === SongItemContext.QUEUE
|
||||||
@ -292,6 +311,7 @@ const SongItem: React.FC<SongItemProps> = React.memo(({
|
|||||||
showPath={shouldShowPath}
|
showPath={shouldShowPath}
|
||||||
showCount={shouldShowCount}
|
showCount={shouldShowCount}
|
||||||
showFullPath={showFullPath}
|
showFullPath={showFullPath}
|
||||||
|
showTopPlayedStar={isInTopPlayed}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{showActions && (
|
{showActions && (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user