@@ -136,10 +136,12 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
136
136
setShareAsImagePreferences,
137
137
} = useShareAsImagePreferences ( ) ;
138
138
139
+ const isComment = "comment" in data ;
140
+
139
141
// eslint-disable-next-line no-nested-ternary
140
142
const defaultMinDepth = allParentComments
141
143
? 0
142
- : "comment" in data
144
+ : isComment
143
145
? getDepthFromComment ( data . comment . comment )
144
146
: 0 ;
145
147
@@ -156,7 +158,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
156
158
} , [ blob ] ) ;
157
159
158
160
const filteredComments = useMemo ( ( ) => {
159
- if ( ! ( "comment" in data ) ) return [ ] ;
161
+ if ( ! isComment ) return [ ] ;
160
162
161
163
const filtered = data . comments
162
164
. filter (
@@ -251,8 +253,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
251
253
async function onShare ( ) {
252
254
if ( ! blob ) return ;
253
255
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 ;
256
257
257
258
const filename = `${ apId
258
259
. replace ( / ^ h t t p s : \/ \/ / , "" )
@@ -312,7 +313,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
312
313
) }
313
314
314
315
< StyledIonList inset lines = "full" >
315
- { "comment" in data && (
316
+ { isComment && (
316
317
< >
317
318
< IonItem >
318
319
< IonToggle
@@ -326,7 +327,7 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
326
327
Include Post Details
327
328
</ IonToggle >
328
329
</ IonItem >
329
- { includePostDetails && hasPostBody ? (
330
+ { ( isComment ? includePostDetails : true ) && hasPostBody ? (
330
331
< IonItem >
331
332
< IonToggle
332
333
checked = { includePostContent }
@@ -426,16 +427,16 @@ export default function ShareAsImage({ data, header }: ShareAsImageProps) {
426
427
< ShareImageContext . Provider
427
428
value = { { capturing : true , hideUsernames, hideCommunity } }
428
429
>
429
- { includePostDetails && (
430
+ { ( isComment ? includePostDetails : true ) && (
430
431
< PostHeader
431
- className = { ! ( "comment" in data ) ? hideBottomBorderCss : "" }
432
+ className = { ! isComment ? hideBottomBorderCss : "" }
432
433
post = { data . post }
433
- showPostText = { includePostContent }
434
+ showPostText = { isComment ? includePostContent : true }
434
435
showPostActions = { false }
435
436
constrainHeight = { false }
436
437
/>
437
438
) }
438
- { "comment" in data && (
439
+ { isComment && (
439
440
< >
440
441
{ includePostDetails && < PostCommentSpacer /> }
441
442
< CommentTree
0 commit comments