Feedback
This commit is contained in:
@@ -31,7 +31,7 @@ export function useLiveLinkMetaQuery(url: string | null) {
|
|||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!url) return undefined
|
if (!url) return undefined
|
||||||
const urlp = new URL(url)
|
const urlp = new URL(url)
|
||||||
if (!liveNowConfig.allowedDomains.includes(urlp.hostname)) {
|
if (!liveNowConfig.allowedDomains.has(urlp.hostname)) {
|
||||||
const {formatted} = getLiveServiceNames(liveNowConfig.allowedDomains)
|
const {formatted} = getLiveServiceNames(liveNowConfig.allowedDomains)
|
||||||
throw new Error(
|
throw new Error(
|
||||||
_(
|
_(
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ const serviceUrlToNameMap: Record<string, string> = {
|
|||||||
'skylight.social': 'Skylight',
|
'skylight.social': 'Skylight',
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLiveServiceNames(domains: string[]) {
|
export function getLiveServiceNames(domains: Set<string>) {
|
||||||
const names = Array.from(
|
const names = Array.from(
|
||||||
new Set(domains.map(d => serviceUrlToNameMap[d] || d)),
|
new Set(Array.from(domains.values()).map(d => serviceUrlToNameMap[d] || d)),
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
names,
|
names,
|
||||||
|
|||||||
@@ -2,6 +2,11 @@ import {LinearGradient} from 'expo-linear-gradient'
|
|||||||
|
|
||||||
import {atoms as a, useTheme, utils, type ViewStyleProp} from '#/alf'
|
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) {
|
export function Gradient({style}: ViewStyleProp) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export function validateStatus(
|
|||||||
try {
|
try {
|
||||||
if (AppBskyEmbedExternal.isView(status.embed)) {
|
if (AppBskyEmbedExternal.isView(status.embed)) {
|
||||||
const url = new URL(status.embed.external.uri)
|
const url = new URL(status.embed.external.uri)
|
||||||
return config.allowedDomains.includes(url.hostname)
|
return config.allowedDomains.has(url.hostname)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,16 +87,18 @@ export function useTrendingConfig() {
|
|||||||
|
|
||||||
const DEFAULT_LIVE_ALLOWED_DOMAINS = ['twitch.tv', 'www.twitch.tv']
|
const DEFAULT_LIVE_ALLOWED_DOMAINS = ['twitch.tv', 'www.twitch.tv']
|
||||||
export type LiveNowConfig = {
|
export type LiveNowConfig = {
|
||||||
allowedDomains: string[]
|
allowedDomains: Set<string>
|
||||||
}
|
}
|
||||||
export function useLiveNowConfig(): LiveNowConfig {
|
export function useLiveNowConfig(): LiveNowConfig {
|
||||||
const ctx = useContext(LiveNowContext)
|
const ctx = useContext(LiveNowContext)
|
||||||
const canGoLive = useCanGoLive()
|
const canGoLive = useCanGoLive()
|
||||||
const {currentAccount} = useSession()
|
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)
|
const vip = ctx.find(live => live.did === currentAccount.did)
|
||||||
return {
|
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