Skip to content

Commit

Permalink
Stop displaying duration on items without streams
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Oct 17, 2022
1 parent d2d2ab7 commit a066912
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion packages/app/app/components/PlayQueue/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ const PlayQueue: React.FC<PlayQueueProps> = ({
}

return queue.queueItems.map((item, i) => {
const trackDuration = formatDuration(item.stream?.duration) === '00:00' && !item.loading
const trackDuration = formatDuration(item.stream?.duration) === '00:00' &&
!item.loading &&
Boolean(item.stream)
? t('live')
: formatDuration(item.stream?.duration);

Expand Down
15 changes: 10 additions & 5 deletions packages/ui/lib/components/QueueItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,21 @@ export const QueueItem = ({
</div>
</div>

<div className={styles.item_duration_container}>
<div className={styles.item_duration}>
{duration}
{
!isLoading &&
Boolean(track.stream) &&
<div className={styles.item_duration_container}>
<div className={styles.item_duration}>
{duration}
</div>
</div>
</div>
}
</>
}

{
Boolean(error) &&
Boolean(error) &&
!isCompact &&
<div className={styles.error_overlay}>
<div className={styles.error_message}>{error.message}</div>
<div className={styles.error_details}>{error.details}</div>
Expand Down
11 changes: 7 additions & 4 deletions packages/ui/stories/components/queueItem.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const commonProps = {
track: {
thumbnail: 'https://i.imgur.com/4euOws2.jpg',
name: 'Test track name',
artist: 'Test artist'
artist: 'Test artist',
stream: {}
},
isLoading: false,
isCurrent: false,
Expand All @@ -35,7 +36,8 @@ storiesOf('Components/Queue item', module)
track={{
thumbnail: 'https://i.imgur.com/aVNWf3j.jpg',
name: 'Small thumbnail',
artist: 'Test artist'
artist: 'Test artist',
stream: {}
}}
/>
</div>
Expand All @@ -58,7 +60,7 @@ storiesOf('Components/Queue item', module)
.add('Compact', () => (
<div className='bg'>
<div
style={{ width: '3rem' }}
style={{ width: '4rem' }}
>
<QueueItem {...commonProps} isCompact />
<QueueItem {...commonProps}
Expand All @@ -80,7 +82,8 @@ storiesOf('Components/Queue item', module)
<QueueItem {...commonProps}
track={{
name: 'Test track name',
artist: 'Test artist'
artist: 'Test artist',
stream: {}
}}
/>
<div
Expand Down

0 comments on commit a066912

Please sign in to comment.