Feedback
This commit is contained in:
@@ -31,7 +31,7 @@ export function useLiveLinkMetaQuery(url: string | null) {
|
||||
queryFn: async () => {
|
||||
if (!url) return undefined
|
||||
const urlp = new URL(url)
|
||||
if (!liveNowConfig.allowedDomains.includes(urlp.hostname)) {
|
||||
if (!liveNowConfig.allowedDomains.has(urlp.hostname)) {
|
||||
const {formatted} = getLiveServiceNames(liveNowConfig.allowedDomains)
|
||||
throw new Error(
|
||||
_(
|
||||
|
||||
@@ -51,9 +51,9 @@ const serviceUrlToNameMap: Record<string, string> = {
|
||||
'skylight.social': 'Skylight',
|
||||
}
|
||||
|
||||
export function getLiveServiceNames(domains: string[]) {
|
||||
export function getLiveServiceNames(domains: Set<string>) {
|
||||
const names = Array.from(
|
||||
new Set(domains.map(d => serviceUrlToNameMap[d] || d)),
|
||||
new Set(Array.from(domains.values()).map(d => serviceUrlToNameMap[d] || d)),
|
||||
)
|
||||
return {
|
||||
names,
|
||||
|
||||
@@ -2,6 +2,11 @@ import {LinearGradient} from 'expo-linear-gradient'
|
||||
|
||||
import {atoms as a, useTheme, utils, type ViewStyleProp} from '#/alf'
|
||||
|
||||
/**
|
||||
* A gradient overlay using the primary color at low opacity. This component is
|
||||
* absolutely positioned and intended to be composed within other components,
|
||||
* with optional styling allowed, such as adjusting border radius.
|
||||
*/
|
||||
export function Gradient({style}: ViewStyleProp) {
|
||||
const t = useTheme()
|
||||
return (
|
||||
|
||||
@@ -72,7 +72,7 @@ export function validateStatus(
|
||||
try {
|
||||
if (AppBskyEmbedExternal.isView(status.embed)) {
|
||||
const url = new URL(status.embed.external.uri)
|
||||
return config.allowedDomains.includes(url.hostname)
|
||||
return config.allowedDomains.has(url.hostname)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -87,16 +87,18 @@ export function useTrendingConfig() {
|
||||
|
||||
const DEFAULT_LIVE_ALLOWED_DOMAINS = ['twitch.tv', 'www.twitch.tv']
|
||||
export type LiveNowConfig = {
|
||||
allowedDomains: string[]
|
||||
allowedDomains: Set<string>
|
||||
}
|
||||
export function useLiveNowConfig(): LiveNowConfig {
|
||||
const ctx = useContext(LiveNowContext)
|
||||
const canGoLive = useCanGoLive()
|
||||
const {currentAccount} = useSession()
|
||||
if (!currentAccount?.did || !canGoLive) return {allowedDomains: []}
|
||||
if (!currentAccount?.did || !canGoLive) return {allowedDomains: new Set()}
|
||||
const vip = ctx.find(live => live.did === currentAccount.did)
|
||||
return {
|
||||
allowedDomains: DEFAULT_LIVE_ALLOWED_DOMAINS.concat(vip ? vip.domains : []),
|
||||
allowedDomains: new Set(
|
||||
DEFAULT_LIVE_ALLOWED_DOMAINS.concat(vip ? vip.domains : []),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user