⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions packages/common/src/store/upload/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const UPDATE_TRACK_AUDIO = 'UPLOAD/UPDATE_TRACK_AUDIO'
export const UPDATE_PERCENT = 'UPLOAD/UPDATE_PERCENT'
export const INCREMENT_PERCENT = 'UPLOAD/INCREMENT_PERCENT'
export const UPDATE_PROGRESS = 'UPLOAD/UPDATE_PROGRESS'
export const RESET_PROGRESS = 'UPLOAD/RESET_PROGRESS'
export const RESET = 'UPLOAD/RESET'
export const TOGGLE_MULTI_TRACK_NOTIFICATION =
'UPLOAD/TOGGLE_MULTI_TRACK_NOTIFICATION'
Expand Down Expand Up @@ -66,14 +65,6 @@ export const uploadTracksFailed = () => {
return { type: UPLOAD_TRACKS_FAILED }
}

export const resetProgress = (payload: {
clientId: string
stemIndex: number | null
key: 'audio' | 'image'
}) => {
return { type: RESET_PROGRESS, payload }
}

export const updateProgress = (payload: {
clientId: string
stemIndex: number | null
Expand Down
39 changes: 4 additions & 35 deletions packages/common/src/store/upload/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
uploadTracksSucceeded,
updateProgress,
updateFormState,
UPDATE_FORM_STATE,
type resetProgress,
RESET_PROGRESS
UPDATE_FORM_STATE
} from './actions'
import {
ProgressState,
Expand Down Expand Up @@ -96,7 +94,9 @@ const actionsMap = {
newState.uploading = true
const existingProgress = state.uploadProgress ?? []
newState.uploadProgress = tracks?.map(
(t, i) => existingProgress[i] ?? getInitialProgress(t)
(t) =>
existingProgress.find((p) => p && p.clientId === t.clientId) ??
getInitialProgress(t)
)
newState.metadata =
action.payload.uploadType === UploadType.ALBUM ||
Expand Down Expand Up @@ -130,37 +130,6 @@ const actionsMap = {
newState.error = true
return newState
},
[RESET_PROGRESS](
state: UploadState,
action: ReturnType<typeof resetProgress>
) {
const { clientId, stemIndex, key } = action.payload

const newState = { ...state }
newState.uploadProgress = [...(state.uploadProgress ?? [])]

const trackIndex = newState.uploadProgress.findIndex(
(p) => p && p.clientId === clientId
)

if (trackIndex === -1) {
return state
}

if (stemIndex !== null) {
if (!newState.uploadProgress[trackIndex]?.stems[stemIndex]) {
return state
}
newState.uploadProgress[trackIndex].stems[stemIndex][key] = cloneDeep(
initialUploadState[key]
)
} else {
newState.uploadProgress[trackIndex][key] = cloneDeep(
initialUploadState[key]
)
}
return newState
},
[UPDATE_PROGRESS](
state: UploadState,
action: ReturnType<typeof updateProgress>
Expand Down
Loading