diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 2b5b74bfa..a8f19743c 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -44,6 +44,7 @@ import { type PostDraft, type ThreadDraft, } from '#/view/com/composer/state/composer' +import {IS_IOS, IS_WEB} from '#/env' import {createGIFDescription} from '../gif-alt-text' import {detectFacets} from '../strings/detect-facets' import {uploadBlob} from './upload-blob' @@ -89,6 +90,11 @@ export async function post( const did = agent.assertDid const writes: $Typed[] = [] const uris: string[] = [] + const via = IS_WEB + ? 'Witchsky Web App' + : IS_IOS + ? 'Witchsky for iPhone' + : 'Witchsky for Android' let now = new Date() let tid: TID | undefined @@ -124,7 +130,8 @@ export async function post( const rt = await rtPromise const embed = await embedPromise const reply = await replyPromise - const record: AppBskyFeedPost.Record = { + const record: AppBskyFeedPost.Record & {via: string} = { + via, // IMPORTANT: $type has to exist, CID is calculated with the `$type` field // present and will produce the wrong CID if you omit it. $type: 'app.bsky.feed.post', @@ -237,6 +244,10 @@ async function resolveRT(agent: BskyAgent, richtext: RichText) { ) } + if (rt.facets?.length === 0) { + delete rt.facets + } + rt = shortenLinks(rt) rt = stripInvalidMentions(rt) return rt diff --git a/src/screens/PostThread/components/ThreadItemAnchor.tsx b/src/screens/PostThread/components/ThreadItemAnchor.tsx index f767b0568..2b9ebe876 100644 --- a/src/screens/PostThread/components/ThreadItemAnchor.tsx +++ b/src/screens/PostThread/components/ThreadItemAnchor.tsx @@ -579,6 +579,7 @@ function ExpandedPostDetails({ const t = useTheme() const {i18n} = useLingui() const isRootPost = !('reply' in post.record) + const via = post.record.via as string | undefined return ( @@ -587,6 +588,13 @@ function ExpandedPostDetails({ {niceDate(i18n, post.indexedAt, 'dot separated')} + {via ? ( + + {truncateVia(via)} + + ) : null} {isRootPost && ( )} @@ -595,6 +603,10 @@ function ExpandedPostDetails({ ) } +function truncateVia(via: string) { + return via.length > 24 ? `${via.slice(0, 23)}…` : via +} + function BackdatedPostIndicator({post}: {post: AppBskyFeedDefs.PostView}) { const t = useTheme() const {t: l, i18n} = useLingui()