diff options
author | dan <dan.abramov@gmail.com> | 2024-10-08 08:58:42 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-07 16:58:42 -0700 |
commit | dd8be2e939d2879e2bb23b2ccd843a034d19b8dd (patch) | |
tree | fe5ec58ce2fdc72e0112993e85d4efdc265eca25 /src/view/com/composer/state | |
parent | e564fe9cc6abd69f4dfc0cef968dc38741cfc759 (diff) | |
download | voidsky-dd8be2e939d2879e2bb23b2ccd843a034d19b8dd.tar.zst |
Use composer state as source of truth for embeds/links on publish (#5606)
Co-authored-by: Mary <git@mary.my.id> Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'src/view/com/composer/state')
-rw-r--r-- | src/view/com/composer/state/composer.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/view/com/composer/state/composer.ts b/src/view/com/composer/state/composer.ts index 769a0521d..62d1bff49 100644 --- a/src/view/com/composer/state/composer.ts +++ b/src/view/com/composer/state/composer.ts @@ -1,6 +1,10 @@ import {ImagePickerAsset} from 'expo-image-picker' -import {isBskyPostUrl} from '#/lib/strings/url-helpers' +import { + isBskyPostUrl, + postUriToRelativePath, + toBskyAppUrl, +} from '#/lib/strings/url-helpers' import {ComposerImage, createInitialImages} from '#/state/gallery' import {Gif} from '#/state/queries/tenor' import {ComposerOpts} from '#/state/shell/composer' @@ -29,7 +33,7 @@ type Link = { // This structure doesn't exactly correspond to the data model. // Instead, it maps to how the UI is organized, and how we present a post. -type EmbedDraft = { +export type EmbedDraft = { // We'll always submit quote and actual media (images, video, gifs) chosen by the user. quote: Link | undefined media: ImagesMedia | VideoMedia | GifMedia | undefined @@ -304,9 +308,13 @@ export function createComposerState({ } let quote: Link | undefined if (initQuoteUri) { - quote = { - type: 'link', - uri: initQuoteUri, + // TODO: Consider passing the app url directly. + const path = postUriToRelativePath(initQuoteUri) + if (path) { + quote = { + type: 'link', + uri: toBskyAppUrl(path), + } } } // TODO: Other initial content. |