Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAY-2564] Remove old track download code #7942

Merged
merged 2 commits into from
Mar 26, 2024
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
2 changes: 0 additions & 2 deletions packages/common/src/store/downloads/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { CommonState } from '../commonStore'

export const getDownloadedPercentage = (state: CommonState) =>
state.downloads.downloadedPercentage
export const getFileName = (state: CommonState) => state.downloads.fileName
export const getFetchCancel = (state: CommonState) =>
state.downloads.fetchCancel
Expand Down
15 changes: 2 additions & 13 deletions packages/common/src/store/downloads/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import { Nullable } from '~/utils'
export type DownloadState = typeof initialState

type State = {
downloadedPercentage: number
fetchCancel: Nullable<() => void>
trackName: Nullable<string>
fileName: Nullable<string>
error?: Error
}

const initialState: State = {
downloadedPercentage: 0,
fetchCancel: null,
trackName: null,
fileName: null
Expand All @@ -31,10 +29,6 @@ const slice = createSlice({
state.error = action.payload
},
// Mobile only
setDownloadedPercentage: (state, action: PayloadAction<number>) => {
state.downloadedPercentage = action.payload
},
// Mobile only
setFileInfo: (
state,
action: PayloadAction<{
Expand All @@ -52,13 +46,8 @@ const slice = createSlice({
}
})

export const {
beginDownload,
setDownloadedPercentage,
setFileInfo,
setFetchCancel,
setDownloadError
} = slice.actions
export const { beginDownload, setFileInfo, setFetchCancel, setDownloadError } =
slice.actions
export const actions = slice.actions

export default slice.reducer
2 changes: 0 additions & 2 deletions packages/mobile/src/app/Drawers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { CreateChatActionsDrawer } from 'app/components/create-chat-actions-draw
import { DeactivateAccountConfirmationDrawer } from 'app/components/deactivate-account-confirmation-drawer'
import { DeleteChatDrawer } from 'app/components/delete-chat-drawer'
import { DeletePlaylistConfirmationDrawer } from 'app/components/delete-playlist-confirmation-drawer'
import { DownloadTrackProgressDrawer } from 'app/components/download-track-progress-drawer'
import { ReleaseNowConfirmationDrawer } from 'app/components/drawers/ReleaseNowConfirmationDrawer'
import { DuplicateAddConfirmationDrawer } from 'app/components/duplicate-add-confirmation-drawer'
import { EditCollectiblesDrawer } from 'app/components/edit-collectibles-drawer'
Expand Down Expand Up @@ -132,7 +131,6 @@ const commonDrawersMap: { [Modal in Modals]?: ComponentType } = {
const nativeDrawersMap: { [DrawerName in Drawer]?: ComponentType } = {
EnablePushNotifications: EnablePushNotificationsDrawer,
OfflineListening: OfflineListeningDrawer,
DownloadTrackProgress: DownloadTrackProgressDrawer,
ForgotPassword: ForgotPasswordDrawer,
DeleteTrackConfirmation: DeleteTrackConfirmationDrawer,
ReleaseNowConfirmation: ReleaseNowConfirmationDrawer,
Expand Down

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions packages/mobile/src/services/track-download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { dedupFilenames } from '~/utils'

import { make, track as trackEvent } from 'app/services/analytics'
import { dispatch } from 'app/store'
import { setVisibility } from 'app/store/drawers/slice'
import { EventNames } from 'app/types/analytics'

import { audiusBackendInstance } from './audius-backend-instance'
Expand Down Expand Up @@ -66,16 +65,8 @@ const downloadOne = async ({
).fetch('GET', fileUrl)
fetchTasks = [fetchTask]

// TODO: The ReactNativeBlobUtil library is currently broken for download progress events on both platforms.
// fetchTask.progress({ interval: 250 }, (received, total) => {
// dispatch(setDownloadedPercentage((received / total) * 100))
// })

const fetchRes = await fetchTask

// Do this after download is done
dispatch(setVisibility({ drawer: 'DownloadTrackProgress', visible: false }))

await onFetchComplete?.(fetchRes.path())

// Track download success event
Expand Down
3 changes: 0 additions & 3 deletions packages/mobile/src/store/drawers/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export type BaseDrawerData = Record<string, unknown>
export type Drawer =
| 'EnablePushNotifications'
| 'DeactivateAccountConfirmation'
| 'DownloadTrackProgress'
| 'ForgotPassword'
| 'NowPlaying'
| 'CancelEditTrack'
Expand Down Expand Up @@ -36,7 +35,6 @@ export type Drawer =
export type DrawerData = {
EnablePushNotifications: undefined
DeactivateAccountConfirmation: undefined
DownloadTrackProgress: undefined
ForgotPassword: undefined
NowPlaying: undefined
CancelEditTrack: undefined
Expand Down Expand Up @@ -85,7 +83,6 @@ export type DrawersState = { [drawer in Drawer]: boolean | 'closing' } & {
const initialState: DrawersState = {
EnablePushNotifications: false,
DeactivateAccountConfirmation: false,
DownloadTrackProgress: false,
ForgotPassword: false,
NowPlaying: false,
CancelEditTrack: false,
Expand Down
26 changes: 1 addition & 25 deletions packages/web/src/pages/track-page/TrackPageProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ class TrackPageProvider extends Component<
previewing,
buffering,
userId,
pause,
downloadTrack
pause
} = this.props
const heroPlaying =
playing &&
Expand Down Expand Up @@ -474,7 +473,6 @@ class TrackPageProvider extends Component<
onHeroRepost: this.onHeroRepost,
onHeroShare: this.onHeroShare,
onSaveTrack: this.onSaveTrack,
onDownloadTrack: downloadTrack,
onClickMobileOverflow: this.props.clickOverflow,
onConfirmUnfollow: this.props.onConfirmUnfollow,
goToFavoritesPage: this.goToFavoritesPage,
Expand Down Expand Up @@ -600,28 +598,6 @@ function mapDispatchToProps(dispatch: Dispatch) {
),
onConfirmUnfollow: (userId: ID) =>
dispatch(unfollowConfirmationActions.setOpen(userId)),
downloadTrack: ({
trackId,
category,
parentTrackId
}: {
trackId: ID
category?: string
parentTrackId?: ID
}) => {
dispatch(
socialTracksActions.downloadTrack({
trackIds: [trackId],
parentTrackId
})
)
const trackEvent: TrackEvent = make(Name.TRACK_PAGE_DOWNLOAD, {
id: trackId,
category,
parent_track_id: parentTrackId
})
dispatch(trackEvent)
},
clickOverflow: (trackId: ID, overflowActions: OverflowAction[]) =>
dispatch(
open({ source: OverflowSource.TRACKS, id: trackId, overflowActions })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,6 @@ type TrackHeaderProps = {
onShare: () => void
onSave: () => void
onRepost: () => void
onDownload: ({
trackId,
category,
parentTrackId
}: {
trackId: ID
category?: string
parentTrackId?: ID
}) => void
goToFavoritesPage: (trackId: ID) => void
goToRepostsPage: (trackId: ID) => void
}
Expand Down Expand Up @@ -198,7 +189,6 @@ const TrackHeader = ({
onShare,
onSave,
onRepost,
onDownload,
onClickMobileOverflow,
goToFavoritesPage,
goToRepostsPage
Expand Down
11 changes: 0 additions & 11 deletions packages/web/src/pages/track-page/components/mobile/TrackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ export type OwnProps = {
) => void

onSaveTrack: (isSaved: boolean, trackId: ID) => void
onDownloadTrack: ({
trackId,
category,
parentTrackId
}: {
trackId: ID
category?: string
parentTrackId?: ID
}) => void
// Tracks Lineup Props
tracks: LineupState<Track>
currentQueueItem: QueueItem
Expand Down Expand Up @@ -97,7 +88,6 @@ const TrackPage = ({
goToAllRemixesPage,
goToParentRemixesPage,
onSaveTrack,
onDownloadTrack,
onHeroRepost,
onClickMobileOverflow,

Expand Down Expand Up @@ -201,7 +191,6 @@ const TrackPage = ({
onSave={onSave}
onShare={onShare}
onRepost={onRepost}
onDownload={onDownloadTrack}
isUnlisted={defaults.isUnlisted}
isStreamGated={defaults.isStreamGated}
streamConditions={defaults.streamConditions}
Expand Down