-
Notifications
You must be signed in to change notification settings - Fork 123
[PE-6063] Deprecate audius-query collection.ts #11976
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
Changes from all commits
748403b
730f9e2
0d02d0a
5379024
0fb078c
60a95f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,10 @@ import { | |
| } from '~/store/cache' | ||
| import { gatedContentSelectors } from '~/store/gated-content' | ||
| import { CommonState } from '~/store/reducers' | ||
| import { isContentCollection, isContentTrack } from '~/utils/contentTypeUtils' | ||
| import { | ||
| isContentPartialCollection, | ||
| isContentPartialTrack | ||
| } from '~/utils/contentTypeUtils' | ||
| import { Nullable, removeNullable } from '~/utils/typeUtils' | ||
|
|
||
| import { useFeatureFlag } from './useFeatureFlag' | ||
|
|
@@ -64,25 +67,24 @@ export const useGatedCollectionAccess = (collectionId: ID) => { | |
| return { hasStreamAccess } | ||
| } | ||
|
|
||
| type PartialTrack = Pick< | ||
| Track, | ||
| | 'track_id' | ||
| | 'is_stream_gated' | ||
| | 'is_download_gated' | ||
| | 'access' | ||
| | 'stream_conditions' | ||
| | 'download_conditions' | ||
| > | ||
|
|
||
| type PartialCollection = Pick< | ||
| Collection, | ||
| 'playlist_id' | 'is_stream_gated' | 'access' | 'stream_conditions' | ||
| > | ||
|
|
||
| // Returns whether user has access to given track. | ||
| export const useGatedContentAccess = ( | ||
| content: | ||
| | Nullable< | ||
| | Pick< | ||
| Track, | ||
| | 'track_id' | ||
| | 'is_stream_gated' | ||
| | 'is_download_gated' | ||
| | 'access' | ||
| | 'stream_conditions' | ||
| | 'download_conditions' | ||
| > | ||
| | Pick< | ||
| Collection, | ||
| 'playlist_id' | 'is_stream_gated' | 'access' | 'stream_conditions' | ||
| > | ||
| > | ||
| | undefined | ||
| content: Nullable<PartialTrack> | Nullable<PartialCollection> | undefined | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
| ) => { | ||
| const nftAccessSignatureMap = useSelector(getNftAccessSignatureMap) | ||
| const hasAccount = useSelector(getHasAccount) | ||
|
|
@@ -97,8 +99,9 @@ export const useGatedContentAccess = ( | |
| } | ||
| } | ||
|
|
||
| const isTrack = isContentTrack(content) | ||
| const isCollection = isContentCollection(content) | ||
| const isTrack = isContentPartialTrack<PartialTrack>(content) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why we couldn't just typeguard content to a full track? but this is the old code so nbd
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm intentionally only selecting whatever args are needed for the track to avoid unnecessary rerenders from the query hook.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its an optimization pattern with tan-query that we're going to be doing a lot more of so this |
||
| const isCollection = | ||
| isContentPartialCollection<PartialCollection>(content) | ||
| const trackId = isTrack | ||
| ? content.track_id | ||
| : isCollection | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't fully understand where
createdAt,playlistContentswere initialized.. but okThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialized? not sure I follow - these are on the metadata of the collection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh my b plz ignore