Skip to content

Commit 5801ad8

Browse files
committed
Deprecate queue item locking and retrying
1 parent 145b526 commit 5801ad8

9 files changed

Lines changed: 9 additions & 172 deletions

File tree

packages/app/app/actions/queue.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ type LocalTrack = Track & {
2121
local: true;
2222
};
2323

24-
export const streamLookupRetriesLimit = 3;
25-
2624
const isLocalTrack = (track: Track): track is LocalTrack => track.local;
2725

2826
const localTrackToQueueItem = (track: LocalTrack, local: LocalLibraryState): QueueItem => {
@@ -156,7 +154,6 @@ export const reloadTrack = (index: number) => async (dispatch, getState) => {
156154
updateQueueItem({
157155
...track,
158156
error: false,
159-
streamLookupRetries: 0,
160157
streams: []
161158
})
162159
);
@@ -278,17 +275,16 @@ export const findStreamsForTrack = (index: number) => async (dispatch, getState)
278275
}));
279276
} catch (e) {
280277
logger.error(
281-
`An error has occurred when searching for streams with ${selectedStreamProvider.sourceName} for "${track.artist} - ${track.name}". Retrying...`
278+
`An error has occurred when searching for streams with ${selectedStreamProvider.sourceName} for "${track.artist} - ${track.name}".`
282279
);
283280
logger.error(e);
284281

285282
track = getLatestTrack();
286283
dispatch(updateQueueItem({
287284
...track,
288285
loading: false,
289-
streamLookupRetries: (track.streamLookupRetries ?? 0) + 1,
290286
error: {
291-
message: 'Stream lookup error. Retrying...',
287+
message: 'Stream lookup error.',
292288
details: e.message
293289
}
294290
}));

packages/app/app/components/PlayQueue/QueueItemClone/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { useTranslation } from 'react-i18next';
88
export type QueueItemCloneProps = {
99
settings: SettingsState;
1010
queue: QueueStore;
11-
streamLookupRetriesLimit: number;
1211
onSelectTrack: (index: number) => () => void;
1312
onRemoveTrack: (index: number) => () => void;
1413
onReloadTrack: (index: number) => () => void;
@@ -18,7 +17,6 @@ export type QueueItemCloneProps = {
1817
export const QueueItemClone: (props: QueueItemCloneProps) => DraggableChildrenFn = ({
1918
settings,
2019
queue,
21-
streamLookupRetriesLimit,
2220
onSelectTrack,
2321
onRemoveTrack,
2422
onReloadTrack,
@@ -35,8 +33,6 @@ export const QueueItemClone: (props: QueueItemCloneProps) => DraggableChildrenFn
3533
isCompact={settings.compactQueueBar as boolean}
3634
isCurrent={queue.currentTrack === rubric.source.index}
3735
track={queue.queueItems[rubric.source.index]}
38-
streamLookupRetries={queue.queueItems[rubric.source.index].streamLookupRetries}
39-
streamLookupRetriesLimit={streamLookupRetriesLimit}
4036
onSelect={onSelectTrack(rubric.source.index)}
4137
onRemove={onRemoveTrack(rubric.source.index)}
4238
onReload={onReloadTrack(rubric.source.index)}

packages/app/app/components/PlayQueue/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { StreamVerificationContainer } from '../../containers/StreamVerification
2222

2323
import styles from './styles.scss';
2424
import { QueueItemClone } from './QueueItemClone';
25-
import { streamLookupRetriesLimit } from '../../actions/queue';
2625

2726
type PlayQueueProps = {
2827
actions: PlayQueueActions;
@@ -178,8 +177,6 @@ const PlayQueue: React.FC<PlayQueueProps> = ({
178177
isCurrent={data.queue.currentTrack === index}
179178
track={item}
180179
duration={formatTrackDuration(t)(item)}
181-
streamLookupRetries={item.streamLookupRetries}
182-
streamLookupRetriesLimit={streamLookupRetriesLimit}
183180
onSelect={onSelectTrack(index)}
184181
onRemove={onRemoveTrack(index)}
185182
onReload={onReloadTrack(index)}
@@ -234,7 +231,6 @@ const PlayQueue: React.FC<PlayQueueProps> = ({
234231
renderClone={QueueItemClone({
235232
settings,
236233
queue,
237-
streamLookupRetriesLimit,
238234
onSelectTrack,
239235
onRemoveTrack,
240236
onReloadTrack,

packages/app/app/containers/PlayerBarContainer/PlayerBarContainer.test.tsx

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -247,99 +247,6 @@ describe('PlayerBar container', () => {
247247
expect(state.queue.currentTrack).toBe(0);
248248
});
249249

250-
xit('should lock the track after failing to resolve stream URLs after 3 retries', async () => {
251-
const { store, component } = mountComponent({
252-
queue: {
253-
currentTrack: 0,
254-
queueItems: [
255-
{
256-
uuid: 'uuid1',
257-
artist: 'test artist name',
258-
name: 'track without streams',
259-
streamLookupRetries: 2
260-
// no streams provided
261-
}
262-
]
263-
},
264-
plugin: {
265-
plugins: {
266-
streamProviders: [
267-
{
268-
sourceName: 'Mocked Stream Provider',
269-
search: jest.fn(() => ([{
270-
id: 'test-stream-id',
271-
author: {
272-
name: 'test author'
273-
}
274-
}])),
275-
getStreamForId: jest.fn(() => {
276-
throw new Error('Failed to load stream.');
277-
})
278-
}
279-
]
280-
},
281-
selected: {
282-
streamProviders: 'Mocked Stream Provider'
283-
}
284-
}
285-
});
286-
287-
await waitFor(() => {
288-
const state = store.getState();
289-
const track = state.queue.queueItems[0];
290-
expect(track.error).toBeTruthy();
291-
expect(track.streamLookupRetries).toBe(3);
292-
});
293-
294-
const errorOverlay = await component.findByText('Failed to load stream.');
295-
expect(errorOverlay).toBeInTheDocument();
296-
});
297-
298-
xit('should increment streamLookupRetries after a stream lookup failure', async () => {
299-
const { store, component } = mountComponent({
300-
queue: {
301-
currentTrack: 0,
302-
queueItems: [
303-
{
304-
uuid: 'uuid1',
305-
artist: 'test artist name',
306-
name: 'track without streams',
307-
streamLookupRetries: 0,
308-
streams: []
309-
}
310-
]
311-
},
312-
plugin: {
313-
plugins: {
314-
streamProviders: [
315-
{
316-
sourceName: 'Mocked Stream Provider',
317-
search: jest.fn().mockResolvedValue(() => ([{
318-
id: 'test-stream-id',
319-
author: {
320-
name: 'test author'
321-
}
322-
}])),
323-
getStreamForId: jest.fn(() => {
324-
throw new Error('Failed to load stream.');
325-
})
326-
}
327-
]
328-
},
329-
selected: {
330-
streamProviders: 'Mocked Stream Provider'
331-
}
332-
}
333-
});
334-
335-
await waitFor(() => {
336-
const state = store.getState();
337-
const track = state.queue.queueItems[0];
338-
expect(track.streamLookupRetries).toBe(1);
339-
expect(track.error).toBeTruthy();
340-
});
341-
});
342-
343250
const mountComponent = (initialStore?: AnyProps) => {
344251
const store = configureMockStore({
345252
...buildStoreState()

packages/app/app/containers/PlayerBarContainer/hooks.streamLookup.test.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { shouldSearchForStreams } from './hooks';
22
import { QueueStore, QueueItem } from '../../reducers/queue';
3-
import { streamLookupRetriesLimit } from '../../actions/queue';
43

54
describe('shouldSearchForStreams', () => {
65
const createQueueStore = (items: QueueItem[]): QueueStore => ({
@@ -24,22 +23,7 @@ describe('shouldSearchForStreams', () => {
2423
expect(shouldSearchForStreams(queue)).toBe(false);
2524
});
2625

27-
it('returns false when an item with error has reached retries limit', () => {
28-
const queue = createQueueStore([
29-
{ error: { message: 'error', details: 'details' }, streamLookupRetries: streamLookupRetriesLimit, artist: 'A', name: 'a' }
30-
]);
31-
expect(shouldSearchForStreams(queue)).toBe(false);
32-
});
33-
34-
it('returns true when at least one item has no stream and has not reached retries limit', () => {
35-
const queue = createQueueStore([
36-
{ streams: [{ id: '1', source: '1', stream: 'http://test' }], artist: 'A', name: 'a' },
37-
{ error: { message: 'error', details: 'details' }, streamLookupRetries: streamLookupRetriesLimit - 1, artist: 'B', name: 'b' }
38-
]);
39-
expect(shouldSearchForStreams(queue)).toBe(true);
40-
});
41-
42-
it('returns true when at least one item has no stream and no error/retries info', () => {
26+
it('returns true when at least one item has no stream and no error info', () => {
4327
const queue = createQueueStore([
4428
{ streams: [], artist: 'A', name: 'a' }
4529
]);

packages/app/app/containers/PlayerBarContainer/hooks.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { playerSelectors } from '../../selectors/player';
1919
import { queue as queueSelector } from '../../selectors/queue';
2020
import { settingsSelector } from '../../selectors/settings';
2121
import { QueueItem, QueueStore } from '../../reducers/queue';
22-
import { streamLookupRetriesLimit } from '../../actions/queue';
2322

2423
export const useSeekbarProps = () => {
2524
const dispatch = useDispatch();
@@ -268,8 +267,7 @@ export const useStreamLookup = () => {
268267
if (
269268
currentTrack &&
270269
!currentTrack.loading &&
271-
queueActions.trackHasNoFirstStream(currentTrack) &&
272-
(currentTrack.streamLookupRetries === undefined || currentTrack.streamLookupRetries < 3)
270+
queueActions.trackHasNoFirstStream(currentTrack)
273271
) {
274272
dispatch(queueActions.findStreamsForTrack(queue.currentTrack));
275273
return;
@@ -280,8 +278,7 @@ export const useStreamLookup = () => {
280278
const nextTrackWithNoStream = queue.queueItems.findIndex((item, index) =>
281279
index !== queue.currentTrack &&
282280
!item.loading &&
283-
isEmpty(item.streams) &&
284-
(item.streamLookupRetries < streamLookupRetriesLimit || item.streamLookupRetries === undefined)
281+
isEmpty(item.streams)
285282
);
286283

287284
if (nextTrackWithNoStream !== -1) {
@@ -294,7 +291,6 @@ export const useStreamLookup = () => {
294291
export const shouldSearchForStreams = (queue: QueueStore): boolean => {
295292
return queue.queueItems.length > 0 && !queue.queueItems.every(item =>
296293
item.local ||
297-
(item.streams?.[0]?.stream) ||
298-
(item.error && item.streamLookupRetries !== undefined && item.streamLookupRetries >= streamLookupRetriesLimit)
294+
(item.streams?.[0]?.stream)
299295
);
300296
};

packages/app/app/reducers/queue.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export type QueueItem = {
2727
message: string;
2828
details: string;
2929
};
30-
streamLookupRetries?: number;
3130
local?: boolean;
3231
artist: string | { name: string };
3332
name: string;

packages/ui/lib/components/QueueItem/index.tsx

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export type QueueItemProps = {
2121
isCompact: boolean;
2222
track: Track;
2323
duration: string;
24-
streamLookupRetries: number;
25-
streamLookupRetriesLimit: number;
2624
onSelect: () => void;
2725
onRemove: () => void;
2826
onReload: () => void;
@@ -38,27 +36,21 @@ export const QueueItem: React.FC<QueueItemProps> = ({
3836
isCompact,
3937
track,
4038
duration,
41-
streamLookupRetries,
42-
streamLookupRetriesLimit,
4339
onRemove,
4440
onSelect,
4541
onReload,
4642
strings
4743
}) => {
48-
const isLocked = streamLookupRetries >= streamLookupRetriesLimit;
49-
5044
return (
5145
<div
5246
className={cx(
5347
common.nuclear,
5448
styles.queue_item,
5549
{ [`${styles.current_track}`]: isCurrent },
5650
{ [`${styles.error}`]: Boolean(track.error) },
57-
{ [`${styles.locked}`]: isLocked },
5851
{ [`${styles.compact}`]: isCompact }
5952
)}
6053
onDoubleClick={onSelect}
61-
onClick={isLocked && onReload}
6254
>
6355
<div className={styles.thumbnail}>
6456
{
@@ -67,14 +59,7 @@ export const QueueItem: React.FC<QueueItemProps> = ({
6759
}
6860

6961
{
70-
isLocked &&
71-
<div className={styles.lock}>
72-
<Icon name='lock' size={isCompact ? 'small' : 'big'} className={styles.lock_icon} />
73-
</div>
74-
}
75-
76-
{
77-
!track.loading && !isLocked &&
62+
!track.loading &&
7863
<Img
7964
src={getThumbnail(track) ?? artPlaceholder}
8065
unloader={<img src={artPlaceholder}/>}
@@ -95,7 +80,7 @@ export const QueueItem: React.FC<QueueItemProps> = ({
9580
</div>
9681

9782
{
98-
!track.error && !isLocked && !isCompact &&
83+
!track.error && !isCompact &&
9984
<>
10085
<div className={styles.item_info_container}>
10186
<div className={styles.name_container}>
@@ -108,7 +93,6 @@ export const QueueItem: React.FC<QueueItemProps> = ({
10893

10994
{
11095
!track.loading &&
111-
!isLocked &&
11296
!isEmpty(track.streams) &&
11397
<div className={styles.item_duration_container}>
11498
<div className={styles.item_duration}>
@@ -126,7 +110,7 @@ export const QueueItem: React.FC<QueueItemProps> = ({
126110
}
127111

128112
{
129-
isLocked && !isCompact &&
113+
!isCompact &&
130114
<div className={styles.error_overlay}>
131115
<div className={styles.error_message}>
132116
{strings.locked}

packages/ui/stories/components/queueItem.stories.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ const commonProps = {
2727
onReload: () => {
2828
alert('Item reloaded');
2929
},
30-
streamLookupRetries: 0,
31-
streamLookupRetriesLimit: 3,
3230
strings: {
3331
locked: 'Stream lookup failed. Click to start over.'
3432
}
@@ -97,14 +95,6 @@ export const Compact = () => (
9795
<QueueItem {...commonProps} isCompact
9896
track={{...commonProps.track, error: { message: 'An error has occurred.', details: 'Error details are available here.' }}}
9997
/>
100-
<QueueItem
101-
{...commonProps}
102-
isCompact
103-
track={{...commonProps.track
104-
}}
105-
streamLookupRetries={3}
106-
streamLookupRetriesLimit={3}
107-
/>
10898
</div>
10999
</div>
110100
);
@@ -141,14 +131,3 @@ export const Error = () => (
141131
/>
142132
</div>
143133
);
144-
145-
export const Locked = () => (
146-
<div className='bg'>
147-
<QueueItem {...commonProps}
148-
track={{...commonProps.track
149-
}}
150-
streamLookupRetries={3}
151-
streamLookupRetriesLimit={3}
152-
/>
153-
</div>
154-
);

0 commit comments

Comments
 (0)