@openpeepshq/rn-components 0.13.0 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/package.json +3 -3
  2. package/src/components/icons/index.ts +2 -0
  3. package/src/components/jams/JamDeviceSelectors.tsx +31 -3
  4. package/src/components/jams/JamLobby.tsx +104 -5
  5. package/src/components/jams/JamVideoCall.tsx +157 -3
  6. package/src/components/jams/JamVideoLayout.tsx +9 -2
  7. package/src/components/jams/useLateTrackMediaStream.test.ts +145 -0
  8. package/src/components/jams/useLateTrackMediaStream.ts +61 -0
  9. package/src/components/layout/ContentHeader.tsx +6 -2
  10. package/src/components/layout/HeaderMobile.tsx +48 -22
  11. package/src/components/layout/PlusButton.tsx +1 -7
  12. package/src/components/layout/pageChrome.test.tsx +213 -0
  13. package/src/components/post/feed/events/EventsCalendar.test.tsx +144 -0
  14. package/src/components/post/feed/events/EventsCalendar.tsx +4 -8
  15. package/src/components/post/feed/events/EventsView.tsx +5 -13
  16. package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +14 -5
  17. package/src/components/post/post-form/PostForm.tsx +1 -0
  18. package/src/components/profile/ProfileCard.test.tsx +16 -1
  19. package/src/components/profile/ProfileCard.tsx +14 -3
  20. package/src/lib/dmMessageGate.test.ts +58 -0
  21. package/src/lib/livekit/useStableLiveKitRoom.ts +23 -13
  22. package/src/lib/utils.ts +4 -1
  23. package/src/pages/conversations/NewDraft.tsx +2 -3
  24. package/src/pages/conversations/Show.tsx +25 -30
  25. package/src/pages/events/Index.tsx +1 -5
  26. package/src/pages/events/My.tsx +1 -2
  27. package/src/pages/groups/Show.tsx +10 -2
  28. package/src/pages/posts/Edit.tsx +16 -6
  29. package/src/pages/posts/New.tsx +15 -5
  30. package/src/pages/posts/Reply.tsx +15 -6
