@openpeepshq/rn-components 0.7.1 → 0.8.0

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 (70) hide show
  1. package/README.md +1 -1
  2. package/package.json +12 -7
  3. package/src/components/custom/navigation/side-menu.tsx +59 -11
  4. package/src/components/icons/iconWithClassName.tsx +21 -0
  5. package/src/components/jams/JamActionsFooter.tsx +8 -2
  6. package/src/components/jams/JamCapacityGate.tsx +1 -1
  7. package/src/components/jams/JamCard.tsx +8 -4
  8. package/src/components/jams/JamConference.tsx +6 -1
  9. package/src/components/jams/JamParticipantConference.tsx +2 -0
  10. package/src/components/jams/JamRoom.tsx +2 -3
  11. package/src/components/jams/LiveJamsSection.tsx +12 -1
  12. package/src/components/jams/LivekitUnavailableNotice.tsx +25 -0
  13. package/src/components/jams/index.ts +1 -0
  14. package/src/components/markdown/MarkdownOverlay.tsx +75 -0
  15. package/src/components/markdown/OpenpeepsMarkdown.tsx +3 -1
  16. package/src/components/markdown/extensions/link.tsx +34 -0
  17. package/src/components/markdown/index.ts +2 -0
  18. package/src/components/navigation/tab-navigator.tsx +39 -17
  19. package/src/components/notifications/NotificationItem.tsx +27 -2
  20. package/src/components/notifications/types/JamStarted.tsx +13 -3
  21. package/src/components/notifications/types/Reply.tsx +1 -5
  22. package/src/components/notifications/types/WaitlistOffer.tsx +61 -0
  23. package/src/components/notifications/types/index.ts +1 -0
  24. package/src/components/post/CompactReplyParent.tsx +16 -15
  25. package/src/components/post/TruncatedMarkdown.tsx +60 -0
  26. package/src/components/post/helpers.ts +2 -2
  27. package/src/components/post/index.ts +2 -0
  28. package/src/components/post/pieces/EventRsvpButton.tsx +99 -5
  29. package/src/components/post/pieces/EventRsvpList.tsx +46 -0
  30. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +30 -19
  31. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +62 -0
  32. package/src/components/post/pieces/PollContent.tsx +7 -7
  33. package/src/components/post/pieces/PostActions.tsx +89 -23
  34. package/src/components/post/pieces/ShareMenu.tsx +2 -2
  35. package/src/components/post/post-form/DescriptionEditModal.tsx +1 -0
  36. package/src/components/post/post-form/EventForm.tsx +50 -10
  37. package/src/components/post/post-form/ResourceForm.tsx +115 -5
  38. package/src/components/post/types/Article.tsx +6 -2
  39. package/src/components/post/types/Poll.tsx +4 -1
  40. package/src/components/post/types/event/CardEvent.tsx +101 -76
  41. package/src/components/post/types/event/FullEvent.tsx +60 -23
  42. package/src/components/post/types/event/ProfileEventRelationship.tsx +2 -0
  43. package/src/components/post/types/resource/FullResource.tsx +9 -1
  44. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  45. package/src/components/preview-link/helpers.ts +5 -1
  46. package/src/components/preview-link/index.ts +1 -0
  47. package/src/components/preview-link/local/WelcomePreview.tsx +59 -0
  48. package/src/components/profile/Avatar.tsx +0 -1
  49. package/src/components/profile/EditProfileForm.tsx +23 -2
  50. package/src/components/profile/ProfileSheet.tsx +1 -1
  51. package/src/components/resources/ResourceCard.tsx +75 -22
  52. package/src/components/resources/ResourceLibrary.tsx +18 -2
  53. package/src/components/ui/badge.tsx +2 -3
  54. package/src/components/ui/bottom-sheet.tsx +0 -6
  55. package/src/components/ui/popup-menu-button.tsx +2 -2
  56. package/src/components/ui/popup-menu-separator.tsx +1 -1
  57. package/src/components/ui/popup-menu.tsx +2 -2
  58. package/src/lib/utils.ts +10 -3
  59. package/src/pages/auth/Register.tsx +34 -4
  60. package/src/pages/conversations/Show.tsx +38 -7
  61. package/src/pages/feeds/Bookmarks.tsx +1 -1
  62. package/src/pages/jams/Index.tsx +6 -4
  63. package/src/pages/posts/New.tsx +1 -1
  64. package/src/pages/resources/Edit.tsx +2 -1
  65. package/src/pages/resources/New.tsx +6 -1
  66. package/src/pages/settings/Account.tsx +46 -2
  67. package/src/pages/settings/Index.tsx +3 -4
  68. package/src/pages/settings/NotificationPreferences.tsx +3 -3
  69. package/src/pages/settings/Theme.tsx +1 -1
  70. package/src/components/icons/iconWithClassName.ts +0 -12
