This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
[PAY-1573] Convert premium content type to union #3711
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
39edc66
first run with type guards
dharit-tan e566cdd
some conversions
dharit-tan 5ce2f50
rest of conversion
dharit-tan 61a8691
Merge remote-tracking branch 'origin/gated-content-updates' into rt-p…
dharit-tan 742716f
always use typeguards
dharit-tan f03a104
Merge remote-tracking branch 'origin/gated-content-updates' into rt-p…
dharit-tan 86fcd85
lint yay
dharit-tan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,13 +1,14 @@ | ||
import type { ID, PremiumConditions } from '@audius/common' | ||
import { removeNullable, cacheUsersSelectors } from '@audius/common' | ||
import { | ||
isPremiumContentCollectibleGated, | ||
isPremiumContentFollowGated, | ||
isPremiumContentTipGated | ||
} from '@audius/common' | ||
import type { ViewStyle } from 'react-native' | ||
import { useSelector } from 'react-redux' | ||
|
||
import { DetailsTileHasAccess } from './DetailsTileHasAccess' | ||
import { DetailsTileNoAccess } from './DetailsTileNoAccess' | ||
|
||
const { getUsers } = cacheUsersSelectors | ||
|
||
type DetailsTilePremiumAccessProps = { | ||
trackId: ID | ||
premiumConditions: PremiumConditions | ||
|
@@ -23,17 +24,10 @@ export const DetailsTilePremiumAccess = ({ | |
doesUserHaveAccess, | ||
style | ||
}: DetailsTilePremiumAccessProps) => { | ||
const { follow_user_id: followUserId, tip_user_id: tipUserId } = | ||
premiumConditions ?? {} | ||
const users = useSelector((state) => | ||
getUsers(state, { | ||
ids: [followUserId, tipUserId].filter(removeNullable) | ||
}) | ||
) | ||
const followee = followUserId ? users[followUserId] : null | ||
const tippedUser = tipUserId ? users[tipUserId] : null | ||
const shouldDisplay = | ||
!!premiumConditions.nft_collection || followee || tippedUser | ||
isPremiumContentCollectibleGated(premiumConditions) || | ||
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. Eek, somehow made it more verbose. 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. ah good point. Probably good to keep it this way for now tho bc |
||
isPremiumContentFollowGated(premiumConditions) || | ||
isPremiumContentTipGated(premiumConditions) | ||
|
||
if (!shouldDisplay) return null | ||
|
||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ternaries here
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 think it's because of
?? {}
; if we had a branch that checked if premiumConditions was null first and then returned early we'd probably be good, tho would be tricky given hooks hereThere 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.
still getting type errors even if I null check first. gonna stick with the type guard for now but let's chat about it tmr.
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 can live with the type guards!