@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.
- 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 +75 -22
- package/src/components/resources/ResourceLibrary.tsx +18 -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,6 +1,8 @@
|
|
|
1
1
|
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import { Pressable, View } from 'react-native';
|
|
3
|
+
import { Linking, Pressable, View } from 'react-native';
|
|
4
|
+
import { useNavigation } from '@react-navigation/native';
|
|
5
|
+
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
4
6
|
import { useTranslation } from 'react-i18next';
|
|
5
7
|
import type {
|
|
6
8
|
MediaAttachmentData,
|
|
@@ -10,13 +12,16 @@ import type {
|
|
|
10
12
|
import {
|
|
11
13
|
attachmentMediaKind,
|
|
12
14
|
formatSize,
|
|
15
|
+
groupName,
|
|
13
16
|
normalizeResourceTags,
|
|
14
|
-
truncateMarkdown,
|
|
15
17
|
} from '@openpeepshq/common/lib';
|
|
16
18
|
import { useOpenpeeps } from '@openpeepshq/react';
|
|
19
|
+
import type { MainStackParamList } from '../navigation/types/index';
|
|
17
20
|
import { CachedImage } from '../custom/common';
|
|
18
21
|
import { ThemedText } from '../ui/themed-text';
|
|
19
22
|
import { VideoPlayOverlay } from '../post/VideoPlayOverlay';
|
|
23
|
+
import { TruncatedMarkdown } from '../post/TruncatedMarkdown';
|
|
24
|
+
import { buildGoto } from '../navigation/helpers';
|
|
20
25
|
import {
|
|
21
26
|
BookmarkPlusIcon,
|
|
22
27
|
BookmarkMinusIcon,
|
|
@@ -28,6 +33,10 @@ export interface ResourceCardProps {
|
|
|
28
33
|
post: PublicPost;
|
|
29
34
|
layout?: 'card' | 'list';
|
|
30
35
|
preview?: ReactNode;
|
|
36
|
+
/** Set false when the full description is rendered by the surrounding layout (e.g. the post detail page). */
|
|
37
|
+
showDescription?: boolean;
|
|
38
|
+
/** When true, hides the group label (already shown by the group context). */
|
|
39
|
+
inGroup?: boolean;
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
const visualAttachments = (attachments: MediaAttachmentData[]) =>
|
|
@@ -55,8 +64,13 @@ export const ResourceCard = ({
|
|
|
55
64
|
post,
|
|
56
65
|
layout = 'card',
|
|
57
66
|
preview,
|
|
67
|
+
showDescription = true,
|
|
68
|
+
inGroup = false,
|
|
58
69
|
}: ResourceCardProps) => {
|
|
59
70
|
const { t } = useTranslation();
|
|
71
|
+
const navigation =
|
|
72
|
+
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
73
|
+
const goto = buildGoto(navigation);
|
|
60
74
|
const { openpeepsApi } = useOpenpeeps();
|
|
61
75
|
const { data: currentProfile } = openpeepsApi.useCurrentProfile();
|
|
62
76
|
const bookmarkedIdsQuery = openpeepsApi.useCurrentProfileBookmarkedIds();
|
|
@@ -74,13 +88,18 @@ export const ResourceCard = ({
|
|
|
74
88
|
!!resource && resource.resourceKind === 'gallery' && visuals.length > 1;
|
|
75
89
|
const tiles = isGallery ? visuals.slice(0, 4) : visuals.slice(0, 1);
|
|
76
90
|
const extra = isGallery ? Math.max(0, visuals.length - 4) : 0;
|
|
77
|
-
const excerpt = resource ? truncateMarkdown(resource.content, 2, 240) : null;
|
|
78
91
|
const tags = resource ? normalizeResourceTags(resource.tags) : [];
|
|
79
92
|
const actionLabel = resource
|
|
80
93
|
? primaryActionLabel(resource.resourceKind, (key, opts) => t(key, opts))
|
|
81
94
|
: null;
|
|
82
95
|
const thumbnail = visuals[0];
|
|
83
96
|
const thumbSrc = thumbnail ? (thumbnail.previewUrl ?? thumbnail.url) : null;
|
|
97
|
+
const downloadUrl =
|
|
98
|
+
resource && resource.resourceKind === 'file'
|
|
99
|
+
? (resource.attachments ?? []).find(
|
|
100
|
+
(att) => attachmentMediaKind(att) === 'file'
|
|
101
|
+
)?.url
|
|
102
|
+
: null;
|
|
84
103
|
|
|
85
104
|
const metaText = useMemo(() => {
|
|
86
105
|
if (!resource) return null;
|
|
@@ -102,6 +121,9 @@ export const ResourceCard = ({
|
|
|
102
121
|
|
|
103
122
|
if (!resource) return null;
|
|
104
123
|
|
|
124
|
+
const group = post.group;
|
|
125
|
+
const groupLabel = group ? groupName(group) : null;
|
|
126
|
+
|
|
105
127
|
const toggleBookmark = () => {
|
|
106
128
|
if (!currentProfile) return;
|
|
107
129
|
if (isBookmarked) {
|
|
@@ -125,6 +147,23 @@ export const ResourceCard = ({
|
|
|
125
147
|
</Pressable>
|
|
126
148
|
);
|
|
127
149
|
|
|
150
|
+
const renderGroupLabel = () => {
|
|
151
|
+
if (!group || !groupLabel || inGroup) return null;
|
|
152
|
+
return (
|
|
153
|
+
<Pressable
|
|
154
|
+
onPress={() => navigation.navigate('Group', { handle: group.handle })}
|
|
155
|
+
className="rounded-full bg-muted px-2 py-0.5"
|
|
156
|
+
>
|
|
157
|
+
<ThemedText className="text-xs text-muted-foreground">
|
|
158
|
+
{t('resources.group.inGroup', {
|
|
159
|
+
defaultValue: 'in {{groupName}}',
|
|
160
|
+
groupName: groupLabel,
|
|
161
|
+
})}
|
|
162
|
+
</ThemedText>
|
|
163
|
+
</Pressable>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
128
167
|
const renderThumbnail = () => {
|
|
129
168
|
if (thumbSrc) {
|
|
130
169
|
return (
|
|
@@ -154,10 +193,15 @@ export const ResourceCard = ({
|
|
|
154
193
|
{resource.categoryPath.join(' / ')}
|
|
155
194
|
</ThemedText>
|
|
156
195
|
) : null}
|
|
157
|
-
{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
196
|
+
{renderGroupLabel()}
|
|
197
|
+
{showDescription ? (
|
|
198
|
+
<TruncatedMarkdown
|
|
199
|
+
source={resource.content ?? ''}
|
|
200
|
+
maxBlocks={2}
|
|
201
|
+
maxChars={240}
|
|
202
|
+
maxLines={2}
|
|
203
|
+
className="text-sm text-muted-foreground"
|
|
204
|
+
/>
|
|
161
205
|
) : null}
|
|
162
206
|
{metaText ? (
|
|
163
207
|
<ThemedText className="text-xs text-muted-foreground">
|
|
@@ -167,13 +211,12 @@ export const ResourceCard = ({
|
|
|
167
211
|
</View>
|
|
168
212
|
<View className="flex-row items-center gap-2">
|
|
169
213
|
{resource.resourceKind !== 'link' && actionLabel ? (
|
|
170
|
-
actionLabel === 'Download' &&
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
</ThemedText>
|
|
214
|
+
actionLabel === 'Download' && downloadUrl ? (
|
|
215
|
+
<Pressable onPress={() => Linking.openURL(downloadUrl)}>
|
|
216
|
+
<ThemedText className="text-primary text-xs font-medium">
|
|
217
|
+
{actionLabel}
|
|
218
|
+
</ThemedText>
|
|
219
|
+
</Pressable>
|
|
177
220
|
) : (
|
|
178
221
|
<ThemedText className="text-muted-foreground text-xs">
|
|
179
222
|
{actionLabel}
|
|
@@ -259,10 +302,15 @@ export const ResourceCard = ({
|
|
|
259
302
|
{resource.categoryPath.join(' / ')}
|
|
260
303
|
</ThemedText>
|
|
261
304
|
) : null}
|
|
262
|
-
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
305
|
+
{renderGroupLabel()}
|
|
306
|
+
{showDescription ? (
|
|
307
|
+
<TruncatedMarkdown
|
|
308
|
+
source={resource.content ?? ''}
|
|
309
|
+
maxBlocks={2}
|
|
310
|
+
maxChars={240}
|
|
311
|
+
maxLines={2}
|
|
312
|
+
className="text-sm text-muted-foreground"
|
|
313
|
+
/>
|
|
266
314
|
) : null}
|
|
267
315
|
{metaText ? (
|
|
268
316
|
<ThemedText className="text-xs text-muted-foreground">
|
|
@@ -272,12 +320,17 @@ export const ResourceCard = ({
|
|
|
272
320
|
{tags.length ? (
|
|
273
321
|
<View className="flex-row flex-wrap gap-1">
|
|
274
322
|
{tags.map((value) => (
|
|
275
|
-
<
|
|
323
|
+
<Pressable
|
|
276
324
|
key={value}
|
|
277
|
-
|
|
325
|
+
onPress={() =>
|
|
326
|
+
goto({ target: 'HashtagPosts', params: { tag: value } })
|
|
327
|
+
}
|
|
328
|
+
className="rounded-full bg-muted px-2 py-0.5"
|
|
278
329
|
>
|
|
279
|
-
|
|
280
|
-
|
|
330
|
+
<ThemedText className="text-xs text-muted-foreground">
|
|
331
|
+
#{value}
|
|
332
|
+
</ThemedText>
|
|
333
|
+
</Pressable>
|
|
281
334
|
))}
|
|
282
335
|
</View>
|
|
283
336
|
) : null}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import { Pressable, View, ScrollView } from 'react-native';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useNavigation } from '@react-navigation/native';
|
|
5
|
+
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
4
6
|
import type { ResourceKind } from '@openpeepshq/common/types';
|
|
5
7
|
import { RESOURCE_KINDS } from '@openpeepshq/common/lib';
|
|
6
8
|
import type { CategoryNode } from '@openpeepshq/common/lib';
|
|
7
9
|
import { useResourceLibrary } from '@openpeepshq/react';
|
|
10
|
+
import { MainStackParamList } from '../navigation/types/index';
|
|
8
11
|
import { Input } from '../ui/input';
|
|
9
12
|
import { LoadingSpinner } from '../ui/loading-spinner';
|
|
10
13
|
import { ThemedText } from '../ui/themed-text';
|
|
@@ -94,6 +97,8 @@ const Tree = ({
|
|
|
94
97
|
|
|
95
98
|
export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
|
|
96
99
|
const { t } = useTranslation();
|
|
100
|
+
const navigation =
|
|
101
|
+
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
97
102
|
const library = useResourceLibrary(groupId);
|
|
98
103
|
const [expanded, setExpanded] = useState<Set<string>>(new Set());
|
|
99
104
|
|
|
@@ -356,13 +361,24 @@ export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
|
|
|
356
361
|
) : library.view === 'list' ? (
|
|
357
362
|
<View className="divide-border">
|
|
358
363
|
{library.posts.map((post) => (
|
|
359
|
-
<
|
|
364
|
+
<Pressable
|
|
365
|
+
key={post.id}
|
|
366
|
+
onPress={() => navigation.navigate('Post', { id: post.id })}
|
|
367
|
+
className="border-b border-border"
|
|
368
|
+
>
|
|
369
|
+
<ResourceCard post={post} layout="list" inGroup={!!groupId} />
|
|
370
|
+
</Pressable>
|
|
360
371
|
))}
|
|
361
372
|
</View>
|
|
362
373
|
) : (
|
|
363
374
|
<ScrollView horizontal={false} contentContainerClassName="gap-4 p-4">
|
|
364
375
|
{library.posts.map((post) => (
|
|
365
|
-
<
|
|
376
|
+
<Pressable
|
|
377
|
+
key={post.id}
|
|
378
|
+
onPress={() => navigation.navigate('Post', { id: post.id })}
|
|
379
|
+
>
|
|
380
|
+
<ResourceCard post={post} layout="card" inGroup={!!groupId} />
|
|
381
|
+
</Pressable>
|
|
366
382
|
))}
|
|
367
383
|
</ScrollView>
|
|
368
384
|
)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { View } from 'react-native';
|
|
4
|
-
import {
|
|
4
|
+
import {} from './themed-text';
|
|
5
5
|
import { cn } from '../../lib/utils';
|
|
6
6
|
|
|
7
7
|
const badgeVariants = cva(
|
|
@@ -23,8 +23,7 @@ const badgeVariants = cva(
|
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
export interface BadgeProps
|
|
26
|
-
extends
|
|
27
|
-
React.ComponentPropsWithoutRef<typeof View>,
|
|
26
|
+
extends React.ComponentPropsWithoutRef<typeof View>,
|
|
28
27
|
VariantProps<typeof badgeVariants> {}
|
|
29
28
|
|
|
30
29
|
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
@@ -25,12 +25,6 @@ import { cn } from '../../lib/utils';
|
|
|
25
25
|
type BottomSheetRef = React.ElementRef<typeof View>;
|
|
26
26
|
type BottomSheetProps = React.ComponentPropsWithoutRef<typeof View>;
|
|
27
27
|
|
|
28
|
-
interface BottomSheetContext {
|
|
29
|
-
sheetRef: React.RefObject<BottomSheetModal>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const BottomSheetContext = React.createContext({} as BottomSheetContext);
|
|
33
|
-
|
|
34
28
|
const BottomSheet = React.forwardRef<BottomSheetRef, BottomSheetProps>(
|
|
35
29
|
({ ...props }, ref) => {
|
|
36
30
|
return <View ref={ref} {...props} />;
|
|
@@ -38,11 +38,11 @@ const baseClass =
|
|
|
38
38
|
export const PopupMenuButton = ({
|
|
39
39
|
action,
|
|
40
40
|
text = '',
|
|
41
|
-
loadingText = '',
|
|
41
|
+
loadingText: _loadingText = '',
|
|
42
42
|
icon: Icon,
|
|
43
43
|
danger = false,
|
|
44
44
|
compact = false,
|
|
45
|
-
title = '',
|
|
45
|
+
title: _title = '',
|
|
46
46
|
textSlot,
|
|
47
47
|
closeOnPress = true,
|
|
48
48
|
disabled,
|
|
@@ -27,7 +27,7 @@ const DEFAULT_ICON_SIZE = 22;
|
|
|
27
27
|
* surface as @openpeepshq/react-ui's PopupMenu.
|
|
28
28
|
*/
|
|
29
29
|
export const PopupMenu = ({
|
|
30
|
-
className,
|
|
30
|
+
className: _className,
|
|
31
31
|
iconSize = DEFAULT_ICON_SIZE,
|
|
32
32
|
compact = false,
|
|
33
33
|
menuButton,
|
|
@@ -36,7 +36,7 @@ export const PopupMenu = ({
|
|
|
36
36
|
triggerIcon,
|
|
37
37
|
}: PopupMenuProps) => {
|
|
38
38
|
const actionName = title;
|
|
39
|
-
const [
|
|
39
|
+
const [_open, setOpen] = React.useState(false);
|
|
40
40
|
|
|
41
41
|
const TriggerIcon = () => {
|
|
42
42
|
if (triggerIcon) return <>{triggerIcon}</>;
|
package/src/lib/utils.ts
CHANGED
|
@@ -130,8 +130,12 @@ export const handleInternalURLNavigation = (
|
|
|
130
130
|
const hash = hashStart === -1 ? '' : path.slice(hashStart);
|
|
131
131
|
const pathWithoutHash = hashStart === -1 ? path : path.slice(0, hashStart);
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
const pathname = pathWithoutHash.split('?')[0] ?? pathWithoutHash;
|
|
134
|
+
if (isWelcomePath(pathname)) {
|
|
135
|
+
goto({ target: 'welcome' });
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
if (isGroupPath(pathname)) {
|
|
135
139
|
goto({
|
|
136
140
|
target: 'group',
|
|
137
141
|
params: {
|
|
@@ -204,6 +208,8 @@ export const handleInternalURLNavigation = (
|
|
|
204
208
|
};
|
|
205
209
|
|
|
206
210
|
export const isProfilePath = (path: string) => path.startsWith('/@');
|
|
211
|
+
export const isWelcomePath = (path: string) =>
|
|
212
|
+
path === '/welcome' || path === '/welcome/';
|
|
207
213
|
export const isGroupPath = (path: string) => path.startsWith('/groups/@');
|
|
208
214
|
export const isJamPath = (path: string) =>
|
|
209
215
|
path.startsWith('/events/') && path.endsWith('/jam');
|
|
@@ -217,7 +223,8 @@ export const isLocalLink = (url: string, origin: string) => {
|
|
|
217
223
|
urlObj.origin === origin &&
|
|
218
224
|
(isPostPath(urlObj.pathname) ||
|
|
219
225
|
isJamPath(urlObj.pathname) ||
|
|
220
|
-
isGroupPath(urlObj.pathname)
|
|
226
|
+
isGroupPath(urlObj.pathname) ||
|
|
227
|
+
isWelcomePath(urlObj.pathname))
|
|
221
228
|
);
|
|
222
229
|
} catch {
|
|
223
230
|
return false;
|
|
@@ -6,6 +6,9 @@ import { useForm } from 'react-hook-form';
|
|
|
6
6
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
7
7
|
import { NativeStackScreenProps } from '@react-navigation/native-stack';
|
|
8
8
|
import {
|
|
9
|
+
accountNameSchema,
|
|
10
|
+
HANDLE_RESERVED_MESSAGE,
|
|
11
|
+
isForbiddenHandle,
|
|
9
12
|
registerRequestSchema,
|
|
10
13
|
type RegisterRequest,
|
|
11
14
|
} from '@openpeepshq/common';
|
|
@@ -31,7 +34,10 @@ const INVITE_INACTIVE_MESSAGES = new Set([
|
|
|
31
34
|
'Invalid Invite Code',
|
|
32
35
|
]);
|
|
33
36
|
|
|
34
|
-
const buildRegisterFormSchema = (
|
|
37
|
+
const buildRegisterFormSchema = (
|
|
38
|
+
t: TFunction,
|
|
39
|
+
additionalForbiddenHandles: readonly string[] = []
|
|
40
|
+
) =>
|
|
35
41
|
registerRequestSchema
|
|
36
42
|
.refine((d) => d.password === d.confirmPassword, {
|
|
37
43
|
message: t('auth.register.passwordsDoNotMatch'),
|
|
@@ -40,12 +46,25 @@ const buildRegisterFormSchema = (t: TFunction) =>
|
|
|
40
46
|
.refine((d) => d.privacyPolicyAccepted, {
|
|
41
47
|
message: t('auth.register.mustAgreePrivacyPolicy'),
|
|
42
48
|
path: ['privacyPolicyAccepted'],
|
|
49
|
+
})
|
|
50
|
+
.superRefine((data, ctx) => {
|
|
51
|
+
if (!isForbiddenHandle(data.handle, additionalForbiddenHandles)) return;
|
|
52
|
+
if (!accountNameSchema.safeParse(data.handle).success) return;
|
|
53
|
+
ctx.addIssue({
|
|
54
|
+
code: 'custom',
|
|
55
|
+
path: ['handle'],
|
|
56
|
+
message: t('profile.form.handleReserved'),
|
|
57
|
+
});
|
|
43
58
|
});
|
|
44
59
|
|
|
45
|
-
const registerErrorCopy = (raw: string, t: TFunction) =>
|
|
46
|
-
|
|
60
|
+
const registerErrorCopy = (raw: string, t: TFunction) => {
|
|
61
|
+
if (raw === HANDLE_RESERVED_MESSAGE) {
|
|
62
|
+
return t('profile.form.handleReserved');
|
|
63
|
+
}
|
|
64
|
+
return INVITE_INACTIVE_MESSAGES.has(raw)
|
|
47
65
|
? t('auth.register.inviteInactive')
|
|
48
66
|
: t(raw);
|
|
67
|
+
};
|
|
49
68
|
|
|
50
69
|
type RegisterProps = NativeStackScreenProps<
|
|
51
70
|
AuthStackParamList,
|
|
@@ -60,7 +79,12 @@ export const Register = ({
|
|
|
60
79
|
const { t } = useTranslation();
|
|
61
80
|
const { register } = useRegisterAccount();
|
|
62
81
|
const serverInfo = useServerInfo();
|
|
63
|
-
const
|
|
82
|
+
const additionalForbiddenHandles =
|
|
83
|
+
serverInfo.communityConfig?.settings?.additionalForbiddenHandles;
|
|
84
|
+
const registerFormSchema = useMemo(
|
|
85
|
+
() => buildRegisterFormSchema(t, additionalForbiddenHandles ?? []),
|
|
86
|
+
[t, additionalForbiddenHandles]
|
|
87
|
+
);
|
|
64
88
|
|
|
65
89
|
const form = useForm<RegisterRequest>({
|
|
66
90
|
resolver: zodResolver(registerFormSchema),
|
|
@@ -201,6 +225,12 @@ export const Register = ({
|
|
|
201
225
|
)}
|
|
202
226
|
/>
|
|
203
227
|
|
|
228
|
+
{password && password.length > 0 && (
|
|
229
|
+
<ThemedText className="text-xs text-muted-foreground">
|
|
230
|
+
{t('auth.register.passwordRules')}
|
|
231
|
+
</ThemedText>
|
|
232
|
+
)}
|
|
233
|
+
|
|
204
234
|
{(password ?? '').length > 0 && (confirmPassword ?? '').length === 0 ? (
|
|
205
235
|
<View className="w-full items-center rounded border border-border py-2">
|
|
206
236
|
<ThemedText>
|
|
@@ -23,14 +23,38 @@ import { OpenpeepsMarkdownInput } from '../../components/post/post-form/Openpeep
|
|
|
23
23
|
import { maxContentLength } from '../../lib/utils';
|
|
24
24
|
import { DropdownMenu } from '../../components/ui/dropdown-menu';
|
|
25
25
|
import { Button } from '../../components/ui/button';
|
|
26
|
+
import { ProfileAvatar } from '../../components/profile/Avatar';
|
|
26
27
|
import { ThemedText } from '../../components/ui/themed-text';
|
|
27
28
|
import {
|
|
28
29
|
ConversationParticipantsModal,
|
|
29
30
|
ConversationProfileHeader,
|
|
30
31
|
MessageInThread,
|
|
31
32
|
} from '../../components/conversations/index';
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Shows handle + bio for a 1:1 conversation participant, without a
|
|
36
|
+
* duplicate avatar (the header already renders it).
|
|
37
|
+
*/
|
|
38
|
+
const ConversationParticipantDetail = ({
|
|
39
|
+
profile,
|
|
40
|
+
}: {
|
|
41
|
+
profile: import('@openpeepshq/common').Profile;
|
|
42
|
+
}) => {
|
|
43
|
+
const truncate = (text: string | null | undefined, max: number) =>
|
|
44
|
+
!text ? '' : text.length > max ? text.slice(0, max) + '…' : text;
|
|
45
|
+
return (
|
|
46
|
+
<View className="gap-y-1 p-3">
|
|
47
|
+
<ThemedText className="text-muted-foreground text-xs">
|
|
48
|
+
@{profile.handle}
|
|
49
|
+
</ThemedText>
|
|
50
|
+
{profile.bio ? (
|
|
51
|
+
<ThemedText className="text-sm">
|
|
52
|
+
{truncate(profile.bio, 100)}
|
|
53
|
+
</ThemedText>
|
|
54
|
+
) : null}
|
|
55
|
+
</View>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
34
58
|
|
|
35
59
|
type ConversationProps = MainScreenProps<'Conversation'>;
|
|
36
60
|
|
|
@@ -100,6 +124,17 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
100
124
|
};
|
|
101
125
|
}, [id, client, queryClient, flushPostViews]);
|
|
102
126
|
|
|
127
|
+
// The URL may point at any root of a merged 1:1 conversation (e.g.
|
|
128
|
+
// notification links); unseen counts are merged under the pair's oldest
|
|
129
|
+
// root, so clear that key once the conversation's first message is known.
|
|
130
|
+
const firstMessageId = messages?.[0]?.id;
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (!id || !firstMessageId || firstMessageId === id) return;
|
|
133
|
+
adjustUnseenCounts(queryClient, client, {
|
|
134
|
+
clearConversation: firstMessageId,
|
|
135
|
+
});
|
|
136
|
+
}, [id, firstMessageId, client, queryClient]);
|
|
137
|
+
|
|
103
138
|
useEffect(() => {
|
|
104
139
|
if (!id || !currentProfile || isLoading || !messages) return;
|
|
105
140
|
const unseenIds = messages
|
|
@@ -142,11 +177,7 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
142
177
|
mirroring the web conversation Show page. */}
|
|
143
178
|
<View className="border-b border-border">
|
|
144
179
|
{participants.length === 1 && participants[0] ? (
|
|
145
|
-
<
|
|
146
|
-
profile={participants[0]}
|
|
147
|
-
showAction={false}
|
|
148
|
-
hasAction={false}
|
|
149
|
-
/>
|
|
180
|
+
<ConversationParticipantDetail profile={participants[0]} />
|
|
150
181
|
) : multipleParticipants ? (
|
|
151
182
|
<TouchableOpacity
|
|
152
183
|
onPress={() => setParticipantsOpen(true)}
|
|
@@ -15,7 +15,7 @@ type HomeScreenProps = CompositeScreenProps<
|
|
|
15
15
|
NativeStackScreenProps<TabStackParamList, 'Bookmarks'>,
|
|
16
16
|
NativeStackScreenProps<MainStackParamList>
|
|
17
17
|
>;
|
|
18
|
-
export const FeedsBookmarks: React.FC<HomeScreenProps> = (
|
|
18
|
+
export const FeedsBookmarks: React.FC<HomeScreenProps> = () => {
|
|
19
19
|
const { openpeepsApi } = useOpenpeeps();
|
|
20
20
|
const { t } = useTranslation();
|
|
21
21
|
|
package/src/pages/jams/Index.tsx
CHANGED
|
@@ -10,7 +10,11 @@ import {
|
|
|
10
10
|
ChevronRightIcon,
|
|
11
11
|
MoreHorizontalIcon,
|
|
12
12
|
} from '../../components/icons/index';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
CreateNewJam,
|
|
15
|
+
LiveJamsSection,
|
|
16
|
+
LivekitUnavailableNotice,
|
|
17
|
+
} from '../../components/jams/index';
|
|
14
18
|
import { MainStackParamList } from '../../components/navigation/types/index';
|
|
15
19
|
import { EventsFeed } from '../../components/post/feed/events/EventsFeed';
|
|
16
20
|
import { Button } from '../../components/ui/button';
|
|
@@ -99,9 +103,7 @@ export const JamsIndex = ({ my = false }: Props) => {
|
|
|
99
103
|
className="w-full bg-background p-4"
|
|
100
104
|
>
|
|
101
105
|
{!livekitEnabled ? (
|
|
102
|
-
<
|
|
103
|
-
{t('jams.unavailable.message')}
|
|
104
|
-
</ThemedText>
|
|
106
|
+
<LivekitUnavailableNotice className="mb-4 text-sm text-destructive" />
|
|
105
107
|
) : null}
|
|
106
108
|
{!my && livekitEnabled ? <LiveJamsSection /> : null}
|
|
107
109
|
|
package/src/pages/posts/New.tsx
CHANGED
|
@@ -277,7 +277,7 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
277
277
|
if (route.params?.triggeredFrom === 'group') {
|
|
278
278
|
navigation.pop();
|
|
279
279
|
navigation.navigate('Group', {
|
|
280
|
-
id: route.params?.originatorId
|
|
280
|
+
id: route.params?.originatorId as string,
|
|
281
281
|
});
|
|
282
282
|
} else {
|
|
283
283
|
navigation.goBack();
|
|
@@ -21,6 +21,7 @@ export const EditResource: React.FC<EditResourceProps> = ({ route }) => {
|
|
|
21
21
|
postData,
|
|
22
22
|
setPostData,
|
|
23
23
|
resourceTitle,
|
|
24
|
+
canSubmit,
|
|
24
25
|
submitting,
|
|
25
26
|
error,
|
|
26
27
|
clearError,
|
|
@@ -46,7 +47,7 @@ export const EditResource: React.FC<EditResourceProps> = ({ route }) => {
|
|
|
46
47
|
: t('resources.update.title', { defaultValue: 'Update resource' })
|
|
47
48
|
}
|
|
48
49
|
onPress={() => void submit()}
|
|
49
|
-
disabled={submitting || !
|
|
50
|
+
disabled={submitting || !canSubmit}
|
|
50
51
|
loading={submitting}
|
|
51
52
|
/>
|
|
52
53
|
);
|
|
@@ -16,6 +16,7 @@ export const NewResource: React.FC<NewResourceProps> = () => {
|
|
|
16
16
|
postData,
|
|
17
17
|
setPostData,
|
|
18
18
|
canSubmit,
|
|
19
|
+
groupOnly,
|
|
19
20
|
submitting,
|
|
20
21
|
error,
|
|
21
22
|
clearError,
|
|
@@ -48,7 +49,11 @@ export const NewResource: React.FC<NewResourceProps> = () => {
|
|
|
48
49
|
contentContainerClassName="grow"
|
|
49
50
|
className="pb-12"
|
|
50
51
|
>
|
|
51
|
-
<ResourceForm
|
|
52
|
+
<ResourceForm
|
|
53
|
+
postData={postData}
|
|
54
|
+
onChange={setPostData}
|
|
55
|
+
groupOnly={groupOnly}
|
|
56
|
+
/>
|
|
52
57
|
</KeyboardAwareScrollView>
|
|
53
58
|
</ThemedView>
|
|
54
59
|
);
|
|
@@ -10,7 +10,7 @@ import Toast from 'react-native-toast-message';
|
|
|
10
10
|
import { Button } from '../../components/ui/button';
|
|
11
11
|
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
|
12
12
|
import { Account } from '@openpeepshq/common';
|
|
13
|
-
import { View } from 'react-native';
|
|
13
|
+
import { ActivityIndicator, View } from 'react-native';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
|
|
16
16
|
type AccountSettingsProps = MainScreenProps<'AccountSettings'>;
|
|
@@ -22,7 +22,7 @@ type AccountFormValues = {
|
|
|
22
22
|
confirmPassword: string | undefined;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export const AccountSettings: React.FC<AccountSettingsProps> = (
|
|
25
|
+
export const AccountSettings: React.FC<AccountSettingsProps> = () => {
|
|
26
26
|
const { openpeepsApi, queryClient } = useOpenpeeps();
|
|
27
27
|
const { data: currentAccount } = openpeepsApi.useCurrentAccount();
|
|
28
28
|
const logout = openpeepsApi.logoutAction();
|
|
@@ -31,7 +31,9 @@ export const AccountSettings: React.FC<AccountSettingsProps> = ({}) => {
|
|
|
31
31
|
const [isConfirmPasswordVisible, setIsConfirmPasswordVisible] =
|
|
32
32
|
React.useState(false);
|
|
33
33
|
const updateCurrentAccount = openpeepsApi.updateCurrentAccountAction();
|
|
34
|
+
const validateEmail = openpeepsApi.validationEmailAction();
|
|
34
35
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
36
|
+
const [verifying, setVerifying] = useState(false);
|
|
35
37
|
const { t } = useTranslation();
|
|
36
38
|
|
|
37
39
|
const form = useForm<AccountFormValues>({
|
|
@@ -116,6 +118,28 @@ export const AccountSettings: React.FC<AccountSettingsProps> = ({}) => {
|
|
|
116
118
|
setIsSubmitting(false);
|
|
117
119
|
});
|
|
118
120
|
};
|
|
121
|
+
const handleVerifyEmail = async () => {
|
|
122
|
+
setVerifying(true);
|
|
123
|
+
try {
|
|
124
|
+
await validateEmail();
|
|
125
|
+
Toast.show({
|
|
126
|
+
type: 'success',
|
|
127
|
+
text1: t('settings.account.verifyEmailSent', {
|
|
128
|
+
defaultValue: 'Verification email sent',
|
|
129
|
+
}),
|
|
130
|
+
});
|
|
131
|
+
} catch {
|
|
132
|
+
Toast.show({
|
|
133
|
+
type: 'error',
|
|
134
|
+
text1: t('settings.account.verifyEmailError', {
|
|
135
|
+
defaultValue: 'Failed to send verification email',
|
|
136
|
+
}),
|
|
137
|
+
});
|
|
138
|
+
} finally {
|
|
139
|
+
setVerifying(false);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
119
143
|
const handleSubmit = async () => {
|
|
120
144
|
const values = form.getValues();
|
|
121
145
|
await onSubmit(values);
|
|
@@ -165,6 +189,26 @@ export const AccountSettings: React.FC<AccountSettingsProps> = ({}) => {
|
|
|
165
189
|
)}
|
|
166
190
|
/>
|
|
167
191
|
</View>
|
|
192
|
+
{!(currentAccount as Account)?.emailValidated ? (
|
|
193
|
+
<View className="w-full gap-y-2">
|
|
194
|
+
<ThemedText className="text-sm text-muted-foreground">
|
|
195
|
+
{t('settings.account.verifyEmailDescription')}
|
|
196
|
+
</ThemedText>
|
|
197
|
+
<Button
|
|
198
|
+
variant="outline"
|
|
199
|
+
onPress={() => void handleVerifyEmail()}
|
|
200
|
+
disabled={verifying}
|
|
201
|
+
>
|
|
202
|
+
{verifying ? (
|
|
203
|
+
<ActivityIndicator size={16} />
|
|
204
|
+
) : (
|
|
205
|
+
<ThemedText className="text-sm">
|
|
206
|
+
{t('settings.account.verifyEmailButton')}
|
|
207
|
+
</ThemedText>
|
|
208
|
+
)}
|
|
209
|
+
</Button>
|
|
210
|
+
</View>
|
|
211
|
+
) : null}
|
|
168
212
|
|
|
169
213
|
<View className="relative w-full">
|
|
170
214
|
<Button
|