From b759f304ce53bf8913391e8e1c97ae02dcad0de6 Mon Sep 17 00:00:00 2001 From: Rishi Balakrishnan Date: Wed, 16 Sep 2026 14:19:18 -0400 Subject: [PATCH] feat(composer): allow media in private space posts --- src/lib/api/__tests__/space-post.test.ts | 14 ------ src/lib/api/space-post.ts | 6 --- src/view/com/composer/Composer.tsx | 62 +++--------------------- 3 files changed, 7 insertions(+), 75 deletions(-) diff --git a/src/lib/api/__tests__/space-post.test.ts b/src/lib/api/__tests__/space-post.test.ts index a31b20e23..2c7cf4c1f 100644 --- a/src/lib/api/__tests__/space-post.test.ts +++ b/src/lib/api/__tests__/space-post.test.ts @@ -49,20 +49,6 @@ const thread = (embed: object = {}, id = 'draft-operation-1') => describe(postToSpace, () => { beforeEach(() => jest.clearAllMocks()) - it.each(['images', 'gallery', 'video', 'gif'])( - 'blocks %s before embed resolution or a write', - async type => { - await expect( - postToSpace(agent, queryClient, SPACE, { - thread: thread({media: {type}}), - }), - ).rejects.toThrow(/not available in private spaces/i) - - expect(resolveEmbed).not.toHaveBeenCalled() - expect(spaceCreateRecord).not.toHaveBeenCalled() - }, - ) - it('refuses a quote from another space before embed resolution', async () => { await expect( postToSpace(agent, queryClient, SPACE, { diff --git a/src/lib/api/space-post.ts b/src/lib/api/space-post.ts index 535d89cc9..5bb964621 100644 --- a/src/lib/api/space-post.ts +++ b/src/lib/api/space-post.ts @@ -35,12 +35,6 @@ export async function postToSpace( const langs = opts.langs?.slice(0, 3) const uris: string[] = [] - if (thread.posts.some(draft => draft.embed.media)) { - throw new Error( - t`Photos, videos, and GIFs are not available in private spaces yet.`, - ) - } - // Read access is uniform within a space but not across spaces, so quoting // another space's post here would name a private post to people who cannot // see it. Same space is fine — everyone reading this record can already read diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index f2d61e698..ba2ff2982 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -422,39 +422,6 @@ export const ComposePost = ({ ) const thread = composerState.thread - const spaceTarget = - thread.communitySpaceUri ?? - (isSpaceBackedFeed(thread.communityFeed?.config) - ? thread.communityFeed.config.space - : undefined) - - useEffect(() => { - if (!spaceTarget) return - for (const post of thread.posts) { - const media = post.embed.media - if (media?.type === 'images' || media?.type === 'gallery') { - for (const image of media.images) { - composerDispatch({ - type: 'update_post', - postId: post.id, - postAction: {type: 'embed_remove_image', image}, - }) - } - } else if (media?.type === 'video') { - composerDispatch({ - type: 'update_post', - postId: post.id, - postAction: {type: 'embed_remove_video'}, - }) - } else if (media?.type === 'gif') { - composerDispatch({ - type: 'update_post', - postId: post.id, - postAction: {type: 'embed_remove_gif'}, - }) - } - } - }, [spaceTarget, thread.posts]) // Clear error when composer content changes, but only if all posts are // back within the character limit. @@ -1435,7 +1402,6 @@ export const ComposePost = ({ languageNudgeAt={languageNudgeAt} openGallery={openGallery} textInputRef={textInputRef} - spaceMediaDisabled={!!spaceTarget} /> ) @@ -2191,7 +2157,6 @@ function ComposerFooter({ languageNudgeAt, openGallery, textInputRef, - spaceMediaDisabled, }: { post: PostDraft dispatch: (action: PostAction) => void @@ -2204,7 +2169,6 @@ function ComposerFooter({ languageNudgeAt: number openGallery?: boolean textInputRef: React.RefObject - spaceMediaDisabled: boolean }) { const t = useTheme() const {t: l} = useLingui() @@ -2241,10 +2205,9 @@ function ComposerFooter({ const onSelectGif = useCallback( (gif: Gif) => { - if (spaceMediaDisabled) return dispatch({type: 'embed_add_gif', gif}) }, - [dispatch, spaceMediaDisabled], + [dispatch], ) /* @@ -2256,7 +2219,6 @@ function ComposerFooter({ const onSelectAssets = useCallback( async ({type, assets, errors}) => { - if (spaceMediaDisabled) return setSelectedAssetsType(type) if (assets.length) { @@ -2293,7 +2255,7 @@ function ComposerFooter({ }) }) }, - [post.id, onSelectVideo, onImageAdd, spaceMediaDisabled], + [post.id, onSelectVideo, onImageAdd], ) return ( @@ -2315,7 +2277,7 @@ function ComposerFooter({ ) : ( - + {IS_WEB && gtPhone ? ( @@ -2356,11 +2313,6 @@ function ComposerFooter({ )} - {spaceMediaDisabled ? ( - - Media isn’t available in private spaces yet. - - ) : null} {showAddButton && ( -- knotmirror 0.0.1