@openpeepshq/rn-components 0.3.6 → 0.3.8
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.
- package/package.json +1 -1
- package/src/components/custom/common/empty-state-container.tsx +42 -114
- package/src/components/custom/common/index.ts +1 -0
- package/src/components/custom/common/plus-fab.tsx +23 -0
- package/src/components/custom/headers/tab-screens-header.tsx +3 -4
- package/src/components/custom/navigation/side-menu.tsx +40 -78
- package/src/components/icons/index.ts +6 -0
- package/src/components/jams/CreateNewJam.tsx +3 -4
- package/src/components/navigation/auth-wrapper.tsx +1 -1
- package/src/components/notifications/NotificationItem.tsx +1 -1
- package/src/components/notifications/NotificationsList.tsx +5 -1
- package/src/components/post/Feed.tsx +3 -1
- package/src/components/post/FeedPost.tsx +32 -37
- package/src/components/post/FeedPostContent.tsx +6 -8
- package/src/components/post/NewEventButton.tsx +3 -8
- package/src/components/post/NewNoteButton.tsx +3 -5
- package/src/components/post/feed/events/EventsFeed.tsx +1 -0
- package/src/components/post/pieces/PostActions.tsx +46 -121
- package/src/components/post/pieces/PostInfoHeader.tsx +9 -5
- package/src/components/post/post-form/Footer.tsx +47 -64
- package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +3 -0
- package/src/components/post/post-form/PollComposerFields.tsx +2 -2
- package/src/components/post/post-form/PostForm.tsx +133 -129
- package/src/components/post/types/Note.tsx +1 -1
- package/src/components/post/types/Poll.tsx +1 -1
- package/src/components/post/types/article/CardArticle.tsx +1 -1
- package/src/components/post/types/event/CardEvent.tsx +1 -1
- package/src/components/post/types/event/FullEvent.tsx +21 -20
- package/src/components/profile/ProfileCard.tsx +1 -1
- package/src/components/profile/ProfileHeader.tsx +8 -10
- package/src/pages/Explore.tsx +30 -5
- package/src/pages/Members.tsx +2 -2
- package/src/pages/Tags.tsx +8 -2
- package/src/pages/articles/Index.tsx +18 -2
- package/src/pages/conversations/Index.tsx +21 -4
- package/src/pages/conversations/New.tsx +8 -1
- package/src/pages/feeds/Local.tsx +8 -2
- package/src/pages/feeds/My.tsx +13 -3
- package/src/pages/groups/Index.tsx +23 -1
- package/src/pages/groups/Info.tsx +4 -4
- package/src/pages/groups/Show.tsx +42 -3
- package/src/pages/posts/Edit.tsx +43 -5
- package/src/pages/posts/New.tsx +121 -74
- package/src/pages/posts/Reply.tsx +77 -49
- package/src/pages/profile/Followers.tsx +4 -1
- package/src/pages/profile/Following.tsx +4 -1
package/src/pages/posts/New.tsx
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import { checkMediaPermissions } from '../../lib/media-permissions';
|
|
3
9
|
import { NativeStackScreenProps } from '@react-navigation/native-stack';
|
|
4
10
|
import {
|
|
@@ -10,14 +16,15 @@ import {
|
|
|
10
16
|
AudioPickerSheet,
|
|
11
17
|
GenericHeader,
|
|
12
18
|
ImagePickerSheet,
|
|
13
|
-
VideoPickerSheet,
|
|
14
19
|
DocumentPickerSheet,
|
|
15
20
|
type DocumentPickerSheetHandle,
|
|
16
21
|
} from '../../components/custom/index';
|
|
17
22
|
import {
|
|
23
|
+
checkRoleCapabilities,
|
|
18
24
|
MediaAttachment,
|
|
25
|
+
pollOptionsWithinLimit,
|
|
19
26
|
PostCreationData,
|
|
20
|
-
|
|
27
|
+
resolvePollOptionContents,
|
|
21
28
|
VisibilityType,
|
|
22
29
|
} from '@openpeepshq/common';
|
|
23
30
|
import { CompositeScreenProps } from '@react-navigation/native';
|
|
@@ -27,14 +34,10 @@ import { useLocalPostStore } from '../../stores/useLocalPostStore';
|
|
|
27
34
|
import { PostForm } from '../../components/post/post-form/PostForm';
|
|
28
35
|
import { useTranslation } from 'react-i18next';
|
|
29
36
|
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
|
30
|
-
import Footer from '../../components/post/post-form/Footer';
|
|
37
|
+
import { Footer } from '../../components/post/post-form/Footer';
|
|
38
|
+
import { PostTypeSwitcher } from '../../components/post/post-form/PostTypeSwitcher';
|
|
31
39
|
import { BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
32
|
-
import {
|
|
33
|
-
hasProcessingAttachments,
|
|
34
|
-
toArticle,
|
|
35
|
-
toNote,
|
|
36
|
-
toQuestion,
|
|
37
|
-
} from '../../lib/post';
|
|
40
|
+
import { hasProcessingAttachments, toNote, toQuestion } from '../../lib/post';
|
|
38
41
|
import { useForm } from 'react-hook-form';
|
|
39
42
|
|
|
40
43
|
import { ArticleForm } from '../../components/post/index';
|
|
@@ -51,8 +54,11 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
51
54
|
const publicContent = !!server?.publicContent;
|
|
52
55
|
|
|
53
56
|
const createPost = openpeepsApi.createPostAction();
|
|
57
|
+
const announcePost = openpeepsApi.admin.announcePostAction();
|
|
58
|
+
const joinGroup = openpeepsApi.joinGroupAction();
|
|
54
59
|
|
|
55
60
|
const [isPosting, setIsPosting] = useState(false);
|
|
61
|
+
const [notify, setNotify] = useState(false);
|
|
56
62
|
|
|
57
63
|
const postData = useLocalPostStore((state) => state.postData);
|
|
58
64
|
const attachmentsProcessing = hasProcessingAttachments(postData);
|
|
@@ -60,7 +66,6 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
60
66
|
const resetPostData = useLocalPostStore((state) => state.resetPostData);
|
|
61
67
|
|
|
62
68
|
const imagePickerModalRef = useRef<BottomSheetModal>(null);
|
|
63
|
-
const videoPickerModalRef = useRef<BottomSheetModal>(null);
|
|
64
69
|
const audioPickerModalRef = useRef<BottomSheetModal>(null);
|
|
65
70
|
const documentPickerModalRef = useRef<DocumentPickerSheetHandle>(null);
|
|
66
71
|
|
|
@@ -68,24 +73,86 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
68
73
|
defaultValues: postData,
|
|
69
74
|
});
|
|
70
75
|
|
|
71
|
-
const joinGroup = openpeepsApi.addGroupMemberAction();
|
|
72
|
-
|
|
73
76
|
const resetForm = useCallback(async () => {
|
|
74
77
|
form.reset();
|
|
75
78
|
setPostData(postData);
|
|
76
79
|
resetPostData();
|
|
77
80
|
}, [form, setPostData, resetPostData, postData]);
|
|
78
81
|
|
|
82
|
+
const canNotify = useMemo(
|
|
83
|
+
() =>
|
|
84
|
+
checkRoleCapabilities(currentProfile?.roles ?? [], [
|
|
85
|
+
'allpeep-core-admin-notify',
|
|
86
|
+
]).success,
|
|
87
|
+
[currentProfile?.roles]
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const showNotify =
|
|
91
|
+
canNotify &&
|
|
92
|
+
(postData.visibility === 'public' || postData.visibility === 'local');
|
|
93
|
+
|
|
94
|
+
const trimmedContent = (postData.data.content ?? '').trim();
|
|
95
|
+
const pollOptions =
|
|
96
|
+
postData.data.type === 'question'
|
|
97
|
+
? postData.data.options.map((option) => option.content)
|
|
98
|
+
: [];
|
|
99
|
+
const resolvedPollOptions = resolvePollOptionContents(pollOptions, (index) =>
|
|
100
|
+
t('posts.form.poll.option', { number: index + 1 })
|
|
101
|
+
);
|
|
102
|
+
const pollOptionsValid =
|
|
103
|
+
resolvedPollOptions.length >= 2 &&
|
|
104
|
+
pollOptionsWithinLimit(resolvedPollOptions);
|
|
105
|
+
|
|
106
|
+
const canSubmit = useMemo(() => {
|
|
107
|
+
if (isPosting || attachmentsProcessing) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if (postData.visibility === 'direct' && !postData.audience?.length) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (postData.visibility === 'group' && !postData.groupId) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (postData.data.type === 'question') {
|
|
117
|
+
return trimmedContent.length > 0 && pollOptionsValid;
|
|
118
|
+
}
|
|
119
|
+
if (postData.type === 'article') {
|
|
120
|
+
return trimmedContent.length > 0;
|
|
121
|
+
}
|
|
122
|
+
return (
|
|
123
|
+
(trimmedContent.length > 0 && trimmedContent.length <= 500) ||
|
|
124
|
+
(postData.data.attachments?.length ?? 0) > 0
|
|
125
|
+
);
|
|
126
|
+
}, [
|
|
127
|
+
attachmentsProcessing,
|
|
128
|
+
isPosting,
|
|
129
|
+
pollOptionsValid,
|
|
130
|
+
postData.audience?.length,
|
|
131
|
+
postData.data.attachments?.length,
|
|
132
|
+
postData.data.type,
|
|
133
|
+
postData.groupId,
|
|
134
|
+
postData.type,
|
|
135
|
+
postData.visibility,
|
|
136
|
+
trimmedContent.length,
|
|
137
|
+
]);
|
|
138
|
+
|
|
79
139
|
const handlePostCreation = async () => {
|
|
140
|
+
if (!canSubmit) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
80
144
|
try {
|
|
81
145
|
setIsPosting(true);
|
|
82
146
|
|
|
83
147
|
await handleGroupJoinIfNeeded();
|
|
84
|
-
await createPost(postData as PostCreationData);
|
|
148
|
+
const response = await createPost(postData as PostCreationData);
|
|
149
|
+
if (notify && canNotify && response?.id) {
|
|
150
|
+
await announcePost({ id: response.id });
|
|
151
|
+
}
|
|
85
152
|
|
|
86
153
|
await handlePostSuccess();
|
|
87
154
|
} catch {
|
|
88
|
-
Toast.show({ type: 'error', text1: t('posts.create.
|
|
155
|
+
Toast.show({ type: 'error', text1: t('posts.create.errorGeneric') });
|
|
89
156
|
} finally {
|
|
90
157
|
setIsPosting(false);
|
|
91
158
|
}
|
|
@@ -95,21 +162,19 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
95
162
|
if (
|
|
96
163
|
postData.visibility === 'group' &&
|
|
97
164
|
postData.groupId &&
|
|
98
|
-
!currentProfile?.memberships
|
|
99
|
-
|
|
100
|
-
|
|
165
|
+
!currentProfile?.memberships?.some(
|
|
166
|
+
(membership) => membership.group.id === postData.groupId
|
|
167
|
+
)
|
|
101
168
|
) {
|
|
102
|
-
await joinGroup({
|
|
103
|
-
...(currentProfile as PublicProfile),
|
|
104
|
-
});
|
|
169
|
+
await joinGroup({ id: postData.groupId });
|
|
105
170
|
}
|
|
106
171
|
};
|
|
107
172
|
|
|
108
173
|
const handlePostSuccess = async () => {
|
|
109
|
-
Toast.show({ type: 'success', text1: t('posts.create.
|
|
174
|
+
Toast.show({ type: 'success', text1: t('posts.create.successToast') });
|
|
175
|
+
await resetForm();
|
|
110
176
|
|
|
111
177
|
if (postData.visibility === 'group' && postData.groupId) {
|
|
112
|
-
resetForm();
|
|
113
178
|
if (navigation.canGoBack()) {
|
|
114
179
|
navigation.goBack();
|
|
115
180
|
}
|
|
@@ -135,13 +200,6 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
135
200
|
}
|
|
136
201
|
}, [t]);
|
|
137
202
|
|
|
138
|
-
const handleVideoModalPress = useCallback(async () => {
|
|
139
|
-
const hasPermission = await checkMediaPermissions(t, 'video');
|
|
140
|
-
if (hasPermission) {
|
|
141
|
-
videoPickerModalRef.current?.present();
|
|
142
|
-
}
|
|
143
|
-
}, [t]);
|
|
144
|
-
|
|
145
203
|
const handleAudioModalPress = useCallback(async () => {
|
|
146
204
|
const hasPermission = await checkMediaPermissions(t, 'audio');
|
|
147
205
|
if (hasPermission) {
|
|
@@ -164,31 +222,18 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
164
222
|
[postData, form, setPostData]
|
|
165
223
|
);
|
|
166
224
|
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
postData.data.type ===
|
|
170
|
-
|
|
171
|
-
: toQuestion(postData);
|
|
172
|
-
form.reset(newPostData);
|
|
173
|
-
setPostData(newPostData);
|
|
174
|
-
}, [postData, form, setPostData]);
|
|
175
|
-
|
|
176
|
-
const handleSwithToArticlePress = useCallback(() => {
|
|
177
|
-
const newPostData =
|
|
178
|
-
postData.type === 'article' ? toNote(postData) : toArticle(postData);
|
|
179
|
-
form.reset(newPostData);
|
|
180
|
-
setPostData(newPostData);
|
|
181
|
-
}, [postData, form, setPostData]);
|
|
182
|
-
|
|
183
|
-
useEffect(() => {
|
|
184
|
-
const unsubscribe = navigation.addListener('focus', () => {
|
|
185
|
-
if (!route.params?.originatorId && !route.params?.withContent) {
|
|
186
|
-
resetForm();
|
|
225
|
+
const handleSelectComposerType = useCallback(
|
|
226
|
+
(next: 'note' | 'question') => {
|
|
227
|
+
if (postData.data.type === next) {
|
|
228
|
+
return;
|
|
187
229
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
230
|
+
const newPostData =
|
|
231
|
+
next === 'question' ? toQuestion(postData) : toNote(postData);
|
|
232
|
+
form.reset(newPostData);
|
|
233
|
+
setPostData(newPostData);
|
|
234
|
+
},
|
|
235
|
+
[postData, form, setPostData]
|
|
236
|
+
);
|
|
192
237
|
|
|
193
238
|
useEffect(() => {
|
|
194
239
|
if (!publicContent && postData.visibility === 'public') {
|
|
@@ -211,15 +256,14 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
211
256
|
setPostData(newPostData);
|
|
212
257
|
}, [route, form, setPostData]);
|
|
213
258
|
|
|
259
|
+
const isArticle = postData.type === 'article';
|
|
260
|
+
const composerType = postData.data.type === 'question' ? 'question' : 'note';
|
|
261
|
+
|
|
214
262
|
return (
|
|
215
263
|
<ThemedSafeAreaView className="flex-1 bg-background">
|
|
216
264
|
<GenericHeader
|
|
217
265
|
title={
|
|
218
|
-
|
|
219
|
-
? t('articles.create.title')
|
|
220
|
-
: postData.data.type === 'question'
|
|
221
|
-
? t('posts.create.title')
|
|
222
|
-
: t('posts.create.title')
|
|
266
|
+
isArticle ? t('articles.create.title') : t('posts.newPost.title')
|
|
223
267
|
}
|
|
224
268
|
rightType="button"
|
|
225
269
|
rightButtonTitle={
|
|
@@ -239,40 +283,43 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
239
283
|
navigation.goBack();
|
|
240
284
|
}
|
|
241
285
|
}}
|
|
242
|
-
rightButtonDisabled={
|
|
286
|
+
rightButtonDisabled={!canSubmit}
|
|
243
287
|
onRightButtonPress={handlePostCreation}
|
|
244
288
|
/>
|
|
245
289
|
<KeyboardAwareScrollView className="flex-1">
|
|
246
|
-
{
|
|
290
|
+
{isArticle ? (
|
|
247
291
|
<ArticleForm postData={postData} onChange={setPostData} />
|
|
248
|
-
)
|
|
249
|
-
{(postData.type === 'question' || postData.type === 'note') && (
|
|
292
|
+
) : (
|
|
250
293
|
<PostForm
|
|
251
294
|
postData={postData}
|
|
252
295
|
setPostData={setPostData}
|
|
253
|
-
canEditVisibility
|
|
296
|
+
canEditVisibility={route.params?.triggeredFrom !== 'group'}
|
|
254
297
|
form={form}
|
|
298
|
+
showNotify={showNotify}
|
|
299
|
+
notify={notify}
|
|
300
|
+
onNotifyChange={setNotify}
|
|
255
301
|
/>
|
|
256
302
|
)}
|
|
257
303
|
</KeyboardAwareScrollView>
|
|
258
304
|
<Footer
|
|
259
|
-
|
|
260
|
-
postType={postData?.data?.type}
|
|
305
|
+
hideMedia={isArticle || composerType === 'question'}
|
|
261
306
|
onImagePress={handleImageModalPress}
|
|
262
|
-
|
|
263
|
-
onVideoPress={handleVideoModalPress}
|
|
264
|
-
onPollPress={handleSwitchPollPress}
|
|
307
|
+
onAudioPress={handleAudioModalPress}
|
|
265
308
|
onDocumentPress={handleDocumentModalPress}
|
|
266
|
-
|
|
309
|
+
typeSwitcher={
|
|
310
|
+
<PostTypeSwitcher
|
|
311
|
+
type={isArticle ? 'article' : composerType}
|
|
312
|
+
onSelect={handleSelectComposerType}
|
|
313
|
+
onClose={() => undefined}
|
|
314
|
+
visibility={postData.visibility}
|
|
315
|
+
groupId={postData.groupId ?? undefined}
|
|
316
|
+
/>
|
|
317
|
+
}
|
|
267
318
|
/>
|
|
268
319
|
<ImagePickerSheet
|
|
269
320
|
ref={imagePickerModalRef}
|
|
270
321
|
onSelect={handleAddAttachments}
|
|
271
322
|
/>
|
|
272
|
-
<VideoPickerSheet
|
|
273
|
-
ref={videoPickerModalRef}
|
|
274
|
-
onSelect={handleAddAttachments}
|
|
275
|
-
/>
|
|
276
323
|
<AudioPickerSheet
|
|
277
324
|
ref={audioPickerModalRef}
|
|
278
325
|
onSelect={handleAddAttachments}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import { useOpenpeeps } from '@openpeepshq/react';
|
|
3
9
|
import {
|
|
4
10
|
AudioPickerSheet,
|
|
@@ -6,12 +12,13 @@ import {
|
|
|
6
12
|
type DocumentPickerSheetHandle,
|
|
7
13
|
GenericHeader,
|
|
8
14
|
ImagePickerSheet,
|
|
9
|
-
VideoPickerSheet,
|
|
10
15
|
} from '../../components/custom/index';
|
|
11
16
|
import {
|
|
12
17
|
MediaAttachment,
|
|
18
|
+
pollOptionsWithinLimit,
|
|
13
19
|
PostCreationData,
|
|
14
20
|
PublicPost,
|
|
21
|
+
resolvePollOptionContents,
|
|
15
22
|
} from '@openpeepshq/common';
|
|
16
23
|
import Toast from 'react-native-toast-message';
|
|
17
24
|
import { ThemedSafeAreaView } from '../../components/ui/themed-safe-area-view';
|
|
@@ -28,14 +35,10 @@ import { MainScreenProps } from '../../components/navigation/types/index';
|
|
|
28
35
|
import { BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
29
36
|
import { useTranslation } from 'react-i18next';
|
|
30
37
|
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
|
31
|
-
import Footer from '../../components/post/post-form/Footer';
|
|
38
|
+
import { Footer } from '../../components/post/post-form/Footer';
|
|
39
|
+
import { PostTypeSwitcher } from '../../components/post/post-form/PostTypeSwitcher';
|
|
32
40
|
import { useForm } from 'react-hook-form';
|
|
33
|
-
import {
|
|
34
|
-
hasProcessingAttachments,
|
|
35
|
-
toArticle,
|
|
36
|
-
toNote,
|
|
37
|
-
toQuestion,
|
|
38
|
-
} from '../../lib/post';
|
|
41
|
+
import { hasProcessingAttachments, toNote, toQuestion } from '../../lib/post';
|
|
39
42
|
import { CompactReplyParent } from '../../components/post/CompactReplyParent';
|
|
40
43
|
|
|
41
44
|
import { ReplyModal } from '../../components/post/index';
|
|
@@ -114,9 +117,40 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
114
117
|
scrollRef.current?.scrollToEnd(false);
|
|
115
118
|
}, [isPostLoading, post, postData]);
|
|
116
119
|
|
|
120
|
+
const trimmedContent = (postData?.data.content ?? '').trim();
|
|
121
|
+
const pollOptions =
|
|
122
|
+
postData?.data.type === 'question'
|
|
123
|
+
? postData.data.options.map((option) => option.content)
|
|
124
|
+
: [];
|
|
125
|
+
const resolvedPollOptions = resolvePollOptionContents(pollOptions, (index) =>
|
|
126
|
+
t('posts.form.poll.option', { number: index + 1 })
|
|
127
|
+
);
|
|
128
|
+
const pollOptionsValid =
|
|
129
|
+
resolvedPollOptions.length >= 2 &&
|
|
130
|
+
pollOptionsWithinLimit(resolvedPollOptions);
|
|
131
|
+
|
|
132
|
+
const canSubmit = useMemo(() => {
|
|
133
|
+
if (!post || !postData || isPosting || attachmentsProcessing) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (postData.data.type === 'question') {
|
|
137
|
+
return trimmedContent.length > 0 && pollOptionsValid;
|
|
138
|
+
}
|
|
139
|
+
return (
|
|
140
|
+
(trimmedContent.length > 0 && trimmedContent.length <= 500) ||
|
|
141
|
+
(postData.data.attachments?.length ?? 0) > 0
|
|
142
|
+
);
|
|
143
|
+
}, [
|
|
144
|
+
attachmentsProcessing,
|
|
145
|
+
isPosting,
|
|
146
|
+
pollOptionsValid,
|
|
147
|
+
post,
|
|
148
|
+
postData,
|
|
149
|
+
trimmedContent.length,
|
|
150
|
+
]);
|
|
151
|
+
|
|
117
152
|
const handlePostCreation = async () => {
|
|
118
|
-
if (!post) {
|
|
119
|
-
Toast.show({ type: 'error', text1: t('posts.create.error') });
|
|
153
|
+
if (!post || !canSubmit) {
|
|
120
154
|
return;
|
|
121
155
|
}
|
|
122
156
|
|
|
@@ -132,14 +166,14 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
132
166
|
|
|
133
167
|
handlePostSuccess();
|
|
134
168
|
} catch {
|
|
135
|
-
Toast.show({ type: 'error', text1: t('posts.
|
|
169
|
+
Toast.show({ type: 'error', text1: t('posts.replyModal.errorToast') });
|
|
136
170
|
} finally {
|
|
137
171
|
setIsPosting(false);
|
|
138
172
|
}
|
|
139
173
|
};
|
|
140
174
|
|
|
141
175
|
const handlePostSuccess = async () => {
|
|
142
|
-
Toast.show({ type: 'success', text1: t('posts.
|
|
176
|
+
Toast.show({ type: 'success', text1: t('posts.replyModal.successToast') });
|
|
143
177
|
resetReplyData(id);
|
|
144
178
|
navigation.navigate('TabNavigator', {
|
|
145
179
|
screen: 'Feed',
|
|
@@ -147,7 +181,6 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
147
181
|
};
|
|
148
182
|
|
|
149
183
|
const imagePickerModalRef = useRef<BottomSheetModal>(null);
|
|
150
|
-
const videoPickerModalRef = useRef<BottomSheetModal>(null);
|
|
151
184
|
const audioPickerModalRef = useRef<BottomSheetModal>(null);
|
|
152
185
|
const documentPickerModalRef = useRef<DocumentPickerSheetHandle>(null);
|
|
153
186
|
|
|
@@ -158,13 +191,6 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
158
191
|
}
|
|
159
192
|
}, [t]);
|
|
160
193
|
|
|
161
|
-
const handleVideoModalPress = useCallback(async () => {
|
|
162
|
-
const hasPermission = await checkMediaPermissions(t, 'video');
|
|
163
|
-
if (hasPermission) {
|
|
164
|
-
videoPickerModalRef.current?.present();
|
|
165
|
-
}
|
|
166
|
-
}, [t]);
|
|
167
|
-
|
|
168
194
|
const handleAudioModalPress = useCallback(async () => {
|
|
169
195
|
const hasPermission = await checkMediaPermissions(t, 'audio');
|
|
170
196
|
if (hasPermission) {
|
|
@@ -187,21 +213,18 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
187
213
|
[postData, form, setPostData]
|
|
188
214
|
);
|
|
189
215
|
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
postData.data.type ===
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
form.reset(newPostData);
|
|
203
|
-
setPostData(newPostData);
|
|
204
|
-
}, [postData, form, setPostData]);
|
|
216
|
+
const handleSelectComposerType = useCallback(
|
|
217
|
+
(next: 'note' | 'question') => {
|
|
218
|
+
if (!postData || postData.data.type === next) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const newPostData =
|
|
222
|
+
next === 'question' ? toQuestion(postData) : toNote(postData);
|
|
223
|
+
form.reset(newPostData);
|
|
224
|
+
setPostData(newPostData);
|
|
225
|
+
},
|
|
226
|
+
[postData, form, setPostData]
|
|
227
|
+
);
|
|
205
228
|
|
|
206
229
|
const handleDocumentModalPress = useCallback(async () => {
|
|
207
230
|
const hasPermission = await checkMediaPermissions(t, 'file');
|
|
@@ -222,7 +245,7 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
222
245
|
: t('posts.create.submit')
|
|
223
246
|
}
|
|
224
247
|
onRightButtonPress={handlePostCreation}
|
|
225
|
-
rightButtonDisabled={
|
|
248
|
+
rightButtonDisabled={!canSubmit}
|
|
226
249
|
/>
|
|
227
250
|
<KeyboardAwareScrollView
|
|
228
251
|
ref={scrollRef}
|
|
@@ -254,7 +277,7 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
254
277
|
onPress={() => {}}
|
|
255
278
|
className="inline-flex items-center "
|
|
256
279
|
>
|
|
257
|
-
<ThemedText className="text-lg text-
|
|
280
|
+
<ThemedText className="text-lg text-primary">
|
|
258
281
|
{`@${post?.profile.handle}`}
|
|
259
282
|
</ThemedText>
|
|
260
283
|
</TouchableWithoutFeedback>
|
|
@@ -266,7 +289,7 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
266
289
|
onPress={() => {}}
|
|
267
290
|
className="inline-flex items-center "
|
|
268
291
|
>
|
|
269
|
-
<ThemedText className="text-lg text-
|
|
292
|
+
<ThemedText className="text-lg text-primary">
|
|
270
293
|
{post.group.displayName}
|
|
271
294
|
</ThemedText>
|
|
272
295
|
</TouchableWithoutFeedback>
|
|
@@ -289,23 +312,28 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
289
312
|
<ReplyModal ref={replyModalRef} onSelect={() => {}} id={id} />
|
|
290
313
|
</KeyboardAwareScrollView>
|
|
291
314
|
<Footer
|
|
292
|
-
|
|
293
|
-
postType={postData?.data?.type}
|
|
315
|
+
hideMedia={postData?.data.type === 'question'}
|
|
294
316
|
onImagePress={handleImageModalPress}
|
|
295
|
-
|
|
296
|
-
onVideoPress={handleVideoModalPress}
|
|
297
|
-
onPollPress={handleSwitchPollPress}
|
|
317
|
+
onAudioPress={handleAudioModalPress}
|
|
298
318
|
onDocumentPress={handleDocumentModalPress}
|
|
299
|
-
|
|
319
|
+
typeSwitcher={
|
|
320
|
+
postData ? (
|
|
321
|
+
<PostTypeSwitcher
|
|
322
|
+
type={postData.data.type === 'question' ? 'question' : 'note'}
|
|
323
|
+
onSelect={handleSelectComposerType}
|
|
324
|
+
onClose={() => undefined}
|
|
325
|
+
showEventType={false}
|
|
326
|
+
showArticleType={false}
|
|
327
|
+
visibility={postData.visibility}
|
|
328
|
+
groupId={postData.groupId ?? undefined}
|
|
329
|
+
/>
|
|
330
|
+
) : undefined
|
|
331
|
+
}
|
|
300
332
|
/>
|
|
301
333
|
<ImagePickerSheet
|
|
302
334
|
ref={imagePickerModalRef}
|
|
303
335
|
onSelect={handleAddAttachments}
|
|
304
336
|
/>
|
|
305
|
-
<VideoPickerSheet
|
|
306
|
-
ref={videoPickerModalRef}
|
|
307
|
-
onSelect={handleAddAttachments}
|
|
308
|
-
/>
|
|
309
337
|
<AudioPickerSheet
|
|
310
338
|
ref={audioPickerModalRef}
|
|
311
339
|
onSelect={handleAddAttachments}
|
|
@@ -35,7 +35,10 @@ export const Followers: React.FC<ProfileFollowersProps> = ({ route }) => {
|
|
|
35
35
|
return <ProfileCard key={index} profile={follower} />;
|
|
36
36
|
})}
|
|
37
37
|
{profileFollowers?.length === 0 && (
|
|
38
|
-
<EmptyStateContainer
|
|
38
|
+
<EmptyStateContainer
|
|
39
|
+
type="followers"
|
|
40
|
+
copyKey="profile.followers.noFollowing"
|
|
41
|
+
/>
|
|
39
42
|
)}
|
|
40
43
|
</KeyboardAwareScrollView>
|
|
41
44
|
</ThemedSafeAreaView>
|
|
@@ -34,7 +34,10 @@ export const Following: React.FC<ProfileFollowingProps> = ({ route }) => {
|
|
|
34
34
|
return <ProfileCard key={index} profile={following} />;
|
|
35
35
|
})}
|
|
36
36
|
{profileFollowing?.length === 0 && (
|
|
37
|
-
<EmptyStateContainer
|
|
37
|
+
<EmptyStateContainer
|
|
38
|
+
type="following"
|
|
39
|
+
copyKey="profile.following.noFollowers"
|
|
40
|
+
/>
|
|
38
41
|
)}
|
|
39
42
|
</KeyboardAwareScrollView>
|
|
40
43
|
</ThemedSafeAreaView>
|