Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
[C-2141] Fix missing lineup when coming back online (#2863)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Mendelsohn <[email protected]>
Co-authored-by: Sebastian Klingler <[email protected]>
  • Loading branch information
3 people authored Feb 15, 2023
1 parent 88f5958 commit 9e4b90f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ const OfflineCollectionHeader = (props: OfflineCollectionHeaderProps) => {
[playlist_id, downloadSwitchValue]
)

const isReachable = useSelector(getIsReachable)

const showDownloadSwitchAndIndicator =
collection.has_current_user_saved ||
collection.playlist_owner_id === currentUserId
Expand Down Expand Up @@ -214,7 +216,7 @@ const OfflineCollectionHeader = (props: OfflineCollectionHeaderProps) => {
weight='demiBold'
fontSize='small'
>
{downloadStatus === OfflineDownloadStatus.LOADING
{downloadStatus === OfflineDownloadStatus.LOADING && isReachable
? messages.downloading
: headerText}
</Text>
Expand Down
32 changes: 22 additions & 10 deletions packages/web/src/common/store/lineup/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
take,
takeEvery,
takeLatest,
getContext
getContext,
race
} from 'redux-saga/effects'

import { getToQueue } from 'common/store/queue/sagas'
Expand Down Expand Up @@ -122,7 +123,7 @@ function* fetchLineupMetadatasAsync(
)
: initLineup.prefix

const task = yield fork(function* () {
function* fetchLineupMetadatasTask() {
try {
yield put(
lineupActions.fetchLineupMetadatasRequested(
Expand Down Expand Up @@ -284,15 +285,26 @@ function* fetchLineupMetadatasAsync(
console.error(err)
yield put(lineupActions.fetchLineupMetadatasFailed())
}
})
const { source: resetSource } = yield take(
baseLineupActions.addPrefix(lineupPrefix, baseLineupActions.RESET)
)
// If a source is specified in the reset action, make sure it matches the lineup source
// If not specified, cancel the fetchTrackMetdatas
if (!resetSource || resetSource === initSource) {
yield cancel(task)
}

function* shouldCancelTask() {
while (true) {
const { source: resetSource } = yield take(
baseLineupActions.addPrefix(lineupPrefix, baseLineupActions.RESET)
)

// If a source is specified in the reset action, make sure it matches the lineup source
// If not specified, cancel the fetchTrackMetdatas
if (!resetSource || resetSource === initSource) {
return true
}
}
}

yield race({
task: call(fetchLineupMetadatasTask),
cancel: call(shouldCancelTask)
})
}

function* updateQueueLineup(lineupPrefix, source, lineupEntries) {
Expand Down

0 comments on commit 9e4b90f

Please sign in to comment.