From 5d124a3e14b833ce830e09f520acc6222f3aa301 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Mon, 22 Jul 2024 13:29:59 +0000 Subject: [PATCH] Make more post params cross-postable (#2621) --- src/shared/components/post/create-post.tsx | 6 ++++++ src/shared/components/post/post-listing.tsx | 14 +++++++++++++- src/shared/utils/types/cross-post-params.ts | 5 +++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/shared/components/post/create-post.tsx b/src/shared/components/post/create-post.tsx index 4c6073af..9235e776 100644 --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@ -203,6 +203,9 @@ export class CreatePost extends Component< title: locationState.name, url: locationState.url, body: locationState.body, + altText: locationState.altText, + nsfw: locationState.nsfw, + languageId: locationState.languageId, }); this.setState(s => ({ resetCounter: s.resetCounter + 1 })); } @@ -234,6 +237,7 @@ export class CreatePost extends Component< title, nsfw, url, + altText, } = this.props; const params: PostFormParams = { @@ -244,6 +248,7 @@ export class CreatePost extends Component< custom_thumbnail: customThumbnailUrl, language_id: languageId, nsfw: nsfw === "true", + alt_text: altText, }; return ( @@ -278,6 +283,7 @@ export class CreatePost extends Component< onUrlBlur={this.handleUrlBlur} onThumbnailUrlBlur={this.handleThumbnailUrlBlur} onNsfwChange={this.handleNsfwChange} + onAltTextBlur={this.handleAltTextBlur} onCopySuggestedTitle={this.handleCopySuggestedTitle} /> diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 1d8b3b0d..f9261347 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -878,7 +878,7 @@ export class PostListing extends Component { } get crossPostParams(): CrossPostParams { - const { name, url } = this.postView.post; + const { name, url, alt_text, nsfw, language_id } = this.postView.post; const crossPostParams: CrossPostParams = { name }; if (url) { @@ -890,6 +890,18 @@ export class PostListing extends Component { crossPostParams.body = crossPostBody; } + if (alt_text) { + crossPostParams.altText = alt_text; + } + + if (nsfw) { + crossPostParams.nsfw = nsfw ? "true" : "false"; + } + + if (language_id !== undefined) { + crossPostParams.languageId = language_id; + } + return crossPostParams; } diff --git a/src/shared/utils/types/cross-post-params.ts b/src/shared/utils/types/cross-post-params.ts index 9eb29b70..e63e5c1a 100644 --- a/src/shared/utils/types/cross-post-params.ts +++ b/src/shared/utils/types/cross-post-params.ts @@ -1,5 +1,10 @@ +import StringBoolean from "./string-boolean"; + export default interface CrossPostParams { name: string; url?: string; body?: string; + altText?: string; + nsfw?: StringBoolean; + languageId?: number; }