Skip to content

Commit

Permalink
Ensure /start navigates to /starter-pack when clicking a link int…
Browse files Browse the repository at this point in the history
…ernally (bluesky-social#4745)

* remove temporary metadata removal

* ensure proper navigation
  • Loading branch information
haileyok authored Jul 7, 2024
1 parent 6b5e318 commit a6b3c97
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
6 changes: 6 additions & 0 deletions src/lib/strings/url-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import TLDs from 'tlds'
import {logger} from '#/logger'
import {BSKY_SERVICE} from 'lib/constants'
import {isInvalidHandle} from 'lib/strings/handles'
import {startUriToStarterPackUri} from 'lib/strings/starter-pack'

export const BSKY_APP_HOST = 'https://bsky.app'
const BSKY_TRUSTED_HOSTS = [
Expand Down Expand Up @@ -187,6 +188,11 @@ export function convertBskyAppUrlIfNeeded(url: string): string {
if (isBskyAppUrl(url)) {
try {
const urlp = new URL(url)

if (isBskyStartUrl(url)) {
return startUriToStarterPackUri(urlp.pathname)
}

return urlp.pathname
} catch (e) {
console.error('Unexpected error in convertBskyAppUrlIfNeeded()', e)
Expand Down
56 changes: 27 additions & 29 deletions src/view/com/util/post-embeds/ExternalLinkEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,35 @@ export const ExternalLinkEmbed = ({
) : embedPlayerParams ? (
<ExternalPlayer link={link} params={embedPlayerParams} />
) : undefined}
{!starterPackParsed ? (
<View
style={[
a.flex_1,
a.py_sm,
{
paddingHorizontal: isMobile ? 10 : 14,
},
]}>
<View
style={[
a.flex_1,
a.py_sm,
{
paddingHorizontal: isMobile ? 10 : 14,
},
]}>
<Text
type="sm"
numberOfLines={1}
style={[pal.textLight, {marginVertical: 2}]}>
{toNiceDomain(link.uri)}
</Text>

{!embedPlayerParams?.isGif && !embedPlayerParams?.dimensions && (
<Text type="lg-bold" numberOfLines={3} style={[pal.text]}>
{link.title || link.uri}
</Text>
)}
{link.description ? (
<Text
type="sm"
numberOfLines={1}
style={[pal.textLight, {marginVertical: 2}]}>
{toNiceDomain(link.uri)}
type="md"
numberOfLines={link.thumb ? 2 : 4}
style={[pal.text, a.mt_xs]}>
{link.description}
</Text>

{!embedPlayerParams?.isGif && !embedPlayerParams?.dimensions && (
<Text type="lg-bold" numberOfLines={3} style={[pal.text]}>
{link.title || link.uri}
</Text>
)}
{link.description ? (
<Text
type="md"
numberOfLines={link.thumb ? 2 : 4}
style={[pal.text, a.mt_xs]}>
{link.description}
</Text>
) : undefined}
</View>
) : null}
) : undefined}
</View>
</LinkWrapper>
</View>
)
Expand Down

0 comments on commit a6b3c97

Please sign in to comment.