[🐴] Post embeds polish (#4339)
* Handle message cleanup * Handle last message in chat list * Memoize lastMessage
This commit is contained in:
@@ -3,6 +3,7 @@ import psl from 'psl'
|
||||
import TLDs from 'tlds'
|
||||
|
||||
import {BSKY_SERVICE} from 'lib/constants'
|
||||
import {isInvalidHandle} from 'lib/strings/handles'
|
||||
|
||||
export const BSKY_APP_HOST = 'https://bsky.app'
|
||||
const BSKY_TRUSTED_HOSTS = [
|
||||
@@ -83,6 +84,10 @@ export function toShareUrl(url: string): string {
|
||||
return url
|
||||
}
|
||||
|
||||
export function toBskyAppUrl(url: string): string {
|
||||
return new URL(url, BSKY_APP_HOST).toString()
|
||||
}
|
||||
|
||||
export function isBskyAppUrl(url: string): boolean {
|
||||
return url.startsWith('https://bsky.app/')
|
||||
}
|
||||
@@ -183,6 +188,22 @@ export function feedUriToHref(url: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function postUriToRelativePath(
|
||||
uri: string,
|
||||
options?: {handle?: string},
|
||||
): string | undefined {
|
||||
try {
|
||||
const {hostname, rkey} = new AtUri(uri)
|
||||
const handleOrDid =
|
||||
options?.handle && !isInvalidHandle(options.handle)
|
||||
? options.handle
|
||||
: hostname
|
||||
return `/profile/${handleOrDid}/post/${rkey}`
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the label in the post text matches the host of the link facet.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user