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>
This commit is contained in:
dan
2024-10-08 08:58:42 +09:00
committed by GitHub
parent e564fe9cc6
commit dd8be2e939
4 changed files with 274 additions and 62 deletions
-2
View File
@@ -425,8 +425,6 @@ export const ComposePost = ({
composerState, // TODO: move more state here.
rawText: richtext.text,
replyTo: replyTo?.uri,
quote,
extLink,
labels,
threadgate: threadgateAllowUISettings,
postgate,
+13 -5
View File
@@ -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.