Skip to content

Commit a273f68

Browse files
committed
fix bug related to sharing the post as image
1 parent e0230b2 commit a273f68

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/features/share/asImage/ShareAsImage.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
136136
setShareAsImagePreferences,
137137
} = useShareAsImagePreferences();
138138

139+
const isComment = "comment" in data;
140+
139141
// eslint-disable-next-line no-nested-ternary
140142
const defaultMinDepth = allParentComments
141143
? 0
142-
: "comment" in data
144+
: isComment
143145
? getDepthFromComment(data.comment.comment)
144146
: 0;
145147

@@ -156,7 +158,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
156158
}, [blob]);
157159

158160
const filteredComments = useMemo(() => {
159-
if (!("comment" in data)) return [];
161+
if (!isComment) return [];
160162

161163
const filtered = data.comments
162164
.filter(
@@ -251,8 +253,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
251253
async function onShare() {
252254
if (!blob) return;
253255

254-
const apId =
255-
"comment" in data ? data.comment.comment.ap_id : data.post.post.ap_id;
256+
const apId = isComment ? data.comment.comment.ap_id : data.post.post.ap_id;
256257

257258
const filename = `${apId
258259
.replace(/^https:\/\//, "")
@@ -312,7 +313,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
312313
)}
313314

314315
<StyledIonList inset lines="full">
315-
{"comment" in data && (
316+
{isComment && (
316317
<>
317318
<IonItem>
318319
<IonToggle
@@ -326,7 +327,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
326327
Include Post Details
327328
</IonToggle>
328329
</IonItem>
329-
{includePostDetails && hasPostBody ? (
330+
{(isComment ? includePostDetails : true) && hasPostBody ? (
330331
<IonItem>
331332
<IonToggle
332333
checked={includePostContent}
@@ -426,16 +427,16 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
426427
<ShareImageContext.Provider
427428
value={{ capturing: true, hideUsernames, hideCommunity }}
428429
>
429-
{includePostDetails && (
430+
{(isComment ? includePostDetails : true) && (
430431
<PostHeader
431-
className={!("comment" in data) ? hideBottomBorderCss : ""}
432+
className={!isComment ? hideBottomBorderCss : ""}
432433
post={data.post}
433-
showPostText={includePostContent}
434+
showPostText={isComment ? includePostContent : true}
434435
showPostActions={false}
435436
constrainHeight={false}
436437
/>
437438
)}
438-
{"comment" in data && (
439+
{isComment && (
439440
<>
440441
{includePostDetails && <PostCommentSpacer />}
441442
<CommentTree

0 commit comments

Comments
 (0)