-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PAY-1248] Initial changes to get ready for upcoming PRs that include…
… track and playlist tiles in DMs (#3391) Co-authored-by: Saliou Diallo <saliou@audius.co> Co-authored-by: Andrew Mendelsohn <andrew.mendelsohn@audius.co>
- Loading branch information
1 parent
c2fabf6
commit 2ebaef5
Showing
10 changed files
with
136 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Kind } from 'models' | ||
|
||
import { createApi } from './createApi' | ||
|
||
const collectionApi = createApi({ | ||
reducerPath: 'collectionApi', | ||
endpoints: { | ||
getPlaylistByPermalink: { | ||
fetch: async ({ permalink, currentUserId }, { apiClient }) => { | ||
return { | ||
collection: ( | ||
await apiClient.getPlaylistByPermalink({ | ||
permalink, | ||
currentUserId | ||
}) | ||
)[0] | ||
} | ||
}, | ||
options: { | ||
permalinkArgKey: 'permalink', | ||
kind: Kind.COLLECTIONS, | ||
schemaKey: 'collection' | ||
} | ||
} | ||
} | ||
}) | ||
|
||
export const { useGetPlaylistByPermalink } = collectionApi.hooks | ||
export default collectionApi.reducer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './AudiusQueryContext' | ||
export * from './relatedArtists' | ||
export * from './track' | ||
export * from './collection' | ||
export * from './user' | ||
export * from './hooks' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { combineReducers } from 'redux' | ||
|
||
import collectionApi from './collection' | ||
import relatedArtistsApi from './relatedArtists' | ||
import trackApi from './track' | ||
import userApi from './user' | ||
|
||
export default combineReducers({ | ||
relatedArtistsApi, | ||
trackApi, | ||
collectionApi, | ||
userApi | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
const audiusUrlRegex = | ||
// eslint-disable-next-line no-useless-escape | ||
/^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?(staging\.)?(audius.co)(\/.+)?/gim | ||
/^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?(staging\.)?(audius\.co)(\/.+)?/gim | ||
|
||
export const isAudiusUrl = (url: string) => new RegExp(audiusUrlRegex).test(url) | ||
export const getPathFromAudiusUrl = (url: string) => | ||
new RegExp(audiusUrlRegex).exec(url)?.[3] ?? null | ||
|
||
const playlistUrlRegex = | ||
// eslint-disable-next-line no-useless-escape | ||
/^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?(staging\.)?(audius\.co)(\/[\S]+\/playlist\/[\S]+)$/gim | ||
|
||
export const isPlaylistUrl = (url: string) => | ||
new RegExp(playlistUrlRegex).test(url) | ||
export const getPathFromPlaylistUrl = (url: string) => { | ||
const results = new RegExp(trackUrlRegex).exec(url) | ||
if (!results) return null | ||
return results[3] | ||
} | ||
|
||
const trackUrlRegex = | ||
// eslint-disable-next-line no-useless-escape | ||
/^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?(staging\.)?(audius\.co)(\/[\S]+\/[\S]+)$/gim | ||
|
||
export const isTrackUrl = (url: string) => new RegExp(trackUrlRegex).test(url) | ||
export const getPathFromTrackUrl = (url: string) => { | ||
const results = new RegExp(trackUrlRegex).exec(url) | ||
if (!results) return null | ||
return results[3] | ||
} |