@openpeepshq/rn-components 0.4.0 → 0.5.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.
@@ -1,9 +1,7 @@
1
- import { View, Pressable, Share, ActivityIndicator } from 'react-native';
2
1
  import React, { useCallback, useEffect, useRef } from 'react';
2
+ import { View } from 'react-native';
3
3
  import {
4
- EllipsisIcon,
5
4
  PencilIcon,
6
- LinkIcon,
7
5
  Trash2Icon,
8
6
  FlagIcon,
9
7
  UserXIcon,
@@ -11,36 +9,33 @@ import {
11
9
  PinIcon,
12
10
  BookmarkPlusIcon,
13
11
  BookmarkMinusIcon,
12
+ Repeat2Icon,
13
+ ThumbsUpIcon,
14
14
  } from '../../icons/index';
15
- import {
16
- DropdownMenu,
17
- type DropdownMenuRef,
18
- DropdownMenuContent,
19
- DropdownMenuGroup,
20
- DropdownMenuItem,
21
- DropdownMenuTrigger,
22
- } from '../../ui/dropdown-menu';
23
- import { ThemedText } from '../../ui/themed-text';
24
- import Clipboard from '@react-native-clipboard/clipboard';
25
- import Toast from 'react-native-toast-message';
26
- import { BASE_URL } from '../../../lib/constants';
15
+ import { PopupMenu, PopupMenuButton, PopupSeparator } from '../../ui';
16
+ import { useOpenpeeps } from '@openpeepshq/react';
27
17
  import {
28
18
  checkGroupCapabilities,
29
- checkRoleCapabilities,
30
- PublicPost,
19
+ checkPostCapabilities,
31
20
  } from '@openpeepshq/common';
32
- import { truncateText } from '../../../lib/utils';
33
- import { useOpenpeeps } from '@openpeepshq/react';
34
- import { BottomSheetModal } from '@gorhom/bottom-sheet';
35
- import { DeletePostModal } from './modals/DeletePostModal';
21
+ import { checkRoleCapabilities } from '@openpeepshq/common/lib';
22
+ import type { PublicPost } from '@openpeepshq/common/types';
36
23
  import { useEditPostModal } from '../post-form/EditPostModalContext';
37
24
  import { useTranslation } from 'react-i18next';
25
+ import { BottomSheetModal } from '@gorhom/bottom-sheet';
26
+ import { DeletePostModal } from './modals/DeletePostModal';
38
27
  import { ReportProfileOrPostModal } from '../../profile/ReportProfileOrPostModal';
39
- import { UploadIcon } from '../../icons/index';
40
- interface PostMenuProps {
28
+ import { RepostModal } from './modals/RepostModal';
29
+ import { ReactionsModal } from './modals/ReactionsModal';
30
+ import { BASE_URL } from '../../../lib/constants';
31
+ import { truncateText } from '../../../lib/utils';
32
+ import Toast from 'react-native-toast-message';
33
+
34
+ export interface PostMenuProps {
41
35
  post: PublicPost;
42
36
  deleteCallback?: () => void;
43
37
  }
38
+
44
39
  export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
45
40
  const { t } = useTranslation();
46
41
  const { openpeepsApi, queryClient } = useOpenpeeps();
@@ -50,11 +45,13 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
50
45
  const { openEditPost } = useEditPostModal();
51
46
  const reportProfileModalRef = useRef<BottomSheetModal>(null);
52
47
  const reportPostModalRef = useRef<BottomSheetModal>(null);
53
- const dropdownMenuRef = useRef<DropdownMenuRef>(null);
54
- const bookmarkActionInFlight = useRef(false);
48
+
55
49
  const [isBookmarkActionPending, setIsBookmarkActionPending] =
56
50
  React.useState(false);
57
51
  const [isFollowing, setIsFollowing] = React.useState(false);
52
+ const [repostsModalOpen, setRepostsModalOpen] = React.useState(false);
53
+ const [reactionsModalOpen, setReactionsModalOpen] = React.useState(false);
54
+
58
55
  const { data: serverInfo } = openpeepsApi.useServerInfo();
59
56
  const canPinToGroup =
60
57
  post.group &&
@@ -63,38 +60,32 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
63
60
  ['core-groups-pin'],
64
61
  post.group
65
62
  ).success;
66
- const pinnedInGroup: boolean = post.group?.pinnedPostId === post.id;
67
- const pinnedOnProfile: boolean = currentProfile?.pinnedPostId === post.id;
68
- const canPinGlobally: boolean =
69
- (['public', 'local'].includes(post.visibility) &&
70
- currentProfile &&
71
- checkRoleCapabilities(currentProfile?.roles, ['core-config-update'])
72
- .success) ||
73
- false;
74
- const pinnedGlobally: boolean =
63
+ const pinnedInGroup = post.group?.pinnedPostId === post.id;
64
+ const pinnedOnProfile = currentProfile?.pinnedPostId === post.id;
65
+ const canPinGlobally = !!(
66
+ (['public', 'local'] as string[]).includes(post.visibility) &&
67
+ currentProfile &&
68
+ checkRoleCapabilities(currentProfile.roles ?? [], ['core-config-update'])
69
+ .success
70
+ );
71
+ const pinnedGlobally =
75
72
  serverInfo?.communityConfig?.content?.pinnedPost === post.id;
76
73
  const { data: bookmarkedIdsStore, refetch: refetchBookmarkedIds } =
77
74
  openpeepsApi.useCurrentProfileBookmarkedIds();
78
75
 
79
76
  const bookmarkPostId = post.repost?.id ?? post.id;
80
-
81
77
  const isBookmarked = bookmarkedIdsStore?.includes(bookmarkPostId);
82
78
 
83
79
  const bookmarkPost = openpeepsApi.bookmarkPostAction({ id: bookmarkPostId });
84
80
  const unbookmarkPost = openpeepsApi.unbookmarkPostAction({
85
81
  id: bookmarkPostId,
86
82
  });
87
-
88
- const deletePost = openpeepsApi.deletePostAction({
89
- id: post.id,
90
- });
91
-
83
+ const deletePost = openpeepsApi.deletePostAction({ id: post.id });
92
84
  const updateGroup = openpeepsApi.updateGroupAction({
93
- id: post.group?.id as string,
85
+ id: post.group?.id ?? '',
94
86
  });
95
87
  const pinGloballyMutation = openpeepsApi.admin.pinPostGloballyAction();
96
88
  const pinOnProfileMutation = openpeepsApi.pinPostOnProfileAction();
97
-
98
89
  const followProfile = openpeepsApi.followProfileAction({
99
90
  id: post.profile.id,
100
91
  });
@@ -115,7 +106,7 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
115
106
  }, []);
