@openpeepshq/rn-components 0.13.0 → 0.13.1

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.
@@ -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 () => {