@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
@@ -0,0 +1,62 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { View } from 'react-native';
3
+ import { BottomSheetModal } from '@gorhom/bottom-sheet';
4
+ import { useTranslation } from 'react-i18next';
5
+ import type { PublicPost } from '@openpeepshq/common/types';
6
+ import { waitlistOfferWindowMs } from '@openpeepshq/common/lib';
7
+ import { BaseSheet, SheetFooter } from '../../custom/modals/common';
8
+ import { ThemedText } from '../../ui/themed-text';
9
+ import { bottomSheetClose } from '../../../lib/bottom-sheet-ref';
10
+
11
+ export interface EventWaitlistJoinDialogProps {
12
+ post: PublicPost;
13
+ error?: string | null;
14
+ isLoading?: boolean;
15
+ onClose: () => void;
16
+ onConfirm: () => void | Promise<void>;
17
+ }
18
+
19
+ export const EventWaitlistJoinDialog = forwardRef<
20
+ BottomSheetModal,
21
+ EventWaitlistJoinDialogProps
22
+ >(({ post, error, isLoading, onClose, onConfirm }, ref) => {
23
+ const { t } = useTranslation();
24
+ const event = post.data?.type === 'event' ? post.data : undefined;
25
+ const minutes = event
26
+ ? Math.round(waitlistOfferWindowMs(event) / 60_000)
27
+ : 60;
28
+
29
+ return (
30
+ <BaseSheet ref={ref} snapPoints={['40%']} onDismiss={onClose}>
31
+ <View className="flex-1 gap-y-3 p-4">
32
+ <ThemedText className="text-center text-lg">
33
+ {t('events.rsvp.waitlistConfirmTitle')}
34
+ </ThemedText>
35
+ <ThemedText className="text-center text-sm">
36
+ {t('events.rsvp.atCapacity')}
37
+ </ThemedText>
38
+ <ThemedText className="text-center text-sm text-muted-foreground">
39
+ {t('events.rsvp.waitlistConfirmBody', { minutes })}
40
+ </ThemedText>
41
+ {error ? (
42
+ <ThemedText className="text-center text-sm text-destructive">
43
+ {error}
44
+ </ThemedText>
45
+ ) : null}
46
+ <SheetFooter
47
+ onCancel={() => {
48
+ bottomSheetClose(ref);
49
+ onClose();
50
+ }}
51
+ onConfirm={onConfirm}
52
+ confirmText={t('events.rsvp.joinWaitlist')}
53
+ cancelText={t('events.rsvp.scope.cancel')}
54
+ disabled={isLoading}
55
+ isLoading={isLoading}
56
+ />
57
+ </View>
58
+ </BaseSheet>
59
+ );
60
+ });
61
+
62
+ EventWaitlistJoinDialog.displayName = 'EventWaitlistJoinDialog';
@@ -26,19 +26,19 @@ export const PollContent = ({ post }: Props) => {
26
26
 
27
27
  const votePoll = openpeepsApi.voteOnPostAction({ id: post!.id });
28
28
 
29
- let hasPollEnded: boolean = !!(
29
+ const hasPollEnded: boolean = !!(
30
30
  post?.data?.type === 'question' &&
31
31
  post.data.expiresAt &&
32
32
  isPast(post.data.expiresAt)
33
33
  );
34
34
 
35
- let hasVoted: boolean = !!(
35
+ const hasVoted: boolean = !!(
36
36
  currentProfile &&
37
37
  (votes.find((v) => v?.profile?.id === currentProfile.id)?.selection
38
38
  ?.length ?? 0) > 0
39
39
  );
40
40
 
41
- let canVote: boolean = !!(currentProfile && !hasPollEnded && !hasVoted);
41
+ const canVote: boolean = !!(currentProfile && !hasPollEnded && !hasVoted);
42
42
 
43
43
  const handleVote = async () => {
44
44
  if (post?.data?.type !== 'question') {
@@ -191,15 +191,15 @@ export const PollContent = ({ post }: Props) => {
191
191
 
192
192
  <View className="mt-4 flex-row items-center gap-3">
193
193
  <Text className="text-sm text-muted-foreground">
194
- {`${votes.length || 0} ${t('posts.vote.count')}`}
194
+ {t('posts.vote.count', { count: votes.length || 0 })}
195
195
  </Text>
196
196
  {post?.data?.type === 'question' && post.data.expiresAt && (
197
197
  <Text className="text-sm text-muted-foreground">
198
198
  {hasPollEnded
199
199
  ? t('posts.poll.ended')
200
- : `${formatDistanceToNow(post.data.expiresAt)} ${t(
201
- 'posts.poll.timeLeft'
202
- )}`}
200
+ : t('posts.poll.timeLeft', {
201
+ time: formatDistanceToNow(post.data.expiresAt),
202
+ })}
203
203
  </Text>
204
204
  )}
205
205
  {hasVoted && !hasPollEnded && (
@@ -1,11 +1,18 @@
1
1
  import React from 'react';
2
- import { View } from 'react-native';
2
+ import { Pressable, View } from 'react-native';
3
+ import { cn } from '../../../lib/utils';
3
4
  import { Button } from '../../ui/button';
4
5
  import { ThemedText } from '../../ui/themed-text';
5
- import { Repeat2Icon, ReplyIcon, ThumbsUpIcon } from '../../icons/index';
6
+ import {
7
+ Repeat2Icon,
8
+ ReplyIcon,
9
+ ShareIcon,
10
+ ThumbsUpIcon,
11
+ } from '../../icons/index';
6
12
  import { type PublicPost } from '@openpeepshq/common';
7
13
  import { useTranslation } from 'react-i18next';
8
14
  import { useFeedPostActions } from '@openpeepshq/react';
15
+ import { ShareMenu } from './ShareMenu';
9
16
 
10
17
  interface PostActionsProps {
11
18
  post: PublicPost;
@@ -16,7 +23,7 @@ interface PostActionsProps {
16
23
  export const PostActions = ({
17
24
  post,
18
25
  previewMode = false,
19
- compact = false,
26
+ compact: _compact = false,
20
27
  }: PostActionsProps) => {
21
28
  const { t } = useTranslation();
22
29
  const {
@@ -31,51 +38,110 @@ export const PostActions = ({
31
38
  toggleReaction,
32
39
  } = useFeedPostActions(post);
33
40
 
34
- if (!me) {
35
- return null;
36
- }
41
+ const replyActive = !previewMode && canReply;
42
+ const repostActive = !previewMode && canRepost;
43
+ const reactActive = !previewMode && canReact;
44
+ const shareActive = !previewMode;
37
45
 
38
46
  const actionClass = 'flex-1 flex-row items-center gap-2 native:p-2';
47
+ const shareClass = 'flex-row items-center gap-2 native:p-2';
48
+ const shareLabel = t('posts.footer.share');
49
+
50
+ // Button fades every disabled control. These should read as plain text.
51
+ const idleClass =
52
+ 'opacity-100 web:hover:bg-transparent active:bg-transparent';
53
+
54
+ const iconClass = (active: boolean, highlighted: boolean) =>
55
+ !active
56
+ ? 'text-muted-foreground'
57
+ : highlighted
58
+ ? 'text-primary'
59
+ : 'text-foreground';
60
+
61
+ const labelClass = (active: boolean, highlighted: boolean) =>
62
+ cn(
63
+ 'text-sm',
64
+ !active && 'text-muted-foreground',
65
+ active && highlighted && 'text-primary'
66
+ );
67
+
68
+ const shareIconClass = iconClass(shareActive, false);
69
+ const shareTextClass = labelClass(shareActive, false);
70
+
71
+ const shareButton = shareActive ? (
72
+ <ShareMenu
73
+ post={post}
74
+ menuButton={
75
+ <Button variant="ghost" className={shareClass}>
76
+ <ShareIcon size={16} className={shareIconClass} />
77
+ <ThemedText className={shareTextClass}>{shareLabel}</ThemedText>
78
+ </Button>
79
+ }
80
+ />
81
+ ) : (
82
+ <Button variant="ghost" disabled className={cn(shareClass, idleClass)}>
83
+ <ShareIcon size={16} className={shareIconClass} />
84
+ <ThemedText className={shareTextClass}>{shareLabel}</ThemedText>
85
+ </Button>
86
+ );
87
+
88
+ if (!me) {
89
+ return (
90
+ <View className="w-full flex-row items-center justify-end py-2">
91
+ {shareButton}
92
+ </View>
93
+ );
94
+ }
39
95
 
40
96
  return (
41
- <View className="w-full flex-row items-center py-2">
97
+ // A disabled control does not take the touch, so the feed card would open
98
+ // the post. This row absorbs that tap and still yields to scrolling.
99
+ <Pressable
100
+ accessible={false}
101
+ onPress={() => {}}
102
+ className="w-full flex-row items-center py-2"
103
+ >
42
104
  <Button
43
105
  variant="ghost"
44
- disabled={previewMode || !canReply}
106
+ disabled={!replyActive}
45
107
  onPress={() => reply()}
46
- className={`${actionClass} justify-start`}
108
+ className={cn(actionClass, 'justify-start', !replyActive && idleClass)}
47
109
  >
48
- <ReplyIcon size={16} className="text-foreground" />
49
- <ThemedText className="text-sm">{t('posts.footer.reply')}</ThemedText>
110
+ <ReplyIcon size={16} className={iconClass(replyActive, false)} />
111
+ <ThemedText className={labelClass(replyActive, false)}>
112
+ {t('posts.footer.reply')}
113
+ </ThemedText>
50
114
  </Button>
51
115
  <Button
52
116
  variant="ghost"
53
- disabled={previewMode || !canRepost}
117
+ disabled={!repostActive}
54
118
  onPress={() => void toggleRepost()}
55
- className={`${actionClass} justify-center`}
119
+ className={cn(
120
+ actionClass,
121
+ 'justify-center',
122
+ !repostActive && idleClass
123
+ )}
56
124
  >
57
125
  <Repeat2Icon
58
126
  size={16}
59
- className={myRepost ? 'text-primary' : 'text-foreground'}
127
+ className={iconClass(repostActive, !!myRepost)}
60
128
  />
61
- <ThemedText className={`text-sm ${myRepost ? 'text-primary' : ''}`}>
129
+ <ThemedText className={labelClass(repostActive, !!myRepost)}>
62
130
  {t('posts.footer.repost')}
63
131
  </ThemedText>
64
132
  </Button>
65
133
  <Button
66
134
  variant="ghost"
67
- disabled={previewMode || !canReact}
135
+ disabled={!reactActive}
68
136
  onPress={() => void toggleReaction()}
69
- className={`${actionClass} justify-end`}
137
+ className={cn(actionClass, 'justify-end', !reactActive && idleClass)}
70
138
  >
71
- <ThumbsUpIcon
72
- size={16}
73
- className={iReacted ? 'text-primary' : 'text-foreground'}
74
- />
75
- <ThemedText className={`text-sm ${iReacted ? 'text-primary' : ''}`}>
139
+ <ThumbsUpIcon size={16} className={iconClass(reactActive, iReacted)} />
140
+ <ThemedText className={labelClass(reactActive, iReacted)}>
76
141
  {t('posts.footer.like')}
77
142
  </ThemedText>
78
143
  </Button>
79
- </View>
144
+ <View className="flex-1 items-end">{shareButton}</View>
145
+ </Pressable>
80
146
  );
81
147
  };
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
7
7
  import { useNavigation } from '@react-navigation/native';
8
8
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
9
9
  import type { PublicPost } from '@openpeepshq/common';
10
- import { useShareMenu } from '@openpeepshq/react';
10
+ import { postPublicPath, useShareMenu } from '@openpeepshq/react';
11
11
  import {
12
12
  CalendarIcon,
13
13
  CopyIcon,
@@ -35,7 +35,7 @@ export const ShareMenu = ({ post, menuButton }: ShareMenuProps) => {
35
35
  const navigation =
36
36
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
37
37
  const setDraftMessage = useNewConversationStore((s) => s.setContt);
38
- const postUrl = `${BASE_URL}/posts/${post.id}`;
38
+ const postUrl = `${BASE_URL}${postPublicPath(post)}`;
39
39
  const { signedIn, isEvent, repost, eventIcsFile } = useShareMenu(
40
40
  post,
41
41
  postUrl
@@ -27,6 +27,7 @@ export const DescriptionEditModal = forwardRef<
27
27
  } catch (error) {
28
28
  console.error('Failed to Save', error);
29
29
  } finally {
30
+ // swallowed
30
31
  }
31
32
  };
32
33
 
@@ -1,10 +1,13 @@
1
- import React, { useRef } from 'react';
1
+ import React, { useRef, useState } from 'react';
2
2
  import { Pressable, View } from 'react-native';
3
3
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import timezones from 'timezones-list';
6
6
  import type { PostCreationData } from '@openpeepshq/common';
7
- import { parseEventMaxAttendeesInput } from '@openpeepshq/common/lib';
7
+ import {
8
+ parseEventMaxAttendeesInput,
9
+ parseEventWaitlistOfferMinutesInput,
10
+ } from '@openpeepshq/common/lib';
8
11
  import {
9
12
  EVENT_WEEKDAYS,
10
13
  useEventForm,
@@ -86,6 +89,7 @@ export const EventForm = ({
86
89
  occurrenceEdit = false,
87
90
  }: EventFormProps) => {
88
91
  const { t } = useTranslation();
92
+ const [endBeforeStart, setEndBeforeStart] = useState(false);
89
93
  const startSheetRef = useRef<BottomSheetModal>(null);
90
94
  const endSheetRef = useRef<BottomSheetModal>(null);
91
95
  const untilSheetRef = useRef<BottomSheetModal>(null);
@@ -173,13 +177,22 @@ export const EventForm = ({
173
177
  </Pressable>
174
178
 
175
179
  {showEndDate ? (
176
- <PickerField
177
- label={t('events.form.endDate')}
178
- value={formatDate(event.end, eventTimeZone)}
179
- placeholder={t('events.form.endDate')}
180
- icon={<CalendarIcon className="text-muted-foreground" size={18} />}
181
- onPress={() => bottomSheetPresent(endSheetRef)}
182
- />
180
+ <>
181
+ <PickerField
182
+ label={t('events.form.endDate')}
183
+ value={formatDate(event.end, eventTimeZone)}
184
+ placeholder={t('events.form.endDate')}
185
+ icon={
186
+ <CalendarIcon className="text-muted-foreground" size={18} />
187
+ }
188
+ onPress={() => bottomSheetPresent(endSheetRef)}
189
+ />
190
+ {endBeforeStart ? (
191
+ <ThemedText className="text-sm text-destructive">
192
+ {t('events.form.endBeforeStart')}
193
+ </ThemedText>
194
+ ) : null}
195
+ </>
183
196
  ) : null}
184
197
 
185
198
  <PickerField
@@ -381,6 +394,26 @@ export const EventForm = ({
381
394
  ) : null}
382
395
  </View>
383
396
  </View>
397
+ {event.maxAttendees != null ? (
398
+ <View className="gap-y-1">
399
+ <Label nativeID="event-waitlist-minutes">
400
+ {t('events.form.waitlistOfferMinutes')}
401
+ </Label>
402
+ <ThemedText className="text-sm text-muted-foreground">
403
+ {t('events.form.waitlistOfferMinutesDescription')}
404
+ </ThemedText>
405
+ <Input
406
+ keyboardType="numeric"
407
+ value={event.waitlistOfferMinutes?.toString() ?? ''}
408
+ onChangeText={(value) =>
409
+ patchEvent({
410
+ waitlistOfferMinutes:
411
+ parseEventWaitlistOfferMinutesInput(value),
412
+ })
413
+ }
414
+ />
415
+ </View>
416
+ ) : null}
384
417
  </View>
385
418
 
386
419
  <DateSheet
@@ -394,7 +427,14 @@ export const EventForm = ({
394
427
  ref={endSheetRef}
395
428
  value={event.end}
396
429
  timeZone={eventTimeZone}
397
- onChange={(end) => patchEvent({ end })}
430
+ onChange={(end) => {
431
+ if (end && event.start && new Date(end) <= new Date(event.start)) {
432
+ setEndBeforeStart(true);
433
+ return;
434
+ }
435
+ setEndBeforeStart(false);
436
+ patchEvent({ end });
437
+ }}
398
438
  onClose={() => bottomSheetClose(endSheetRef)}
399
439
  />
400
440
  <DateSheet
@@ -8,7 +8,12 @@ import type {
8
8
  ResourceKind,
9
9
  ResourcePost,
10
10
  } from '@openpeepshq/common';
11
- import { RESOURCE_KINDS, normalizeResourceTags } from '@openpeepshq/common/lib';
11
+ import {
12
+ RESOURCE_KINDS,
13
+ RESOURCE_TITLE_MAX_LENGTH,
14
+ normalizeResourceTags,
15
+ resourceFormIssues,
16
+ } from '@openpeepshq/common/lib';
12
17
  import { applyAudienceSetting, useCurrentProfile } from '@openpeepshq/react';
13
18
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
14
19
  import {
@@ -28,12 +33,15 @@ export interface ResourceFormProps {
28
33
  postData: PostCreationData;
29
34
  onChange: (data: PostCreationData) => void;
30
35
  isEdit?: boolean;
36
+ /** Member can post this resource only to a group. */
37
+ groupOnly?: boolean;
31
38
  }
32
39
 
33
40
  export const ResourceForm = ({
34
41
  postData,
35
42
  onChange,
36
43
  isEdit = false,
44
+ groupOnly = false,
37
45
  }: ResourceFormProps) => {
38
46
  const { t } = useTranslation();
39
47
  const me = useCurrentProfile();
@@ -66,6 +74,26 @@ export const ResourceForm = ({
66
74
  setTagDraft('');
67
75
  };
68
76
 
77
+ const issues = resourceFormIssues({
78
+ title: resource.title,
79
+ resourceKind: resource.resourceKind,
80
+ url: resource.url,
81
+ attachments: resource.attachments,
82
+ visibility: postData.visibility,
83
+ audience: postData.audience,
84
+ groupId: postData.groupId,
85
+ });
86
+ const titleMissing = issues.includes('title');
87
+ const titleTooLong = issues.includes('titleLength');
88
+ const urlIssue = issues.includes('url');
89
+ const urlInvalid = urlIssue && Boolean(resource.url?.trim());
90
+ const mediaMissing = issues.includes('media');
91
+ const audienceMissing = issues.includes('audience');
92
+ const groupMissing = issues.includes('group');
93
+ const urlMessage = t('resources.validation.url', {
94
+ defaultValue: 'Enter a real link, like https://example.com',
95
+ });
96
+
69
97
  const openMedia = () => {
70
98
  if (resource.resourceKind === 'gallery') imageRef.current?.present();
71
99
  else if (resource.resourceKind === 'video') videoRef.current?.present();
@@ -77,14 +105,49 @@ export const ResourceForm = ({
77
105
  <View>
78
106
  <View className="mt-4 gap-y-4 px-3">
79
107
  <ThemedText className="text-sm font-medium">
80
- {t('resources.form.name', {
81
- defaultValue: 'Title',
108
+ {t('resources.form.nameRequired', {
109
+ defaultValue: 'Title (Required)',
82
110
  })}
83
111
  </ThemedText>
84
112
  <Input
85
113
  value={resource.title}
114
+ maxLength={RESOURCE_TITLE_MAX_LENGTH}
86
115
  onChangeText={(title) => patchResource({ title })}
116
+ accessibilityHint={
117
+ titleMissing
118
+ ? t('resources.validation.titleRequired', {
119
+ defaultValue: 'Title is required',
120
+ })
121
+ : titleTooLong
122
+ ? t('resources.validation.titleTooLong', {
123
+ defaultValue: 'Title must be 200 characters or fewer',
124
+ })
125
+ : undefined
126
+ }
87
127
  />
128
+ {titleMissing ? (
129
+ <ThemedText className="text-sm text-muted-foreground">
130
+ {t('resources.validation.titleRequired', {
131
+ defaultValue: 'Title is required',
132
+ })}
133
+ </ThemedText>
134
+ ) : null}
135
+ {titleTooLong ? (
136
+ <ThemedText className="text-sm text-destructive">
137
+ {t('resources.validation.titleTooLong', {
138
+ defaultValue: 'Title must be 200 characters or fewer',
139
+ })}
140
+ </ThemedText>
141
+ ) : null}
142
+ <ThemedText
143
+ className={
144
+ titleTooLong
145
+ ? 'px-2 text-right text-sm text-destructive'
146
+ : 'px-2 text-right text-sm'
147
+ }
148
+ >
149
+ {resource.title.length} / {RESOURCE_TITLE_MAX_LENGTH}
150
+ </ThemedText>
88
151
 
89
152
  <ThemedText className="text-sm font-medium">
90
153
  {t('resources.form.kind', {
@@ -118,15 +181,33 @@ export const ResourceForm = ({
118
181
  {resource.resourceKind === 'link' ? (
119
182
  <>
120
183
  <ThemedText className="text-sm font-medium">
121
- {t('resources.form.url', {
122
- defaultValue: 'URL',
184
+ {t('resources.form.urlRequired', {
185
+ defaultValue: 'URL (Required)',
123
186
  })}
124
187
  </ThemedText>
125
188
  <Input
126
189
  value={resource.url ?? ''}
127
190
  onChangeText={(url) => patchResource({ url })}
128
191
  autoCapitalize="none"
192
+ autoCorrect={false}
193
+ keyboardType="url"
194
+ placeholder={t('resources.form.urlPlaceholder', {
195
+ defaultValue: 'https://example.com',
196
+ })}
197
+ className={urlInvalid ? 'border-destructive' : undefined}
198
+ accessibilityHint={urlIssue ? urlMessage : undefined}
129
199
  />
200
+ {urlIssue ? (
201
+ <ThemedText
202
+ className={
203
+ urlInvalid
204
+ ? 'text-sm text-destructive'
205
+ : 'text-sm text-muted-foreground'
206
+ }
207
+ >
208
+ {urlMessage}
209
+ </ThemedText>
210
+ ) : null}
130
211
  </>
131
212
  ) : (
132
213
  <>
@@ -155,6 +236,13 @@ export const ResourceForm = ({
155
236
  })
156
237
  }
157
238
  />
239
+ {mediaMissing ? (
240
+ <ThemedText className="text-sm text-muted-foreground">
241
+ {t('resources.validation.mediaRequired', {
242
+ defaultValue: 'Add the media or link this resource needs',
243
+ })}
244
+ </ThemedText>
245
+ ) : null}
158
246
  </>
159
247
  )}
160
248
 
@@ -231,6 +319,28 @@ export const ResourceForm = ({
231
319
  disabled={isEdit}
232
320
  showDirect
233
321
  />
322
+ {!isEdit && groupOnly ? (
323
+ <ThemedText className="text-sm text-muted-foreground">
324
+ {t('resources.form.groupOnly', {
325
+ defaultValue: 'You can only share resources with a group.',
326
+ })}
327
+ </ThemedText>
328
+ ) : null}
329
+ {groupMissing ? (
330
+ <ThemedText className="text-sm text-muted-foreground">
331
+ {t('resources.validation.groupRequired', {
332
+ defaultValue: 'Choose a group before creating this resource.',
333
+ })}
334
+ </ThemedText>
335
+ ) : null}
336
+ {audienceMissing ? (
337
+ <ThemedText className="text-sm text-muted-foreground">
338
+ {t('resources.validation.directAudience', {
339
+ defaultValue:
340
+ 'Choose at least one recipient for a direct resource.',
341
+ })}
342
+ </ThemedText>
343
+ ) : null}
234
344
  </View>
235
345
  <ImagePickerSheet ref={imageRef} onSelect={addAttachments} />
236
346
  <VideoPickerSheet ref={videoRef} onSelect={addAttachments} />
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import type { Article, PublicPost } from '@openpeepshq/common/types';
3
3
  import { View } from 'react-native';
4
4
  import { ThemedText } from '../../ui/themed-text';
5
- import { OpenpeepsMarkdown } from '../../markdown/index';
6
5
  import { useMemo } from 'react';
7
6
  import { firstNWords } from '@openpeepshq/common';
8
7
  import { Button } from '../../ui/button';
@@ -12,6 +11,7 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
12
11
  import { MainStackParamList } from '../../navigation/types/index';
13
12
  import { useTranslation } from 'react-i18next';
14
13
  import { CachedImage } from '../../custom/common/index';
14
+ import { TruncatedMarkdown } from '../TruncatedMarkdown';
15
15
 
16
16
  export interface FeedArticleProps {
17
17
  post: PublicPost;
@@ -40,7 +40,11 @@ export const FeedArticle = ({ post }: FeedArticleProps) => {
40
40
  <ThemedText className="text-xl font-bold text-foreground">
41
41
  {article.title}
42
42
  </ThemedText>
43
- <OpenpeepsMarkdown source={previewContent} linkPreviewMode="none" />
43
+ <TruncatedMarkdown
44
+ source={article.content ?? ''}
45
+ snippet={previewContent}
46
+ interactive={false}
47
+ />
44
48
  <View className="w-full flex flex-row justify-end">
45
49
  <Button
46
50
  onPress={() => navigation.navigate('Post', { id: post.id })}
@@ -14,7 +14,10 @@ export interface FeedPollProps {
14
14
  interactive?: boolean;
15
15
  }
16
16
 
17
- export const FeedPoll = ({ post, interactive = true }: FeedPollProps) =>
17
+ export const FeedPoll = ({
18
+ post,
19
+ interactive: _interactive = true,
20
+ }: FeedPollProps) =>
18
21
  post?.data?.type === 'question' ? (
19
22
  <View>
20
23
  <Attachments {...{ post }} />