116
107
 
117
108
  const handleDelete = async () => {
118
- void deletePost().then((res: unknown) => {
109
+ void deletePost().then((res) => {
119
110
  if (res) {
120
111
  Toast.show({
121
112
  type: 'success',
@@ -132,350 +123,334 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
132
123
  };
133
124
 
134
125
  const handleFollow = async () => {
135
- const response = await followProfile({
136
- reblogs: true,
137
- notify: true,
138
- });
139
- await refetchCurrentProfile();
140
- Toast.show({
141
- type: response.success ? 'success' : 'error',
142
- text1: response.success
143
- ? t('profile.follow.followedSuccess')
144
- : t('profile.follow.error'),
145
- });
146
- await queryClient.invalidateQueries();
126
+ const response = await followProfile({ reblogs: true, notify: true });
127
+ if (response) {
128
+ setIsFollowing(true);
129
+ Toast.show({
130
+ type: 'success',
131
+ text1: t('profile.actions.followedSuccess'),
132
+ });
133
+ } else {
134
+ Toast.show({ type: 'error', text1: t('profile.follow.error') });
135
+ }
147
136
  };
148
137
 
149
138
  const handleUnfollow = async () => {
150
- const response = await unfollowProfile();
151
- await refetchCurrentProfile();
152
- Toast.show({
153
- type: response.success ? 'success' : 'error',
154
- text1: response.success
155
- ? t('profile.follow.unfollowedSuccess')
156
- : t('profile.follow.error'),
157
- });
158
- await queryClient.invalidateQueries();
139
+ const response = await unfollowProfile(undefined);
140
+ if (response) {
141
+ setIsFollowing(false);
142
+ Toast.show({
143
+ type: 'success',
144
+ text1: t('profile.actions.unfollowedSuccess'),
145
+ });
146
+ } else {
147
+ Toast.show({ type: 'error', text1: t('profile.follow.error') });
148
+ }
159
149
  };
160
150
 
161
- const handlePinInGroup = async () =>
162
- post.group &&
163
- updateGroup({ ...post.group, pinnedPostId: post.id })
164
- .then(() =>
165
- Toast.show({
166
- type: 'success',
167
- text1: t('posts.pinInGroup.success'),
168
- })
169
- )
170
- .catch(() =>
171
- Toast.show({
172
- type: 'error',
173
- text1: t('posts.pinInGroup.error'),
174
- autoHide: false,
175
- })
176
- );
177
-
178
- const handleUnpinInGroup = async () =>
179
- post.group &&
180
- updateGroup({ ...post.group, pinnedPostId: '' })
181
- .then(() =>
182
- Toast.show({
183
- type: 'success',
184
- text1: t('posts.unpinInGroup.success'),
185
- })
186
- )
187
- .catch(() =>
188
- Toast.show({
189
- type: 'error',
190
- text1: t('posts.create.error'),
191
- autoHide: false,
192
- })
193
- );
151
+ const handlePinOnProfile = async () => {
152
+ const response = await pinOnProfileMutation({
153
+ postId: pinnedOnProfile ? '' : post.id,
154
+ });
155
+ if (response) {
156
+ Toast.show({
157
+ type: 'success',
158
+ text1: t(
159
+ pinnedOnProfile
160
+ ? 'posts.unpinOnProfile.success'
161
+ : 'posts.pinOnProfile.success'
162
+ ),
163
+ });
164
+ } else {
165
+ Toast.show({ type: 'error', text1: t('posts.pinOnProfile.error') });
166
+ }
167
+ refetchCurrentProfile();
168
+ };
194
169
 
195
170
  const handlePinGlobally = async () => {
196
171
  const response = await pinGloballyMutation({
197
172
  postId: pinnedGlobally ? '' : post.id,
198
173
  });
199
- if (response.success) {
174
+ if (response) {
200
175
  Toast.show({
201
176
  type: 'success',
202
177
  text1: pinnedGlobally
203
178
  ? t('posts.unpinGlobally.success')
204
179
  : t('posts.pinGlobally.success'),
205
180
  });
181
+ } else {
182
+ Toast.show({ type: 'error', text1: t('posts.pinGlobally.error') });
206
183
  }
207
184
  };
208
185
 
209
- const handlePinOnProfile = async () => {
210
- try {
211
- await pinOnProfileMutation({
212
- postId: pinnedOnProfile ? '' : post.id,
213
- });
214
- await refetchCurrentProfile();
186
+ const handlePinInGroup = async () => {
187
+ const response = await updateGroup({
188
+ ...post.group!,
189
+ pinnedPostId: post.id,
190
+ });
191
+ if (response) {
215
192
  Toast.show({
216
193
  type: 'success',
217
- text1: pinnedOnProfile
218
- ? t('posts.unpinOnProfile.success')
219
- : t('posts.pinOnProfile.success'),
194
+ text1: t('posts.pinInGroup.success'),
220
195
  });
221
- } catch {
196
+ } else {
197
+ Toast.show({ type: 'error', text1: t('posts.pinInGroup.error') });
198
+ }
199
+ };
200
+
201
+ const handleUnpinInGroup = async () => {
202
+ const response = await updateGroup({
203
+ ...post.group!,
204
+ pinnedPostId: '',
205
+ });
206
+ if (response) {
222
207
  Toast.show({
223
- type: 'error',
224
- text1: pinnedOnProfile
225
- ? t('posts.unpinOnProfile.error')
226
- : t('posts.pinOnProfile.error'),
227
- autoHide: false,
208
+ type: 'success',
209
+ text1: t('posts.unpinInGroup.success'),
228
210
  });
211
+ } else {
212
+ Toast.show({ type: 'error', text1: t('posts.unpinInGroup.error') });
229
213
  }
230
214
  };
231
215
 
232
216
  const handleBookmarkMenuPress = useCallback(async () => {
233
- if (bookmarkActionInFlight.current) {
234
- return;
235
- }
236
- bookmarkActionInFlight.current = true;
217
+ if (isBookmarkActionPending) return;
237
218
  setIsBookmarkActionPending(true);
238
219
  try {
239
220
  if (isBookmarked) {
240
- await unbookmarkPost();
241
- Toast.show({
242
- type: 'success',
243
- text1: t('posts.unbookmark.success'),
244
- });
221
+ await unbookmarkPost(undefined);
245
222
  } else {
246
- await bookmarkPost();
247
- Toast.show({
248
- type: 'success',
249
- text1: t('posts.bookmark.success'),
250
- });
223
+ await bookmarkPost(undefined);
251
224
  }
252
225
  await refetchBookmarkedIds();
226
+ Toast.show({
227
+ type: 'success',
228
+ text1: isBookmarked
229
+ ? t('posts.unbookmark.success')
230
+ : t('posts.bookmark.success'),
231
+ });
232
+ } catch {
233
+ Toast.show({
234
+ type: 'error',
235
+ text1: t('posts.bookmark.error'),
236
+ });
253
237
  } finally {
254
- bookmarkActionInFlight.current = false;
255
238
  setIsBookmarkActionPending(false);
256
- dropdownMenuRef.current?.close();
257
239
  }
258
- }, [isBookmarked, bookmarkPost, unbookmarkPost, refetchBookmarkedIds, t]);
240
+ }, [
241
+ isBookmarked,
242
+ bookmarkPost,
243
+ unbookmarkPost,
244
+ refetchBookmarkedIds,
245
+ isBookmarkActionPending,
246
+ t,
247
+ ]);
259
248
 
260
- useEffect(() => {
261
- const isCurrentProfileFollowing = currentProfile?.following
262
- .map((p) => p.id)
263
- .includes(post.profile.id);
249
+ const isCurrentProfileFollowing = currentProfile?.following
250
+ .map((p) => p.id)
251
+ .includes(post.profile.id);
264
252
 
253
+ useEffect(() => {
265
254
  setIsFollowing(isCurrentProfileFollowing || false);
266
255
  refetchBookmarkedIds();
267
256
  }, [currentProfile, post, refetchBookmarkedIds]);
268
257
 
269
258
  return (
270
259
  <View key={post.id}>
271
- <DropdownMenu ref={dropdownMenuRef}>
272
- <DropdownMenuTrigger asChild>
273
- <Pressable className="mr-2 p-2">
274
- <EllipsisIcon className="text-foreground" />
275
- </Pressable>
276
- </DropdownMenuTrigger>
277
- <DropdownMenuContent className="mt-1 ">
278
- <DropdownMenuGroup className="mr-4">
279
- <DropdownMenuItem
280
- onPress={() => {
281
- try {
282
- Clipboard.setString(`${BASE_URL}/post/${post.id}`);
283
- Toast.show({
284
- type: 'success',
285
- text1: t('posts.copyPostLink.success'),
286
- text2: t('posts.copyPostLink.successMessage'),
287
- });
288
- } catch {
289
- Toast.show({
290
- type: 'error',
291
- text1: t('posts.copyPostLink.error'),
292
- text2: t('posts.copyPostLink.errorMessage'),
293
- });
294
- }
295
- }}
296
- className=" flex-row gap-x-2 items-center"
297
- >
298
- <LinkIcon size={16} className="text-foreground" />
299
- <ThemedText>{t('posts.copyPostLink.submit')}</ThemedText>
300
- </DropdownMenuItem>
260
+ <PopupMenu
261
+ title={t('posts.menu.title', { defaultValue: 'Post menu' })}
262
+ className="h-max rounded-lg p-2"
263
+ >
264
+ {currentProfile?.id !== post.profile.id ? (
265
+ isFollowing ? (
266
+ <PopupMenuButton
267
+ title={t('profile.actions.unfollow', {
268
+ defaultValue: 'Unfollow',
269
+ })}
270
+ text={t('profile.actions.unfollow', { defaultValue: 'Unfollow' })}
271
+ icon={UserXIcon}
272
+ action={handleUnfollow}
273
+ />
274
+ ) : (
275
+ <PopupMenuButton
276
+ title={t('profile.actions.follow', { defaultValue: 'Follow' })}
277
+ text={t('profile.actions.follow', { defaultValue: 'Follow' })}
278
+ icon={UsersPlusIcon}
279
+ action={handleFollow}
280
+ />
281
+ )
282
+ ) : null}
283
+
284
+ <PopupMenuButton
285
+ title={t('posts.menu.reposts', { defaultValue: 'Reposts' })}
286
+ text={t('posts.menu.reposts', { defaultValue: 'Reposts' })}
287
+ icon={Repeat2Icon}
288
+ action={() => setRepostsModalOpen(true)}
289
+ />
290
+ <PopupMenuButton
291
+ title={t('posts.menu.reactions', { defaultValue: 'Reactions' })}
292
+ text={t('posts.menu.reactions', { defaultValue: 'Reactions' })}
293
+ icon={ThumbsUpIcon}
294
+ action={() => setReactionsModalOpen(true)}
295
+ />
296
+
297
+ {isBookmarked ? (
298
+ <PopupMenuButton
299
+ title={t('posts.unbookmark.title', {
300
+ defaultValue: 'Remove bookmark',
301
+ })}
302
+ text={t('posts.unbookmark.title', {
303
+ defaultValue: 'Remove bookmark',
304
+ })}
305
+ icon={BookmarkMinusIcon}
306
+ action={handleBookmarkMenuPress}
307
+ closeOnPress={false}
308
+ disabled={isBookmarkActionPending}
309
+ />
310
+ ) : (
311
+ <PopupMenuButton
312
+ title={t('posts.bookmark.title', { defaultValue: 'Bookmark' })}
313
+ text={t('posts.bookmark.title', { defaultValue: 'Bookmark' })}
314
+ icon={BookmarkPlusIcon}
315
+ action={handleBookmarkMenuPress}
316
+ closeOnPress={false}
317
+ disabled={isBookmarkActionPending}
318
+ />
319
+ )}
320
+
321
+ {currentProfile?.id === post.profile.id && !post.repost ? (
322
+ <>
323
+ <PopupSeparator />
324
+ <PopupMenuButton
325
+ title={
326
+ pinnedOnProfile
327
+ ? t('posts.unpinOnProfile.title', {
328
+ defaultValue: 'Unpin from profile',
329
+ })
330
+ : t('posts.pinOnProfile.title', {
331
+ defaultValue: 'Pin to profile',
332
+ })
333
+ }
334
+ text={
335
+ pinnedOnProfile
336
+ ? t('posts.unpinOnProfile.title', {
337
+ defaultValue: 'Unpin from profile',
338
+ })
339
+ : t('posts.pinOnProfile.title', {
340
+ defaultValue: 'Pin to profile',
341
+ })
342
+ }
343
+ icon={PinIcon}
344
+ action={handlePinOnProfile}
345
+ />
346
+ <PopupMenuButton
347
+ title={t('common.actions.edit', { defaultValue: 'Edit' })}
348
+ text={t('common.actions.edit', { defaultValue: 'Edit' })}
349
+ icon={PencilIcon}
350
+ action={() => openEditPost(post)}
351
+ />
352
+ </>
353
+ ) : null}
301
354
 
302
- <DropdownMenuItem
303
- onPress={() => {
304
- Share.share({
305
- message: t('posts.actions.shareMessage'),
306
- url: `${BASE_URL}/post/${post.id}`,
307
- });
308
- }}
309
- className=" flex-row gap-x-2 items-center"
310
- >
311
- <UploadIcon size={16} className="text-foreground" />
312
- <ThemedText>{t('posts.actions.shareMessage')}</ThemedText>
313
- </DropdownMenuItem>
355
+ {canPinGlobally ? (
356
+ <PopupMenuButton
357
+ title={
358
+ pinnedGlobally
359
+ ? t('posts.unpinGlobally.title', {
360
+ defaultValue: 'Unpin globally',
361
+ })
362
+ : t('posts.pinGlobally.title', { defaultValue: 'Pin globally' })
363
+ }
364
+ text={
365
+ pinnedGlobally
366
+ ? t('posts.unpinGlobally.title', {
367
+ defaultValue: 'Unpin globally',
368
+ })
369
+ : t('posts.pinGlobally.title', { defaultValue: 'Pin globally' })
370
+ }
371
+ icon={PinIcon}
372
+ action={handlePinGlobally}
373
+ />
374
+ ) : null}
314
375
 
315
- {currentProfile?.id === post.profile.id && !post.repost && (
316
- <>
317
- <DropdownMenuItem
318
- onPress={handlePinOnProfile}
319
- className=" flex-row gap-x-2 items-center"
320
- >
321
- <PinIcon size={16} className="text-foreground" />
322
- <ThemedText>
323
- {pinnedOnProfile
324
- ? t('posts.unpinOnProfile.title')
325
- : t('posts.pinOnProfile.title')}
326
- </ThemedText>
327
- </DropdownMenuItem>
328
- <DropdownMenuItem
329
- onPress={() => openEditPost(post)}
330
- className=" flex-row gap-x-2 items-center"
331
- >
332
- <PencilIcon size={16} className="text-foreground" />
333
- <ThemedText>{t('common.actions.edit')}</ThemedText>
334
- </DropdownMenuItem>
335
- </>
336
- )}
337
- {/* <DropdownMenuItem className=" flex-row gap-x-2 items-center">
338
- <ClockIcon size={16} className="text-foreground" />
339
- <ThemedText>Edit History</ThemedText>
340
- </DropdownMenuItem> */}
341
- {currentProfile?.id !== post.profile.id && (
342
- <>
343
- {isFollowing ? (
344
- <DropdownMenuItem
345
- onPress={handleUnfollow}
346
- className=" flex-row gap-x-2 items-center"
347
- >
348
- <UserXIcon size={16} className="text-foreground" />
349
- <ThemedText>
350
- {t('profile.actions.unfollow', {
351
- name: truncateText(
352
- post?.profile?.displayName ||
353
- `@${post?.profile?.handle}`,
354
- 5
355
- ),
356
- })}
357
- </ThemedText>
358
- </DropdownMenuItem>
359
- ) : (
360
- <DropdownMenuItem
361
- onPress={handleFollow}
362
- className=" flex-row gap-x-2 items-center"
363
- >
364
- <UsersPlusIcon size={16} className="text-foreground" />
365
- <ThemedText>
366
- {t('profile.actions.follow', {
367
- name: truncateText(
368
- post?.profile?.displayName ||
369
- `@${post?.profile?.handle}`,
370
- 5
371
- ),
372
- })}
373
- </ThemedText>
374
- </DropdownMenuItem>
375
- )}
376
- </>
377
- )}
378
- {currentProfile?.id === post.profile.id && (
379
- <DropdownMenuItem
380
- onPress={handleDeletePostModalPress}
381
- className=" flex-row gap-x-2 items-center text-destructive"
382
- >
383
- <Trash2Icon size={16} className="text-destructive" />
384
- <ThemedText className="text-destructive">
385
- {t('common.actions.delete')}
386
- </ThemedText>
387
- </DropdownMenuItem>
388
- )}
389
- {currentProfile?.id !== post.profile.id && (
390
- <>
391
- <DropdownMenuItem
392
- onPress={handleReportPostModalPress}
393
- className=" flex-row gap-x-2 items-center text-destructive"
394
- >
395
- <FlagIcon size={16} className="text-destructive" />
396
- <ThemedText className="text-destructive">
397
- {t('common.actions.reportPost')}
398
- </ThemedText>
399
- </DropdownMenuItem>
400
- <DropdownMenuItem
401
- onPress={handleReportProfileModalPress}
402
- className=" flex-row gap-x-2 items-center text-destructive"
403
- >
404
- <FlagIcon size={16} className="text-destructive" />
405
- <ThemedText className="text-destructive">
406
- {t('common.actions.reportProfile', {
407
- handle: post.profile.handle,
408
- })}
409
- </ThemedText>
410
- </DropdownMenuItem>
411
- </>
412
- )}
413
- {canPinGlobally && (
414
- <DropdownMenuItem
415
- onPress={handlePinGlobally}
416
- className=" flex-row gap-x-2 items-center text-destructive"
417
- >
418
- <PinIcon size={16} className="text-destructive" />
419
- <ThemedText className="text-destructive">
420
- {pinnedGlobally
421
- ? t('posts.unpinGlobally.title')
422
- : t('posts.pinGlobally.title')}
423
- </ThemedText>
424
- </DropdownMenuItem>
425
- )}
426
- {canPinToGroup && (
427
- <>
428
- {pinnedInGroup ? (
429
- <DropdownMenuItem
430
- onPress={handleUnpinInGroup}
431
- className=" flex-row gap-x-2 items-center"
432
- >
433
- <PinIcon size={16} className="text-foreground" />
434
- <ThemedText>{t('posts.unpinInGroup.title')}</ThemedText>
435
- </DropdownMenuItem>
436
- ) : (
437
- <DropdownMenuItem
438
- onPress={handlePinInGroup}
439
- className=" flex-row gap-x-2 items-center"
440
- >
441
- <PinIcon size={16} className="text-foreground" />
442
- <ThemedText>{t('posts.pinInGroup.title')}</ThemedText>
443
- </DropdownMenuItem>
444
- )}
445
- </>
446
- )}
447
- {isBookmarked ? (
448
- <DropdownMenuItem
449
- closeOnPress={false}
450
- disabled={isBookmarkActionPending}
451
- onPress={handleBookmarkMenuPress}
452
- className=" flex-row gap-x-2 items-center"
453
- >
454
- {isBookmarkActionPending ? (
455
- <ActivityIndicator size="small" />
456
- ) : (
457
- <BookmarkMinusIcon size={16} className="text-foreground" />
458
- )}
459
- <ThemedText>{t('posts.unbookmark.title')}</ThemedText>
460
- </DropdownMenuItem>
461
- ) : (
462
- <DropdownMenuItem
463
- closeOnPress={false}
464
- disabled={isBookmarkActionPending}
465
- onPress={handleBookmarkMenuPress}
466
- className=" flex-row gap-x-2 items-center"
467
- >
468
- {isBookmarkActionPending ? (
469
- <ActivityIndicator size="small" />
470
- ) : (
471
- <BookmarkPlusIcon size={16} className="text-foreground" />
472
- )}
473
- <ThemedText>{t('posts.bookmark.title')}</ThemedText>
474
- </DropdownMenuItem>
475
- )}
476
- </DropdownMenuGroup>
477
- </DropdownMenuContent>
478
- </DropdownMenu>
376
+ {canPinToGroup && post.group ? (
377
+ pinnedInGroup ? (
378
+ <PopupMenuButton
379
+ title={t('posts.unpinInGroup.title', {
380
+ defaultValue: 'Unpin in group',
381
+ })}
382
+ text={t('posts.unpinInGroup.title', {
383
+ defaultValue: 'Unpin in group',
384
+ })}
385
+ icon={PinIcon}
386
+ action={handleUnpinInGroup}
387
+ />
388
+ ) : (
389
+ <PopupMenuButton
390
+ title={t('posts.pinInGroup.title', {
391
+ defaultValue: 'Pin in group',
392
+ })}
393
+ text={t('posts.pinInGroup.title', {
394
+ defaultValue: 'Pin in group',
395
+ })}
396
+ icon={PinIcon}
397
+ action={handlePinInGroup}
398
+ />
399
+ )
400
+ ) : null}
401
+
402
+ {currentProfile?.id === post.profile.id ? (
403
+ <PopupMenuButton
404
+ title={t('common.actions.delete', { defaultValue: 'Delete' })}
405
+ text={t('common.actions.delete', { defaultValue: 'Delete' })}
406
+ icon={Trash2Icon}
407
+ danger
408
+ action={handleDeletePostModalPress}
409
+ />
410
+ ) : null}
411
+
412
+ {currentProfile?.id !== post.profile.id ? (
413
+ <>
414
+ <PopupSeparator />
415
+ <PopupMenuButton
416
+ title={t('common.actions.reportPost', {
417
+ defaultValue: 'Report post',
418
+ })}
419
+ text={t('common.actions.reportPost', {
420
+ defaultValue: 'Report post',
421
+ })}
422
+ icon={FlagIcon}
423
+ danger
424
+ action={handleReportPostModalPress}
425
+ />
426
+ <PopupMenuButton
427
+ title={t('common.actions.reportProfile', {
428
+ defaultValue: 'Report @{{handle}}',
429
+ handle: post.profile.handle,
430
+ })}
431
+ text={t('common.actions.reportProfile', {
432
+ defaultValue: 'Report @{{handle}}',
433
+ handle: post.profile.handle,
434
+ })}
435
+ icon={FlagIcon}
436
+ danger
437
+ action={handleReportProfileModalPress}
438
+ />
439
+ </>
440
+ ) : null}
441
+ </PopupMenu>
442
+
443
+ <RepostModal
444
+ reposts={post.reposts ?? []}
445
+ repostCount={post.repostCount ?? 0}
446
+ open={repostsModalOpen}
447
+ onClose={() => setRepostsModalOpen(false)}
448
+ />
449
+ <ReactionsModal
450
+ reactions={post.reactions ?? []}
451
+ open={reactionsModalOpen}
452
+ onClose={() => setReactionsModalOpen(false)}
453
+ />
479
454
  <DeletePostModal
480
455
  ref={deleteMessageModalRef}
481
456
  onDelete={handleDelete}