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

Commit

Permalink
Use track permalinks for links on mobile (#128)
Browse files Browse the repository at this point in the history
* Initial draft of using permalinks rather than route ids

* Consolidate types
  • Loading branch information
rickyrombo committed Oct 13, 2021
1 parent c4876d7 commit 853d220
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 97 deletions.
89 changes: 43 additions & 46 deletions packages/audius-mobile-client/src/models/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,53 +53,50 @@ export type TrackImage = {
cover_art_sizes: Nullable<CID>
}

export type TrackId = {
export type TrackMetadata = TrackImage & {
track_id: number
route_id: string
}

export type TrackMetadata = TrackImage &
TrackId & {
blocknumber: number
activity_timestamp?: string
is_delete: boolean
created_at: string
isrc: Nullable<string>
iswc: Nullable<string>
credits_splits: Nullable<string>
description: Nullable<string>
followee_reposts: Repost[]
followee_saves: Favorite[]
genre: string
has_current_user_reposted: boolean
has_current_user_saved: boolean
download: Nullable<Download>
license: Nullable<string>
mood: Nullable<string>
play_count: number
owner_id: ID
release_date: Nullable<string>
repost_count: number
save_count: number
tags: Nullable<string>
title: string
track_segments: TrackSegment[]
is_unlisted: boolean
field_visibility?: FieldVisibility
listenCount?: number

// Optional Fields
is_invalid?: boolean
stem_of?: {
parent_track_id: ID
category: StemCategory
}
remix_of: Nullable<RemixOf>

// Added fields
dateListened?: string
duration: number
} & Timestamped
blocknumber: number
activity_timestamp?: string
is_delete: boolean
created_at: string
isrc: Nullable<string>
iswc: Nullable<string>
credits_splits: Nullable<string>
description: Nullable<string>
followee_reposts: Repost[]
followee_saves: Favorite[]
genre: string
has_current_user_reposted: boolean
has_current_user_saved: boolean
download: Nullable<Download>
license: Nullable<string>
mood: Nullable<string>
play_count: number
owner_id: ID
release_date: Nullable<string>
repost_count: number
save_count: number
tags: Nullable<string>
title: string
track_segments: TrackSegment[]
is_unlisted: boolean
field_visibility?: FieldVisibility
listenCount?: number

permalink: string

// Optional Fields
is_invalid?: boolean
stem_of?: {
parent_track_id: ID
category: StemCategory
}
remix_of: Nullable<RemixOf>

// Added fields
dateListened?: string
duration: number
} & Timestamped

export type Stem = {
track_id: ID
Expand Down
96 changes: 48 additions & 48 deletions packages/audius-mobile-client/src/store/search/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TrackImage, TrackId } from '../../models/Track'
import { TrackImage } from '../../models/Track'
import { CollectionImage } from '../../models/Collection'
import {
UserImage,
Expand Down Expand Up @@ -36,54 +36,54 @@ export type SearchUser = UserMultihash &
user_id: number
}

export type SearchTrack = TrackImage &
TrackId & {
description: string | null
genre: string
mood: string
release_date: null
remix_of: null
repost_count: number
tags: null
title: string
user: SearchUser
duration: number
play_count: null
blocknumber: number
create_date: null
created_at: string
credits_splits: null
download: {
cid: null
is_downloadable: false
requires_follow: false
}
isrc: null
license: null
iswc: null
field_visibility: {
mood: boolean
tags: boolean
genre: boolean
share: boolean
play_count: boolean
remixes: null
}
followee_reposts: {}[]
has_current_user_reposted: null
is_unlisted: boolean
has_current_user_saved: null
stem_of: null
updated_at: string
is_delete: boolean
track_id: number
owner_id: number
followee_saves: []
save_count: null
track_segments: { duration: number; multihash: string }[]
followee_favorites: null
user_id: number
export type SearchTrack = TrackImage & {
description: string | null
genre: string
mood: string
release_date: null
remix_of: null
repost_count: number
tags: null
title: string
user: SearchUser
duration: number
play_count: null
blocknumber: number
create_date: null
created_at: string
credits_splits: null
download: {
cid: null
is_downloadable: false
requires_follow: false
}
isrc: null
license: null
iswc: null
field_visibility: {
mood: boolean
tags: boolean
genre: boolean
share: boolean
play_count: boolean
remixes: null
}
followee_reposts: {}[]
has_current_user_reposted: null
is_unlisted: boolean
has_current_user_saved: null
stem_of: null
updated_at: string
is_delete: boolean
track_id: number
owner_id: number
followee_saves: []
save_count: null
track_segments: { duration: number; multihash: string }[]
followee_favorites: null
user_id: number
permalink: string
}

export type SearchPlaylist = CollectionImage & {
description: string | null
Expand Down
6 changes: 3 additions & 3 deletions packages/audius-mobile-client/src/utils/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Config from 'react-native-config'
import { TrackId } from '../models/Track'
import { TrackMetadata } from '../models/Track'
import { UserCollection } from '../models/Collection'
import { UserHandle } from '../models/User'

Expand Down Expand Up @@ -37,8 +37,8 @@ export const encodeUrlName = (name: string) => {

const AUDIUS_URL = Config.AUDIUS_URL

export const getTrackRoute = (track: TrackId, fullUrl = false) => {
const route = `/${track.route_id}-${track.track_id}`
export const getTrackRoute = (track: TrackMetadata, fullUrl = false) => {
const route = track.permalink
return fullUrl ? `${AUDIUS_URL}${route}` : route
}

Expand Down

0 comments on commit 853d220

Please sign in to comment.