@openpeepshq/rn-components 0.7.2 → 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.
- package/README.md +1 -1
- package/package.json +12 -7
- package/src/components/custom/navigation/side-menu.tsx +59 -11
- package/src/components/icons/iconWithClassName.tsx +21 -0
- package/src/components/jams/JamActionsFooter.tsx +8 -2
- package/src/components/jams/JamCapacityGate.tsx +1 -1
- package/src/components/jams/JamCard.tsx +8 -4
- package/src/components/jams/JamConference.tsx +6 -1
- package/src/components/jams/JamParticipantConference.tsx +2 -0
- package/src/components/jams/JamRoom.tsx +2 -3
- package/src/components/jams/LiveJamsSection.tsx +12 -1
- package/src/components/jams/LivekitUnavailableNotice.tsx +25 -0
- package/src/components/jams/index.ts +1 -0
- package/src/components/markdown/MarkdownOverlay.tsx +75 -0
- package/src/components/markdown/OpenpeepsMarkdown.tsx +3 -1
- package/src/components/markdown/extensions/link.tsx +34 -0
- package/src/components/markdown/index.ts +2 -0
- package/src/components/navigation/tab-navigator.tsx +39 -17
- package/src/components/notifications/NotificationItem.tsx +27 -2
- package/src/components/notifications/types/JamStarted.tsx +13 -3
- package/src/components/notifications/types/Reply.tsx +1 -5
- package/src/components/notifications/types/WaitlistOffer.tsx +61 -0
- package/src/components/notifications/types/index.ts +1 -0
- package/src/components/post/CompactReplyParent.tsx +16 -15
- package/src/components/post/TruncatedMarkdown.tsx +60 -0
- package/src/components/post/helpers.ts +2 -2
- package/src/components/post/index.ts +2 -0
- package/src/components/post/pieces/EventRsvpButton.tsx +99 -5
- package/src/components/post/pieces/EventRsvpList.tsx +46 -0
- package/src/components/post/pieces/EventRsvpScopeDialog.tsx +30 -19
- package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +62 -0
- package/src/components/post/pieces/PollContent.tsx +7 -7
- package/src/components/post/pieces/PostActions.tsx +89 -23
- package/src/components/post/pieces/ShareMenu.tsx +2 -2
- package/src/components/post/post-form/DescriptionEditModal.tsx +1 -0
- package/src/components/post/post-form/EventForm.tsx +50 -10
- package/src/components/post/post-form/ResourceForm.tsx +115 -5
- package/src/components/post/types/Article.tsx +6 -2
- package/src/components/post/types/Poll.tsx +4 -1
- package/src/components/post/types/event/CardEvent.tsx +101 -76
- package/src/components/post/types/event/FullEvent.tsx +60 -23
- package/src/components/post/types/event/ProfileEventRelationship.tsx +2 -0
- package/src/components/post/types/resource/FullResource.tsx +9 -1
- package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
- package/src/components/preview-link/helpers.ts +5 -1
- package/src/components/preview-link/index.ts +1 -0
- package/src/components/preview-link/local/WelcomePreview.tsx +59 -0
- package/src/components/profile/Avatar.tsx +0 -1
- package/src/components/profile/EditProfileForm.tsx +23 -2
- package/src/components/profile/ProfileSheet.tsx +1 -1
- package/src/components/resources/ResourceCard.tsx +62 -14
- package/src/components/resources/ResourceLibrary.tsx +2 -2
- package/src/components/ui/badge.tsx +2 -3
- package/src/components/ui/bottom-sheet.tsx +0 -6
- package/src/components/ui/popup-menu-button.tsx +2 -2
- package/src/components/ui/popup-menu-separator.tsx +1 -1
- package/src/components/ui/popup-menu.tsx +2 -2
- package/src/lib/utils.ts +10 -3
- package/src/pages/auth/Register.tsx +34 -4
- package/src/pages/conversations/Show.tsx +38 -7
- package/src/pages/feeds/Bookmarks.tsx +1 -1
- package/src/pages/jams/Index.tsx +6 -4
- package/src/pages/posts/New.tsx +1 -1
- package/src/pages/resources/Edit.tsx +2 -1
- package/src/pages/resources/New.tsx +6 -1
- package/src/pages/settings/Account.tsx +46 -2
- package/src/pages/settings/Index.tsx +3 -4
- package/src/pages/settings/NotificationPreferences.tsx +3 -3
- package/src/pages/settings/Theme.tsx +1 -1
- package/src/components/icons/iconWithClassName.ts +0 -12
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
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
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
138
|
+
{t('jam.start.submit', { defaultValue: 'Start Jam' })}
|
|
116
139
|
</ThemedText>
|
|
117
140
|
</Button>
|
|
118
|
-
|
|
119
|
-
) :
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
<
|
|
130
|
-
|
|
153
|
+
<ShareIcon size={18} className="text-foreground" />
|
|
154
|
+
<ThemedText className="text-sm">
|
|
155
|
+
{t('posts.footer.share')}
|
|
131
156
|
</ThemedText>
|
|
132
|
-
</
|
|
133
|
-
|
|
134
|
-
|
|
157
|
+
</Pressable>
|
|
158
|
+
}
|
|
159
|
+
/>
|
|
135
160
|
</View>
|
|
136
|
-
</
|
|
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
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
166
|
+
const postContextQuery = openpeepsApi.usePostContext(post.id);
|
|
156
167
|
|
|
157
|
-
|
|
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
|
|
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
|
|
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
|
|
|
@@ -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
|
+
};
|
|
@@ -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
|
-
:
|
|
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-
|
|
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,
|