@@ -1,4 +1,10 @@
1
- import { View, Image, TouchableOpacity, ActivityIndicator } from 'react-native';
1
+ import {
2
+ View,
3
+ Image,
4
+ Pressable,
5
+ TouchableOpacity,
6
+ ActivityIndicator,
7
+ } from 'react-native';
2
8
  import React from 'react';
3
9
  import { ThemedText } from '../../../ui/themed-text';
4
10
  import { Event, PublicPost } from '@openpeepshq/common';
@@ -15,6 +21,8 @@ import { MainStackParamList } from '../../../navigation/types/index';
15
21
  import { Button } from '../../../ui/button';
16
22
  import { Timespan } from '../../../custom/date/index';
17
23
  import { EventLocation } from '../../pieces/EventLocation';
24
+ import { ShareMenu } from '../../pieces/ShareMenu';
25
+ import { ShareIcon } from '../../../icons/index';
18
26
  import { ProfileEventRelationship } from './ProfileEventRelationship';
19
27
 
20
28
  import { useTranslation } from 'react-i18next';
@@ -43,67 +51,82 @@ export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
43
51
  const attendeesLength = jamState?.participants.length ?? 0;
44
52
 
45
53
  return (
46
- <TouchableOpacity
47
- onPress={() => {
48
- navigation.navigate('Post', {
49
- id: post.id,
50
- occurrence: occurrenceId,
51
- });
52
- }}
53
- className="mb-6 w-full rounded-lg border border-border"
54
- >
55
- <View className="w-full aspect-video overflow-hidden rounded-t-md">
56
- <Image
57
- source={
58
- event.image
59
- ? { uri: event.image }
60
- : require('../../../../assets/images/event-placeholder.png')
61
- }
62
- className="w-full h-full"
63
- resizeMode="cover"
64
- />
65
- </View>
66
- <View className="grid gap-y-5 p-4">
67
- {showEventDate ? (
68
- <View className="flex-row items-center gap-x-1">
69
- <Timespan
70
- start={post.occurrenceStart ?? event.start}
71
- end={post.occurrenceEnd ?? event.end}
72
- timeZone={event.timeZone}
73
- />
74
- </View>
75
- ) : null}
76
- {event.recurrence ? (
77
- <ThemedText className="text-muted-foreground text-sm">
78
- {formatEventRecurrence(event.recurrence, t, event.start)}
79
- </ThemedText>
80
- ) : null}
81
- <ThemedText className="text-xl font-semibold">
82
- {truncateText(event?.name, 100) || '-'}
83
- </ThemedText>
84
- <View className="flex flex-row gap-x-2">
85
- <EventLocation post={post} truncate={true} />
86
- <ProfileEventRelationship post={post} />
54
+ <View className="mb-6 w-full rounded-lg border border-border">
55
+ <TouchableOpacity
56
+ onPress={() => {
57
+ navigation.navigate('Post', {
58
+ id: post.id,
59
+ occurrence: occurrenceId,
60
+ });
61
+ }}
62
+ >
63
+ <View className="w-full aspect-video overflow-hidden rounded-t-md">
64
+ <Image
65
+ source={
66
+ event.image
67
+ ? { uri: event.image }
68
+ : require('../../../../assets/images/event-placeholder.png')
69
+ }
70
+ className="w-full h-full"
71
+ resizeMode="cover"
72
+ />
87
73
  </View>
88
- {jam && me && livekitEnabled ? (
89
- isLoading ? (
90
- <ActivityIndicator size="small" />
91
- ) : jamState?.active ? (
92
- <View className="flex flex-row items-center gap-x-2 text-xs text-muted-foreground">
93
- <View className="w-12">
94
- <ParticipantsCard jamState={jamState} />
74
+ <View className="grid gap-y-5 p-4">
75
+ {showEventDate ? (
76
+ <View className="flex-row items-center gap-x-1">
77
+ <Timespan
78
+ start={post.occurrenceStart ?? event.start}
79
+ end={post.occurrenceEnd ?? event.end}
80
+ timeZone={event.timeZone}
81
+ />
82
+ </View>
83
+ ) : null}
84
+ {event.recurrence ? (
85
+ <ThemedText className="text-muted-foreground text-sm">
86
+ {formatEventRecurrence(event.recurrence, t, event.start)}
87
+ </ThemedText>
88
+ ) : null}
89
+ <ThemedText className="text-xl font-semibold">
90
+ {truncateText(event?.name, 100) || '-'}
91
+ </ThemedText>
92
+ <View className="flex flex-row gap-x-2">
93
+ <EventLocation post={post} truncate={true} />
94
+ <ProfileEventRelationship post={post} />
95
+ </View>
96
+ {jam && me && livekitEnabled ? (
97
+ isLoading ? (
98
+ <ActivityIndicator size="small" />
99
+ ) : jamState?.active ? (
100
+ <View className="flex flex-row items-center gap-x-2 text-xs text-muted-foreground">
101
+ <View className="w-12">
102
+ <ParticipantsCard jamState={jamState} />
103
+ </View>
104
+ <ThemedText>
105
+ {attendeesLength}{' '}
106
+ {attendeesLength === 1
107
+ ? t('events.jam.attendee', { defaultValue: 'attendee' })
108
+ : t('events.jam.attendees', {
109
+ defaultValue: 'attendees',
110
+ })}
111
+ </ThemedText>
112
+ <Button
113
+ variant="default"
114
+ size="sm"
115
+ onPress={() =>
116
+ navigation.navigate('JamSession', {
117
+ jamId: post.id,
118
+ occurrence: occurrenceId,
119
+ })
120
+ }
121
+ >
122
+ <ThemedText numberOfLines={1}>
123
+ {t('jam.join.submit', { defaultValue: 'Join Jam' })}
124
+ </ThemedText>
125
+ </Button>
95
126
  </View>
96
- <ThemedText>
97
- {attendeesLength}{' '}
98
- {attendeesLength === 1
99
- ? t('events.jam.attendee', { defaultValue: 'attendee' })
100
- : t('events.jam.attendees', {
101
- defaultValue: 'attendees',
102
- })}
103
- </ThemedText>
127
+ ) : canModerateJam(me, post) ? (
104
128
  <Button
105
- variant="default"
106
- size="sm"
129
+ className="mt-2 w-full"
107
130
  onPress={() =>
108
131
  navigation.navigate('JamSession', {
109
132
  jamId: post.id,
@@ -112,27 +135,29 @@ export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
112
135
  }
113
136
  >
114
137
  <ThemedText numberOfLines={1}>
115
- {t('jam.join.submit', { defaultValue: 'Join Jam' })}
138
+ {t('jam.start.submit', { defaultValue: 'Start Jam' })}
116
139
  </ThemedText>
117
140
  </Button>
118
- </View>
119
- ) : canModerateJam(me, post) ? (
120
- <Button
121
- className="mt-2 w-full"
122
- onPress={() =>
123
- navigation.navigate('JamSession', {
124
- jamId: post.id,
125
- occurrence: occurrenceId,
126
- })
127
- }
141
+ ) : null
142
+ ) : null}
143
+ </View>
144
+ </TouchableOpacity>
145
+ <View className="flex-row justify-end px-2 pb-2">
146
+ <ShareMenu
147
+ post={post}
148
+ menuButton={
149
+ <Pressable
150
+ accessibilityLabel={t('posts.footer.share')}
151
+ className="flex-row items-center gap-1 px-2 py-1"
128
152
  >
129
- <ThemedText numberOfLines={1}>
130
- {t('jam.start.submit', { defaultValue: 'Start Jam' })}
153
+ <ShareIcon size={18} className="text-foreground" />
154
+ <ThemedText className="text-sm">
155
+ {t('posts.footer.share')}
131
156
  </ThemedText>
132
- </Button>
133
- ) : null
134
- ) : null}
157
+ </Pressable>
158
+ }
159
+ />
135
160
  </View>
136
- </TouchableOpacity>
161
+ </View>
137
162
  );
138
163
  };
@@ -21,8 +21,8 @@ import {
21
21
  DropdownMenuTrigger,
22
22
  } from '../../../ui/dropdown-menu';
23
23
  import { ThemedText } from '../../../ui/themed-text';
24
- import { Image, TouchableOpacity, View } from 'react-native';
25
-
24
+ import { Image, Pressable, Share, TouchableOpacity, View } from 'react-native';
25
+ import RNFS from 'react-native-fs';
26
26
  import {
27
27
  Event,
28
28
  PublicPost,
@@ -49,22 +49,20 @@ import Toast from 'react-native-toast-message';
49
49
  import { useNewConversationStore } from '../../../../stores/useNewConversationStore';
50
50
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
51
51
  import { useTranslation } from 'react-i18next';
52
- import {
53
- canManageEventRsvps,
54
- countYesRsvps,
55
- isCapacityEvent,
56
- } from '../../../../lib/utils';
52
+ import { canManageEventRsvps } from '../../../../lib/utils';
57
53
  import { bottomSheetPresent } from '../../../../lib/bottom-sheet-ref';
58
54
  import {
55
+ availableSpots,
59
56
  canAccessJamRecordings,
60
57
  canModerateJam,
61
58
  canViewJamAttendees,
62
- defaultRsvpRecurrenceId,
63
59
  effectiveEventTimes,
64
60
  eventTimeZoneOptions,
65
61
  formatEventClockTime,
66
62
  formatEventRecurrence,
67
63
  listRsvpOccurrences,
64
+ parseOccurrenceQuery,
65
+ rsvpExportFilename,
68
66
  } from '@openpeepshq/common/lib';
69
67
  import { ThemedView } from '../../../ui/themed-view';
70
68
  import { EventOccurrenceList } from '../../pieces/EventOccurrenceList';
@@ -90,7 +88,7 @@ export interface FullEventProps {
90
88
 
91
89
  export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
92
90
  const { t } = useTranslation();
93
- const { currentProfile, openpeepsApi } = useOpenpeeps();
91
+ const { currentProfile, openpeepsApi, client } = useOpenpeeps();
94
92
  const navigation =
95
93
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
96
94
  const { openNewPost } = useNewPostModal();
@@ -103,18 +101,31 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
103
101
  const event = useMemo(() => post?.data as Event, [post]);
104
102
 
105
103
  const canManageRsvps = canManageEventRsvps(currentProfile, post);
106
- const slotsLeft =
107
- isCapacityEvent(event) &&
108
- event.maxAttendees !== undefined &&
109
- (!event.recurrence || occurrence)
110
- ? event.maxAttendees - countYesRsvps(post, occurrence)
111
- : null;
104
+ const slotsLeft = availableSpots(post, occurrence) ?? null;
112
105
  const rsvpManage = openpeepsApi.rsvpManageAction();
113
- const times = effectiveEventTimes(
114
- event,
115
- occurrence ??
116
- (event?.recurrence ? defaultRsvpRecurrenceId(event) : undefined)
117
- );
106
+ const exportRsvps = async () => {
107
+ try {
108
+ const csv = await client.posts.exportRsvps({
109
+ id: post.id,
110
+ occurrence: parseOccurrenceQuery(occurrence),
111
+ });
112
+ const filename = rsvpExportFilename(event?.name, new Date());
113
+ const path = `${RNFS.CachesDirectoryPath}/${filename}`;
114
+ await RNFS.writeFile(path, csv, 'utf8');
115
+ await Share.share({
116
+ url: `file://${path}`,
117
+ title: filename,
118
+ }).catch(() => undefined);
119
+ } catch {
120
+ Toast.show({
121
+ type: 'error',
122
+ text1: t('events.exportRsvpsError', {
123
+ defaultValue: 'Failed to export RSVPs',
124
+ }),
125
+ });
126
+ }
127
+ };
128
+ const times = effectiveEventTimes(event, occurrence);
118
129
  const tz = eventTimeZoneOptions(event?.timeZone);
119
130
  const recurrenceLabel = event?.recurrence
120
131
  ? formatEventRecurrence(event.recurrence, t, event.start)
@@ -152,9 +163,9 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
152
163
  const showJamAttendeesTab =
153
164
  !!event.jam && canExportAttendees && jamAttendeesQuery.isSuccess;
154
165
 
155
- let postContextQuery = openpeepsApi.usePostContext(post.id);
166
+ const postContextQuery = openpeepsApi.usePostContext(post.id);
156
167
 
157
- let descendentThreads = useMemo(
168
+ const descendentThreads = useMemo(
158
169
  () =>
159
170
  (postContextQuery.data &&
160
171
  buildThreads(postContextQuery.data.descendants)) ||
@@ -480,6 +491,19 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
480
491
  ))}
481
492
  </TabsContent>
482
493
  <TabsContent value="rsvps" className="px-0 py-4">
494
+ {canManageRsvps ? (
495
+ <Button
496
+ variant="outline"
497
+ className="mb-3 self-end"
498
+ onPress={() => {
499
+ void exportRsvps();
500
+ }}
501
+ >
502
+ <ThemedText>
503
+ {t('events.exportRsvps', { defaultValue: 'Export RSVPs' })}
504
+ </ThemedText>
505
+ </Button>
506
+ ) : null}
483
507
  <EventRsvpList
484
508
  post={post as PublicPost}
485
509
  occurrenceId={occurrence}
@@ -725,7 +749,20 @@ export const FullEventActions: React.FC<{
725
749
 
726
750
  return (
727
751
  <View className="flex-row items-center">
728
- <ShareMenu post={post} />
752
+ <ShareMenu
753
+ post={post}
754
+ menuButton={
755
+ <Pressable
756
+ accessibilityLabel={t('posts.footer.share')}
757
+ className="flex-row items-center gap-1 px-2"
758
+ >
759
+ <ShareIcon size={18} className="text-foreground" />
760
+ <ThemedText className="text-sm">
761
+ {t('posts.footer.share')}
762
+ </ThemedText>
763
+ </Pressable>
764
+ }
765
+ />
729
766
  {myEvent ? (
730
767
  <EventMenu post={post} occurrence={occurrence} />
731
768
  ) : (
@@ -38,6 +38,8 @@ export const ProfileEventRelationship: React.FC<
38
38
  return t('events.profileRelationship.attending');
39
39
  } else if (myRsvp?.response === 'tentative') {
40
40
  return t('events.profileRelationship.tentative');
41
+ } else if (myRsvp?.response === 'waitlist') {
42
+ return t('events.profileRelationship.waitlisted');
41
43
  }
42
44
  return null;
43
45
  })();
@@ -108,6 +108,8 @@ export const FullResource = ({ post }: FullResourceProps) => {
108
108
  return (
109
109
  <ResourceCard
110
110
  post={post}
111
+ showDescription={false}
112
+ inGroup={!!post.group}
111
113
  preview={<VideoPlayer attachment={videoAtt} />}
112
114
  />
113
115
  );
@@ -122,6 +124,8 @@ export const FullResource = ({ post }: FullResourceProps) => {
122
124
  return (
123
125
  <ResourceCard
124
126
  post={post}
127
+ showDescription={false}
128
+ inGroup={!!post.group}
125
129
  preview={
126
130
  <AudioAttachment
127
131
  src={audioAtt.url}
@@ -137,7 +141,11 @@ export const FullResource = ({ post }: FullResourceProps) => {
137
141
  // All kinds: ResourceCard with click overlay
138
142
  return (
139
143
  <View className="relative">
140
- <ResourceCard post={post} />
144
+ <ResourceCard
145
+ post={post}
146
+ showDescription={false}
147
+ inGroup={!!post.group}
148
+ />
141
149
  <View
142
150
  className="absolute top-0 left-0 right-0 h-48 items-center justify-center"
143
151
  pointerEvents="box-none"
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  import { View, TouchableOpacity } from 'react-native';
3
- import { isJamPath, isPostPath, isGroupPath } from './helpers';
3
+ import { isJamPath, isPostPath, isGroupPath, isWelcomePath } from './helpers';
4
4
  import { PostPreview } from './local/PostPreview';
5
5
  import { JamPreview } from './local/JamPreview';
6
6
  import { GroupPreview } from './local/GroupPreview';
7
+ import { WelcomePreview } from './local/WelcomePreview';
7
8
  import { handleInternalURLNavigation } from '../../lib/utils';
8
9
  import { useNavigation } from '@react-navigation/native';
9
10
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
@@ -23,6 +24,7 @@ export const LocalPreviewLink = ({ url }: LocalPreviewLinkProps) => {
23
24
  const isPost = isPostPath(path);
24
25
  const isJam = isJamPath(path);
25
26
  const isGroup = isGroupPath(path);
27
+ const isWelcome = isWelcomePath(path);
26
28
 
27
29
  const handlePress = () => {
28
30
  handleInternalURLNavigation(url, goto);
@@ -34,6 +36,7 @@ export const LocalPreviewLink = ({ url }: LocalPreviewLinkProps) => {
34
36
  {isPost && <PostPreview path={path} />}
35
37
  {isGroup && <GroupPreview path={path} />}
36
38
  {isJam && <JamPreview path={path} />}
39
+ {isWelcome && <WelcomePreview />}
37
40
  </View>
38
41
  </TouchableOpacity>
39
42
  );
@@ -10,13 +10,17 @@ export const isJamPath = (path: string) =>
10
10
  path.endsWith('/jam');
11
11
  export const isGroupPath = (path: string) => path.startsWith('/groups/@');
12
12
 
13
+ export const isWelcomePath = (path: string) =>
14
+ path === '/welcome' || path === '/welcome/';
15
+
13
16
  export const isLocalLink = (url: string, origin: string) => {
14
17
  const urlObj = new URL(url);
15
18
  return (
16
19
  urlObj.origin === origin &&
17
20
  (isPostPath(urlObj.pathname) ||
18
21
  isJamPath(urlObj.pathname) ||
19
- isGroupPath(urlObj.pathname))
22
+ isGroupPath(urlObj.pathname) ||
23
+ isWelcomePath(urlObj.pathname))
20
24
  );
21
25
  };
22
26
 
@@ -5,3 +5,4 @@ export { AccessDenied } from './AccessDenied';
5
5
  export { PostPreview } from './local/PostPreview';
6
6
  export { JamPreview } from './local/JamPreview';
7
7
  export { GroupPreview } from './local/GroupPreview';
8
+ export { WelcomePreview } from './local/WelcomePreview';
@@ -0,0 +1,59 @@
1
+ import { useColorScheme, View } from 'react-native';
2
+ import { useWelcomePreview } from '@openpeepshq/react';
3
+ import { stripMarkdownImages, truncateMarkdown } from '@openpeepshq/common/lib';
4
+ import { CachedImage } from '../../custom/common';
5
+ import { ThemedText } from '../../ui/themed-text';
6
+ import { toAbsoluteMediaUrl } from '../../../lib/media-url';
7
+ import { TruncatedMarkdown } from '../../post/TruncatedMarkdown';
8
+
9
+ export const WelcomePreview = () => {
10
+ const systemColorScheme = useColorScheme();
11
+ const systemScheme = systemColorScheme === 'dark' ? 'dark' : 'light';
12
+ const { eyebrow, title, description, markdown, imageUrl, imageFit } =
13
+ useWelcomePreview(systemScheme);
14
+ const resolvedImage = toAbsoluteMediaUrl(imageUrl);
15
+
16
+ return (
17
+ <View
18
+ testID="welcome-preview-card"
19
+ className="flex w-full flex-row items-center gap-4"
20
+ >
21
+ {resolvedImage ? (
22
+ <View className="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md">
23
+ <CachedImage
24
+ url={resolvedImage}
25
+ className="h-full w-full"
26
+ resizeMode={imageFit}
27
+ />
28
+ </View>
29
+ ) : null}
30
+ <View className="min-w-0 flex-1 gap-1">
31
+ {eyebrow ? (
32
+ <ThemedText
33
+ className="text-muted-foreground text-xs"
34
+ numberOfLines={1}
35
+ >
36
+ {eyebrow}
37
+ </ThemedText>
38
+ ) : null}
39
+ <ThemedText className="font-semibold" numberOfLines={2}>
40
+ {title}
41
+ </ThemedText>
42
+ {markdown ? (
43
+ <TruncatedMarkdown
44
+ source={markdown}
45
+ snippet={truncateMarkdown(stripMarkdownImages(markdown), 2, 240)}
46
+ maxLines={2}
47
+ />
48
+ ) : description ? (
49
+ <ThemedText
50
+ className="text-muted-foreground text-sm"
51
+ numberOfLines={3}
52
+ >
53
+ {description}
54
+ </ThemedText>
55
+ ) : null}
56
+ </View>
57
+ </View>
58
+ );
59
+ };
@@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
3
3
  import { View, Text } from 'react-native';
4
4
  import { Profile, isDeletedProfile } from '@openpeepshq/common';
5
5
  import {
6
- useOpenpeeps,
7
6
  getInitials,
8
7
  hueFromHandle,
9
8
  initialsBackground,
@@ -1,11 +1,13 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
3
3
  import { ThemedView } from '../ui/themed-view';
4
- import { useOpenpeeps } from '@openpeepshq/react';
4
+ import { useOpenpeeps, useServerInfo } from '@openpeepshq/react';
5
5
  import { ThemedText } from '../ui/themed-text';
6
6
  import { useForm } from 'react-hook-form';
7
7
  import {
8
8
  getTheme,
9
+ HANDLE_RESERVED_MESSAGE,
10
+ isForbiddenHandle,
9
11
  MediaAttachment,
10
12
  Profile,
11
13
  ProfileData,
@@ -31,6 +33,7 @@ type EditProfileFormProps = {
31
33
  export const EditProfileForm: React.FC<EditProfileFormProps> = ({ handle }) => {
32
34
  const { openpeepsApi, queryClient } = useOpenpeeps();
33
35
  const { data: serverInfo } = openpeepsApi.useServerInfo();
36
+ const communitySettings = useServerInfo().communityConfig?.settings;
34
37
  const {
35
38
  data: profileData,
36
39
  isLoading,
@@ -84,6 +87,22 @@ export const EditProfileForm: React.FC<EditProfileFormProps> = ({ handle }) => {
84
87
  const updateProfileDetails = openpeepsApi.updateCurrentProfileAction();
85
88
 
86
89
  const onSubmit = async (values: ProfileData) => {
90
+ const additionalForbiddenHandles =
91
+ communitySettings?.additionalForbiddenHandles;
92
+ if (
93
+ values.handle &&
94
+ isForbiddenHandle(values.handle, additionalForbiddenHandles)
95
+ ) {
96
+ const message = t('profile.form.handleReserved');
97
+ form.setError('handle', { message });
98
+ Toast.show({
99
+ type: 'error',
100
+ text1: t('common.errors.error'),
101
+ text2: message,
102
+ });
103
+ return;
104
+ }
105
+
87
106
  setIsSubmitting(true);
88
107
 
89
108
  values.type = profileData?.type || 'local';
@@ -122,7 +141,9 @@ export const EditProfileForm: React.FC<EditProfileFormProps> = ({ handle }) => {
122
141
  ? t('profiles.handleExists', {
123
142
  defaultValue: 'This handle is already in use by someone else.',
124
143
  })
125
- : err.message,
144
+ : message === HANDLE_RESERVED_MESSAGE
145
+ ? t('profile.form.handleReserved')
146
+ : err.message,
126
147
  });
127
148
  })
128
149
  .finally(() => {
@@ -26,7 +26,7 @@ export const ProfileSheet = forwardRef<BottomSheetModal, ProfileSheetProps>(
26
26
  <View className="items-center pt-6">
27
27
  <TouchableOpacity
28
28
  onPress={() => {
29
- // @ts-ignore
29
+ // @ts-expect-error ref.current may be null
30
30
  ref?.current?.close();
31
31
  navigation.navigate('Profile', {
32
32
  handle: profile[0].handle,