@@ -109,6 +109,7 @@ export const PostForm = ({
109
109
 
110
110
  <OpenpeepsMarkdownInput
111
111
  autoFocus={autoFocus}
112
+ blockOverflow={false}
112
113
  value={content}
113
114
  onChange={(text) => form.setValue('data.content', text)}
114
115
  placeholder={
@@ -83,13 +83,14 @@ const profile = {
83
83
  bio: longBio,
84
84
  } as unknown as ProfileCardProps['profile'];
85
85
 
86
- const renderCard = () => {
86
+ const renderCard = (props: Partial<ProfileCardProps> = {}) => {
87
87
  let tree: ReturnType<typeof ReactTestRenderer.create>;
88
88
  ReactTestRenderer.act(() => {
89
89
  tree = ReactTestRenderer.create(
90
90
  React.createElement(ProfileCard, {
91
91
  profile,
92
92
  actionType: 'link' as const,
93
+ ...props,
93
94
  })
94
95
  );
95
96
  });
@@ -140,4 +141,18 @@ describe('ProfileCard layout guards (issue #2111)', () => {
140
141
  // Follow/Unfollow action is rendered and not clipped away.
141
142
  expect(tree.root.findByType('FollowUnfollowButton')).toBeDefined();
142
143
  });
144
+
145
+ it('drops the default spacing with unspaced (issue #1971)', () => {
146
+ const spaced = renderCard();
147
+ const spacedRow = spaced.root.findByProps({
148
+ className: 'w-full flex-row items-center justify-between px-4 mb-8',
149
+ });
150
+ expect(spacedRow).toBeDefined();
151
+
152
+ const unspaced = renderCard({ unspaced: true });
153
+ const unspacedRow = unspaced.root.findByProps({
154
+ className: 'w-full flex-row items-center justify-between',
155
+ });
156
+ expect(unspacedRow).toBeDefined();
157
+ });
143
158
  });
@@ -22,6 +22,12 @@ export interface ProfileCardProps {
22
22
  actionType?: 'follow' | 'message' | 'unfollow' | 'link' | 'select';
23
23
  handleSelectProfile?: () => void;
24
24
  rightComponent?: React.ReactNode;
25
+ /**
26
+ * Drop the default bottom margin and horizontal padding for placements
27
+ * that manage their own spacing (e.g. a bordered strip), mirroring web's
28
+ * tight card-to-border spacing.
29
+ */
30
+ unspaced?: boolean;
25
31
  }
26
32
 
27
33
  export const ProfileCard = ({
@@ -32,6 +38,7 @@ export const ProfileCard = ({
32
38
  actionType = 'link',
33
39
  handleSelectProfile,
34
40
  rightComponent,
41
+ unspaced = false,
35
42
  }: ProfileCardProps) => {
36
43
  const navigation =
37
44
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
@@ -59,9 +66,13 @@ export const ProfileCard = ({
59
66
 
60
67
  return (
61
68
  <View
62
- className={`w-full flex-row items-center justify-between px-4 ${
63
- actionType === 'select' ? 'mb-1 py-1' : 'mb-8'
64
- }`}
69
+ className={
70
+ unspaced
71
+ ? 'w-full flex-row items-center justify-between'
72
+ : `w-full flex-row items-center justify-between px-4 ${
73
+ actionType === 'select' ? 'mb-1 py-1' : 'mb-8'
74
+ }`
75
+ }
65
76
  >
66
77
  <TouchableWithoutFeedback onPress={onPress}>
67
78
  <View className="flex flex-row items-center gap-x-2 min-w-0 flex-1">
@@ -0,0 +1,58 @@
1
+ import { canSendDmMessage } from '../../../react/src/hooks/conversations/dmMessage';
2
+ import {
3
+ hasVisibleText,
4
+ POST_MAX_VISIBLE_LENGTH,
5
+ visibleTextLength,
6
+ } from '@openpeepshq/common';
7
+
8
+ const attachments: never[] = [];
9
+
10
+ describe('DM visible-length send gate', () => {
11
+ it('shares the note budget with the server refine', () => {
12
+ expect(POST_MAX_VISIBLE_LENGTH).toBe(500);
13
+ });
14
+
15
+ it('blocks a message whose visible text is over the budget', () => {
16
+ const text = 'x'.repeat(POST_MAX_VISIBLE_LENGTH + 1);
17
+ expect(visibleTextLength(text)).toBeGreaterThan(POST_MAX_VISIBLE_LENGTH);
18
+ expect(
19
+ canSendDmMessage({
20
+ sending: false,
21
+ uploadsPending: false,
22
+ text,
23
+ attachments,
24
+ })
25
+ ).toBe(false);
26
+ });
27
+
28
+ it('allows a markdown link whose URL alone is longer than the budget', () => {
29
+ const text =
30
+ '[a long but visibly short link](https://example.com/' +
31
+ 'y'.repeat(600) +
32
+ ')';
33
+ expect(text.length).toBeGreaterThan(POST_MAX_VISIBLE_LENGTH);
34
+ expect(visibleTextLength(text)).toBeLessThanOrEqual(
35
+ POST_MAX_VISIBLE_LENGTH
36
+ );
37
+ expect(
38
+ canSendDmMessage({
39
+ sending: false,
40
+ uploadsPending: false,
41
+ text,
42
+ attachments,
43
+ })
44
+ ).toBe(true);
45
+ });
46
+
47
+ it('blocks whitespace-only text without attachments', () => {
48
+ expect(hasVisibleText(' \n ')).toBe(false);
49
+ expect(
50
+ canSendDmMessage({
51
+ sending: false,
52
+ uploadsPending: false,
53
+ text: ' \n ',
54
+ attachments,
55
+ })
56
+ ).toBe(false);
57
+ });
58
+ });
@@ -33,6 +33,8 @@ export function useStableLiveKitRoom(
33
33
  kind?: string
34
34
  ) => void;
35
35
  onEncryptionError?: (error: Error) => void;
36
+ /** Runs after the signal connection, before tracks are enabled. */
37
+ onSignalConnected?: () => void | Promise<void>;
36
38
  simulateParticipants?: number;
37
39
  }
38
40
  ): void {
@@ -49,6 +51,7 @@ export function useStableLiveKitRoom(
49
51
  onError,
50
52
  onMediaDeviceFailure,
51
53
  onEncryptionError,
54
+ onSignalConnected,
52
55
  simulateParticipants,
53
56
  } = params;
54
57
 
@@ -59,23 +62,30 @@ export function useStableLiveKitRoom(
59
62
  connectOptionsRef.current = connectOptions;
60
63
  const connectOptionsKey = JSON.stringify(connectOptions);
61
64
 
65
+ // Callers typically pass a fresh handler object literal on every render;
66
+ // keep a stable ref so the wiring effect does not resubscribe each render.
67
+ const onSignalConnectedRef = React.useRef(onSignalConnected);
68
+ onSignalConnectedRef.current = onSignalConnected;
69
+
62
70
  React.useEffect(() => {
63
71
  const onSignalConnected = () => {
64
72
  const localP = room.localParticipant;
65
73
 
66
- Promise.all([
67
- localP.setMicrophoneEnabled(
68
- !!audio,
69
- typeof audio !== 'boolean' ? audio : undefined
70
- ),
71
- localP.setCameraEnabled(
72
- !!video,
73
- typeof video !== 'boolean' ? video : undefined
74
- ),
75
- // Screen share (and its capture permission) is disabled in React Native jams.
76
- // localP.setScreenShareEnabled(!!screen, typeof screen !== 'boolean' ? screen : undefined),
77
- ]).catch((e: unknown) => {
78
- onError?.(e as Error);
74
+ void Promise.resolve(onSignalConnectedRef.current?.()).then(() => {
75
+ Promise.all([
76
+ localP.setMicrophoneEnabled(
77
+ !!audio,
78
+ typeof audio !== 'boolean' ? audio : undefined
79
+ ),
80
+ localP.setCameraEnabled(
81
+ !!video,
82
+ typeof video !== 'boolean' ? video : undefined
83
+ ),
84
+ // Screen share (and its capture permission) is disabled in React Native jams.
85
+ // localP.setScreenShareEnabled(!!screen, typeof screen !== 'boolean' ? screen : undefined),
86
+ ]).catch((e: unknown) => {
87
+ onError?.(e as Error);
88
+ });
79
89
  });
80
90
  };
81
91
 
package/src/lib/utils.ts CHANGED
@@ -3,6 +3,7 @@ import { twMerge } from 'tailwind-merge';
3
3
  import { lightFormat, parse, parseJSON } from 'date-fns';
4
4
  import {
5
5
  GroupData,
6
+ POST_MAX_VISIBLE_LENGTH,
6
7
  Profile,
7
8
  PublicProfile,
8
9
  SuccessFailureResponse,
@@ -21,7 +22,9 @@ const DATE_FORMAT = 'MM/dd/yyyy';
21
22
  const TIME_FORMAT = 'hh:mm aaa';
22
23
  const DATE_TIME_FORMAT = `${DATE_FORMAT} ${TIME_FORMAT}`;
23
24
 
24
- export const maxContentLength = 500;
25
+ // DM/post composer budget — sourced from the shared note budget so the RN
26
+ // default and the server-side refine can never drift apart.
27
+ export const maxContentLength = POST_MAX_VISIBLE_LENGTH;
25
28
  export const maxArticleContentLength = 10000;
26
29
 
27
30
  export const formatDateTime = (date: Date) =>
@@ -115,6 +115,7 @@ export const DraftMessage = ({ navigation }: DraftMessageProps) => {
115
115
  ) : null}
116
116
  <OpenpeepsMarkdownInput
117
117
  rows={5}
118
+ blockOverflow={false}
118
119
  value={message}
119
120
  onChange={setMessage}
120
121
  maxLength={maxContentLength}
@@ -135,10 +136,8 @@ export const DraftMessage = ({ navigation }: DraftMessageProps) => {
135
136
  </Button>
136
137
  <TouchableOpacity
137
138
  onPress={() => void send()}
139
+ className={`p-2 rounded-full ${canSend ? 'bg-primary' : 'bg-surface'}`}
138
140
  disabled={!canSend}
139
- className={`p-2 rounded-full ${
140
- canSend ? 'bg-primary' : 'bg-surface'
141
- }`}
142
141
  >
143
142
  {submitting ? (
144
143
  <ActivityIndicator size={'small'} />
@@ -43,31 +43,7 @@ import {
43
43
  DirectMessageSearch,
44
44
  MessageInThread,
45
45
  } from '../../components/conversations/index';
46
-
47
- /**
48
- * Shows handle + bio for a 1:1 conversation participant, without a
49
- * duplicate avatar (the header already renders it).
50
- */
51
- const ConversationParticipantDetail = ({
52
- profile,
53
- }: {
54
- profile: import('@openpeepshq/common').Profile;
55
- }) => {
56
- const truncate = (text: string | null | undefined, max: number) =>
57
- !text ? '' : text.length > max ? text.slice(0, max) + '…' : text;
58
- return (
59
- <View className="gap-y-1 p-3">
60
- <ThemedText className="text-muted-foreground text-xs">
61
- @{profile.handle}
62
- </ThemedText>
63
- {profile.bio ? (
64
- <ThemedText className="text-sm">
65
- {truncate(profile.bio, 100)}
66
- </ThemedText>
67
- ) : null}
68
- </View>
69
- );
70
- };
46
+ import { ProfileCard } from '../../components/profile/index';
71
47
 
72
48
  const isMessageId = (value: string | undefined): value is string =>
73
49
  !!value &&
@@ -122,6 +98,9 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
122
98
  participants.length > 0
123
99
  ? participants.map((p) => p.displayName || `@${p.handle}`).join(', ')
124
100
  : t('conversations.title', { defaultValue: 'Conversation' });
101
+ const openParticipantsLabel = t('conversations.participants.openList', {
102
+ defaultValue: 'View participants',
103
+ });
125
104
 
126
105
  const resetForm = useCallback(() => {
127
106
  setContent('');
@@ -147,7 +126,9 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
147
126
  }, []);
148
127
 
149
128
  const handleSendMessage = async () => {
150
- if (!canSend) return;
129
+ if (!canSend) {
130
+ return;
131
+ }
151
132
 
152
133
  try {
153
134
  setIsSending(true);
@@ -208,6 +189,9 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
208
189
  : t('conversations.search.toggle', {
209
190
  defaultValue: 'Search this conversation',
210
191
  });
192
+ const infoLabel = t('conversations.info.title', {
193
+ defaultValue: 'Conversation info',
194
+ });
211
195
 
212
196
  useSetPageHeader(
213
197
  isLoading ? undefined : (
@@ -235,6 +219,8 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
235
219
  </TouchableOpacity>
236
220
  <TouchableOpacity
237
221
  onPress={() => navigation.navigate('ConversationInfo', { id })}
222
+ accessibilityRole="button"
223
+ accessibilityLabel={infoLabel}
238
224
  className="rounded-md p-1.5"
239
225
  >
240
226
  <InfoIcon size={18} className="text-foreground" />
@@ -255,13 +241,19 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
255
241
  <ThemedView className="flex-1">
256
242
  <View className="flex-1">
257
243
  {/* Section under the page header showing the participants,
258
- mirroring the web conversation Show page. */}
259
- <View className="border-b border-border">
244
+ mirroring the web conversation Show page (ProfileCard for 1:1). */}
245
+ <View className="border-b border-border p-4">
260
246
  {participants.length === 1 && participants[0] ? (
261
- <ConversationParticipantDetail profile={participants[0]} />
247
+ <ProfileCard
248
+ profile={participants[0]}
249
+ showAction={false}
250
+ unspaced
251
+ />
262
252
  ) : multipleParticipants ? (
263
253
  <TouchableOpacity
264
254
  onPress={() => setParticipantsOpen(true)}
255
+ accessibilityRole="button"
256
+ accessibilityLabel={openParticipantsLabel}
265
257
  className="w-full flex-row items-center gap-2 p-3"
266
258
  >
267
259
  <View className="flex-row -space-x-2 shrink-0">
@@ -287,7 +279,9 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
287
279
  <KeyboardAvoidingView
288
280
  className="flex-1"
289
281
  behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
290
- keyboardVerticalOffset={Platform.OS === 'ios' ? 90 : 0}
282
+ // iOS: total chrome above the composer (app bar row + h-16
283
+ // content header); re-measure when the shell chrome changes.
284
+ keyboardVerticalOffset={Platform.OS === 'ios' ? 74 : 0}
291
285
  >
292
286
  {searchOpen ? (
293
287
  <View nativeID="conversation-message-search">
@@ -367,6 +361,7 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
367
361
  <View className="px-4 py-3 bg-background border-t border-border">
368
362
  <OpenpeepsMarkdownInput
369
363
  rows={3}
364
+ blockOverflow={false}
370
365
  value={content}
371
366
  onChange={setContent}
372
367
  maxLength={maxContentLength}
@@ -88,11 +88,7 @@ export const EventsIndex = ({
88
88
  },
89
89
  ]}
90
90
  />
91
- <EventsView
92
- query={activeQuery}
93
- agenda={tab}
94
- list={<EventsFeed query={activeQuery} />}
95
- />
91
+ <EventsView list={<EventsFeed query={activeQuery} />} />
96
92
  <NewEventButton visibility={visibility} currentProfile={currentProfile} />
97
93
  </ThemedView>
98
94
  );
@@ -51,8 +51,7 @@ export const EventsMy: React.FC<MainScreenProps<'MyEvents'>> = () => {
51
51
  ]}
52
52
  />
53
53
  <EventsView
54
- query={activeQuery}
55
- agenda={tab}
54
+ calendar={{ mine: true }}
56
55
  list={<Feed query={activeQuery} formatSwitch={false} />}
57
56
  />
58
57
  </ThemedView>
@@ -24,6 +24,7 @@ import {
24
24
  } from '../../components/navigation/types/index';
25
25
  import {
26
26
  EventsFeed,
27
+ EventsView,
27
28
  NewEventButton,
28
29
  NewNoteButton,
29
30
  NewResourceButton,
@@ -172,8 +173,15 @@ export const GroupShow = ({ route, navigation }: GroupProps) => {
172
173
  </ThemedText>
173
174
  </Pressable>
174
175
  </View>
175
- <EventsFeed
176
- query={eventsTab === 'upcoming' ? upcomingEvents : pastEvents}
176
+ <EventsView
177
+ calendar={{ groupId: group.id }}
178
+ list={
179
+ <EventsFeed
180
+ query={
181
+ eventsTab === 'upcoming' ? upcomingEvents : pastEvents
182
+ }
183
+ />
184
+ }
177
185
  />
178
186
  </TabsContent>
179
187
  <TabsContent value="resources" className="p-0">
@@ -7,10 +7,12 @@ import { PostForm } from '../../components/post/post-form/PostForm';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { MainScreenProps } from '../../components/navigation/types/index';
9
9
  import {
10
- PostCreationData,
11
10
  pollOptionsWithinLimit,
11
+ PostCreationData,
12
12
  postCreationDataSchema,
13
+ canSubmitPostContent,
13
14
  resolvePollOptionContents,
15
+ visibleTextLength,
14
16
  } from '@openpeepshq/common';
15
17
  import { ActivityIndicator } from 'react-native';
16
18
  import { useForm } from 'react-hook-form';
@@ -47,6 +49,7 @@ export const EditPost = ({ route, navigation }: PostProps) => {
47
49
  const attachmentsProcessing = hasProcessingAttachments(postData);
48
50
 
49
51
  const trimmedContent = (postData?.data.content ?? '').trim();
52
+ const visibleContentLength = visibleTextLength(trimmedContent);
50
53
  const pollOptions =
51
54
  postData?.data.type === 'question'
52
55
  ? postData.data.options.map((option) => option.content)
@@ -63,21 +66,28 @@ export const EditPost = ({ route, navigation }: PostProps) => {
63
66
  return false;
64
67
  }
65
68
  if (postData.data.type === 'question') {
66
- return trimmedContent.length > 0 && pollOptionsValid;
69
+ return canSubmitPostContent({
70
+ visibleContentLength,
71
+ attachmentsLength: postData.data.attachments?.length ?? 0,
72
+ composerType: 'question',
73
+ pollOptionsValid,
74
+ });
67
75
  }
68
76
  if (postData.type === 'article') {
69
77
  return trimmedContent.length > 0;
70
78
  }
71
- return (
72
- (trimmedContent.length > 0 && trimmedContent.length <= 500) ||
73
- (postData.data.attachments?.length ?? 0) > 0
74
- );
79
+ return canSubmitPostContent({
80
+ visibleContentLength,
81
+ attachmentsLength: postData.data.attachments?.length ?? 0,
82
+ composerType: 'note',
83
+ });
75
84
  }, [
76
85
  attachmentsProcessing,
77
86
  isPosting,
78
87
  pollOptionsValid,
79
88
  postData,
80
89
  trimmedContent.length,
90
+ visibleContentLength,
81
91
  ]);
82
92
 
83
93
  const handlePostUpdate = async () => {
@@ -26,8 +26,10 @@ import {
26
26
  MediaAttachment,
27
27
  pollOptionsWithinLimit,
28
28
  PostCreationData,
29
+ canSubmitPostContent,
29
30
  resolvePollOptionContents,
30
31
  VisibilityType,
32
+ visibleTextLength,
31
33
  } from '@openpeepshq/common';
32
34
  import { CompositeScreenProps } from '@react-navigation/native';
33
35
  import Toast from 'react-native-toast-message';
@@ -89,6 +91,7 @@ export const NewPost = ({ route, navigation }: PostProps) => {
89
91
  canNotify && isCommunityWideVisibility(postData.visibility);
90
92
 
91
93
  const trimmedContent = (postData.data.content ?? '').trim();
94
+ const visibleContentLength = visibleTextLength(trimmedContent);
92
95
  const pollOptions =
93
96
  postData.data.type === 'question'
94
97
  ? postData.data.options.map((option) => option.content)
@@ -111,15 +114,21 @@ export const NewPost = ({ route, navigation }: PostProps) => {
111
114
  return false;
112
115
  }
113
116
  if (postData.data.type === 'question') {
114
- return trimmedContent.length > 0 && pollOptionsValid;
117
+ return canSubmitPostContent({
118
+ visibleContentLength,
119
+ attachmentsLength: postData.data.attachments?.length ?? 0,
120
+ composerType: 'question',
121
+ pollOptionsValid,
122
+ });
115
123
  }
116
124
  if (postData.type === 'article') {
117
125
  return trimmedContent.length > 0;
118
126
  }
119
- return (
120
- (trimmedContent.length > 0 && trimmedContent.length <= 500) ||
121
- (postData.data.attachments?.length ?? 0) > 0
122
- );
127
+ return canSubmitPostContent({
128
+ visibleContentLength,
129
+ attachmentsLength: postData.data.attachments?.length ?? 0,
130
+ composerType: 'note',
131
+ });
123
132
  }, [
124
133
  attachmentsProcessing,
125
134
  isPosting,
@@ -131,6 +140,7 @@ export const NewPost = ({ route, navigation }: PostProps) => {
131
140
  postData.type,
132
141
  postData.visibility,
133
142
  trimmedContent.length,
143
+ visibleContentLength,
134
144
  ]);
135
145
 
136
146
  const handlePostCreation = async () => {
@@ -18,8 +18,10 @@ import {
18
18
  MediaAttachment,
19
19
  pollOptionsWithinLimit,
20
20
  PostCreationData,
21
+ canSubmitPostContent,
21
22
  PublicPost,
22
23
  resolvePollOptionContents,
24
+ visibleTextLength,
23
25
  } from '@openpeepshq/common';
24
26
  import Toast from 'react-native-toast-message';
25
27
  import {
@@ -90,7 +92,6 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
90
92
  setPostData(newPostData as PostCreationData);
91
93
  form.reset(newPostData);
92
94
  }
93
- // eslint-disable-next-line react-hooks/exhaustive-deps
94
95
  }, [post]);
95
96
 
96
97
  useEffect(() => {
@@ -118,6 +119,7 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
118
119
  }, [isPostLoading, post, postData]);
119
120
 
120
121
  const trimmedContent = (postData?.data.content ?? '').trim();
122
+ const visibleContentLength = visibleTextLength(trimmedContent);
121
123
  const pollOptions =
122
124
  postData?.data.type === 'question'
123
125
  ? postData.data.options.map((option) => option.content)
@@ -134,12 +136,18 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
134
136
  return false;
135
137
  }
136
138
  if (postData.data.type === 'question') {
137
- return trimmedContent.length > 0 && pollOptionsValid;
139
+ return canSubmitPostContent({
140
+ visibleContentLength,
141
+ attachmentsLength: postData.data.attachments?.length ?? 0,
142
+ composerType: 'question',
143
+ pollOptionsValid,
144
+ });
138
145
  }
139
- return (
140
- (trimmedContent.length > 0 && trimmedContent.length <= 500) ||
141
- (postData.data.attachments?.length ?? 0) > 0
142
- );
146
+ return canSubmitPostContent({
147
+ visibleContentLength,
148
+ attachmentsLength: postData.data.attachments?.length ?? 0,
149
+ composerType: 'note',
150
+ });
143
151
  }, [
144
152
  attachmentsProcessing,
145
153
  isPosting,
@@ -147,6 +155,7 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
147
155
  post,
148
156
  postData,
149
157
  trimmedContent.length,
158
+ visibleContentLength,
150
159
  ]);
151
160
 
152
161
  const handlePostCreation = async () => {