Straight passthrough links
This commit is contained in:
@@ -4,8 +4,8 @@ import {AtUri} from '@atproto/api'
|
|||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
// import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {feedUriToHref} from '#/lib/strings/url-helpers'
|
// import {feedUriToHref} from '#/lib/strings/url-helpers'
|
||||||
// import {Hashtag_Stroke2_Corner0_Rounded as Hashtag} from '#/components/icons/Hashtag'
|
// import {Hashtag_Stroke2_Corner0_Rounded as Hashtag} from '#/components/icons/Hashtag'
|
||||||
// import {CloseQuote_Filled_Stroke2_Corner0_Rounded as Quote} from '#/components/icons/Quote'
|
// import {CloseQuote_Filled_Stroke2_Corner0_Rounded as Quote} from '#/components/icons/Quote'
|
||||||
// import {UserAvatar} from '#/view/com/util/UserAvatar'
|
// import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
@@ -22,8 +22,6 @@ export function TrendingTopic({
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const topic = useTopic(raw)
|
const topic = useTopic(raw)
|
||||||
|
|
||||||
if (!topic) return null
|
|
||||||
|
|
||||||
const isSmall = size === 'small'
|
const isSmall = size === 'small'
|
||||||
// const hasAvi = topic.type === 'feed' || topic.type === 'profile'
|
// const hasAvi = topic.type === 'feed' || topic.type === 'profile'
|
||||||
// const aviSize = isSmall ? 16 : 20
|
// const aviSize = isSmall ? 16 : 20
|
||||||
@@ -139,8 +137,6 @@ export function TrendingTopicLink({
|
|||||||
} & Omit<LinkProps, 'to' | 'label'>) {
|
} & Omit<LinkProps, 'to' | 'label'>) {
|
||||||
const topic = useTopic(raw)
|
const topic = useTopic(raw)
|
||||||
|
|
||||||
if (!topic) return null
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InternalLink label={topic.label} to={topic.url} {...rest}>
|
<InternalLink label={topic.label} to={topic.url} {...rest}>
|
||||||
{children}
|
{children}
|
||||||
@@ -167,28 +163,32 @@ type ParsedTrendingTopic =
|
|||||||
export function useTopic(raw: TrendingTopic): ParsedTrendingTopic {
|
export function useTopic(raw: TrendingTopic): ParsedTrendingTopic {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
return React.useMemo(() => {
|
return React.useMemo(() => {
|
||||||
const {topic: displayName, link: uri} = raw
|
const {topic: displayName, link} = raw
|
||||||
|
|
||||||
if (!uri.startsWith('at://')) {
|
if (link.startsWith('/search')) {
|
||||||
if (uri.startsWith('/search')) {
|
|
||||||
return {
|
return {
|
||||||
type: 'topic',
|
type: 'topic',
|
||||||
label: _(msg`Browse posts about ${displayName}`),
|
label: _(msg`Browse posts about ${displayName}`),
|
||||||
displayName,
|
displayName,
|
||||||
uri: undefined,
|
uri: undefined,
|
||||||
url: uri,
|
url: link,
|
||||||
}
|
}
|
||||||
} else if (uri.startsWith('/hashtag')) {
|
} else if (link.startsWith('/hashtag')) {
|
||||||
return {
|
return {
|
||||||
type: 'tag',
|
type: 'tag',
|
||||||
label: _(msg`Browse posts tagged with ${displayName}`),
|
label: _(msg`Browse posts tagged with ${displayName}`),
|
||||||
displayName: displayName.replace(/^#/, ''),
|
displayName,
|
||||||
|
// displayName: displayName.replace(/^#/, ''),
|
||||||
uri: undefined,
|
uri: undefined,
|
||||||
url: uri,
|
url: link,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (!link.startsWith('at://')) {
|
||||||
|
// above logic
|
||||||
} else {
|
} else {
|
||||||
const urip = new AtUri(uri)
|
const urip = new AtUri(link)
|
||||||
switch (urip.collection) {
|
switch (urip.collection) {
|
||||||
case 'app.bsky.actor.profile': {
|
case 'app.bsky.actor.profile': {
|
||||||
return {
|
return {
|
||||||
@@ -205,18 +205,19 @@ export function useTopic(raw: TrendingTopic): ParsedTrendingTopic {
|
|||||||
label: _(msg`Browse the ${displayName} feed`),
|
label: _(msg`Browse the ${displayName} feed`),
|
||||||
displayName,
|
displayName,
|
||||||
uri: urip,
|
uri: urip,
|
||||||
url: feedUriToHref(uri),
|
url: feedUriToHref(link),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'unknown',
|
type: 'unknown',
|
||||||
label: _(msg`Browse topic ${displayName}`),
|
label: _(msg`Browse topic ${displayName}`),
|
||||||
displayName,
|
displayName,
|
||||||
uri: undefined,
|
uri: undefined,
|
||||||
url: uri,
|
url: link,
|
||||||
}
|
}
|
||||||
}, [_, raw])
|
}, [_, raw])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user