Files
bsky-social-app/src/lib/routes/links.ts
T
Samuel Newman 377d80e21d Handle notifications on first load (#8629)
* add getInitialURL

* get deep linking working

* actually handle as push instead

* push to route instead of setting initial path

* pop to on top of notifications

* fix comment

* change chat-message handling

* add metrics

* don't reopen due to notif multiple times

* extract data from notification differently on android

* sorry sorry annoying naming nits, align logger

---------

Co-authored-by: Eric Bailey <git@esb.lol>
2025-07-10 16:36:53 -05:00

59 lines
1.6 KiB
TypeScript

import {type AppBskyGraphDefs, AtUri} from '@atproto/api'
import {isInvalidHandle} from '#/lib/strings/handles'
export function makeProfileLink(
info: {
did: string
handle: string
},
...segments: string[]
) {
let handleSegment = info.did
if (info.handle && !isInvalidHandle(info.handle)) {
handleSegment = info.handle
}
return [`/profile`, handleSegment, ...segments].join('/')
}
export function makeCustomFeedLink(
did: string,
rkey: string,
segment?: string | undefined,
feedCacheKey?: 'discover' | 'explore' | undefined,
) {
return (
[`/profile`, did, 'feed', rkey, ...(segment ? [segment] : [])].join('/') +
(feedCacheKey ? `?feedCacheKey=${encodeURIComponent(feedCacheKey)}` : '')
)
}
export function makeListLink(did: string, rkey: string, ...segments: string[]) {
return [`/profile`, did, 'lists', rkey, ...segments].join('/')
}
export function makeTagLink(did: string) {
return `/search?q=${encodeURIComponent(did)}`
}
export function makeSearchLink(props: {query: string; from?: 'me' | string}) {
return `/search?q=${encodeURIComponent(
props.query + (props.from ? ` from:${props.from}` : ''),
)}`
}
export function makeStarterPackLink(
starterPackOrName:
| AppBskyGraphDefs.StarterPackViewBasic
| AppBskyGraphDefs.StarterPackView
| string,
rkey?: string,
) {
if (typeof starterPackOrName === 'string') {
return `https://bsky.app/start/${starterPackOrName}/${rkey}`
} else {
const uriRkey = new AtUri(starterPackOrName.uri).rkey
return `https://bsky.app/start/${starterPackOrName.creator.handle}/${uriRkey}`
}
}