@openpeepshq/rn-components 0.11.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/package.json +2 -2
  2. package/src/components/custom/modals/common/sheet-footer.tsx +1 -1
  3. package/src/components/custom/modals/media/alt-text-sheet.tsx +1 -1
  4. package/src/components/custom/modals/settings/edit-notifications-sheet.tsx +1 -1
  5. package/src/components/groups/ChangeGroupRolesModal.tsx +1 -1
  6. package/src/components/groups/ConfirmGroupExitModal.tsx +1 -1
  7. package/src/components/groups/ConfirmMemberRemovalModal.tsx +2 -2
  8. package/src/components/groups/DeleteGroupModal.tsx +2 -2
  9. package/src/components/groups/GroupForm.tsx +2 -2
  10. package/src/components/groups/GroupNameFromId.tsx +1 -1
  11. package/src/components/groups/GroupNotificationSettingsModal.tsx +2 -2
  12. package/src/components/groups/JoinGroupButton.tsx +1 -1
  13. package/src/components/jams/JamFooter.tsx +1 -1
  14. package/src/components/jams/JamGuestForm.tsx +1 -3
  15. package/src/components/jams/LeaveCloseButton.tsx +1 -1
  16. package/src/components/markdown/MarkdownOverlay.tsx +1 -1
  17. package/src/components/post/pieces/EventRsvpList.tsx +1 -1
  18. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +2 -2
  19. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +1 -1
  20. package/src/components/post/pieces/GalleryModal.tsx +1 -1
  21. package/src/components/post/pieces/modals/CancelEventModal.tsx +1 -1
  22. package/src/components/post/pieces/modals/DeleteEventModal.tsx +1 -1
  23. package/src/components/post/post-form/ComposeAttachments.tsx +1 -1
  24. package/src/components/post/post-form/DateSheet.tsx +5 -3
  25. package/src/components/post/post-form/EventForm.tsx +7 -12
  26. package/src/components/post/post-form/VisibilitySheet.tsx +1 -1
  27. package/src/components/post/types/event/FullEvent.tsx +5 -3
  28. package/src/components/profile/FollowUnfollowButton.tsx +1 -1
  29. package/src/components/profile/ProfileActivitySummary.tsx +4 -4
  30. package/src/components/profile/ProfileBadge.tsx +1 -1
  31. package/src/components/profile/ProfilePageAction.tsx +1 -1
  32. package/src/components/profile/ProfilePostsAndReplies.tsx +2 -2
  33. package/src/components/profile/ReportProfileOrPostModal.tsx +1 -1
  34. package/src/components/resources/ResourceCard.test.tsx +262 -0
  35. package/src/components/resources/ResourceCard.tsx +4 -1
  36. package/src/lib/media-permissions.ts +1 -1
  37. package/src/pages/Members.tsx +1 -1
  38. package/src/pages/auth/Login.tsx +1 -1
  39. package/src/pages/auth/Register.tsx +3 -3
  40. package/src/pages/conversations/Show.tsx +1 -1
  41. package/src/pages/events/Index.tsx +1 -1
  42. package/src/pages/feeds/Bookmarks.tsx +1 -1
  43. package/src/pages/groups/EditInfo.tsx +1 -1
  44. package/src/pages/groups/EditRoles.tsx +1 -1
  45. package/src/pages/groups/Index.tsx +1 -1
  46. package/src/pages/groups/Info.tsx +1 -1
  47. package/src/pages/groups/Members.tsx +2 -2
  48. package/src/pages/groups/New.tsx +1 -1
  49. package/src/pages/groups/Show.tsx +3 -3
  50. package/src/pages/settings/AccessTokens.tsx +4 -6
  51. package/src/pages/settings/Account.tsx +4 -2
  52. package/src/pages/settings/Feed.tsx +1 -1
  53. package/src/pages/settings/Language.tsx +1 -1
  54. package/src/pages/settings/PushEnabledDevices.tsx +3 -4
  55. package/src/pages/settings/Theme.tsx +1 -1
  56. package/src/pages/settings/Timezone.tsx +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/rn-components",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./src/index.ts",
@@ -143,7 +143,7 @@
143
143
  "validator": "^13.15.23",
144
144
  "zustand": "^5.0.3",
145
145
  "@openpeepshq/common": "^0.6.1",
146
- "@openpeepshq/react": "^0.10.0"
146
+ "@openpeepshq/react": "^0.11.0"
147
147
  },
148
148
  "devDependencies": {
149
149
  "@babel/core": "^7.26.7",
@@ -40,7 +40,7 @@ export const SheetFooter: React.FC<SheetFooterProps> = ({
40
40
  <View className="flex-row justify-between px-5 gap-4 mt-auto pt-4 mb-10">
41
41
  <Button variant={variant} className="flex-1" onPress={onCancel}>
42
42
  <ThemedText className="font-semibold">
43
- {cancelText || t('common.form.cancel')}
43
+ {cancelText || t('common.actions.cancel')}
44
44
  </ThemedText>
45
45
  </Button>
46
46
  <Button
@@ -56,7 +56,7 @@ export const AltSheet = forwardRef<BottomSheetModal, AltSheetProps>(
56
56
  <ThemedText className="text-sm font-medium mb-1">
57
57
  {isDocument
58
58
  ? t('form.uploadEditModal.description.altText')
59
- : t('media.image.altTextLabel')}
59
+ : t('common.labels.altText')}
60
60
  </ThemedText>
61
61
  <TextInput
62
62
  placeholder={
@@ -174,7 +174,7 @@ export const EditNotificationsSheet = forwardRef<
174
174
  onConfirm={save}
175
175
  disabled={isLoading}
176
176
  confirmText={
177
- isLoading ? t('common.form.loading') : t('common.form.save')
177
+ isLoading ? t('common.states.loading') : t('common.actions.save')
178
178
  }
179
179
  variant="destructive"
180
180
  />
@@ -110,7 +110,7 @@ export const ChangeGroupRolesModal = ({
110
110
  ) : null}
111
111
  <SheetFooter
112
112
  onCancel={onClose}
113
- cancelText={t('common.cancel')}
113
+ cancelText={t('common.actions.cancel')}
114
114
  onConfirm={() => void submit()}
115
115
  confirmText={t('groups.changeRoles.confirm')}
116
116
  disabled={submitting}
@@ -54,7 +54,7 @@ export const ConfirmGroupExitModal = ({
54
54
  ) : null}
55
55
  <SheetFooter
56
56
  onCancel={onClose}
57
- cancelText={t('common.cancel')}
57
+ cancelText={t('common.actions.cancel')}
58
58
  onConfirm={() => void submit()}
59
59
  confirmText={t('groups.modals.confirmExit.leave')}
60
60
  confirmVariant="destructive"
@@ -57,12 +57,12 @@ export const ConfirmMemberRemovalModal = ({
57
57
  ) : null}
58
58
  <SheetFooter
59
59
  onCancel={onClose}
60
- cancelText={t('common.cancel')}
60
+ cancelText={t('common.actions.cancel')}
61
61
  onConfirm={() => void submit()}
62
62
  confirmText={
63
63
  submitting
64
64
  ? t('groups.removeMember.loading')
65
- : t('groups.removeMember.confirm')
65
+ : t('common.actions.remove')
66
66
  }
67
67
  confirmVariant="destructive"
68
68
  disabled={submitting}
@@ -52,12 +52,12 @@ export const DeleteGroupModal = ({ group, onClose }: DeleteGroupModalProps) => {
52
52
  ) : null}
53
53
  <SheetFooter
54
54
  onCancel={onClose}
55
- cancelText={t('groups.delete.cancel')}
55
+ cancelText={t('common.actions.cancel')}
56
56
  onConfirm={() => void submit()}
57
57
  confirmText={
58
58
  submitting
59
59
  ? t('groups.delete.deleting')
60
- : t('groups.delete.deleteButton')
60
+ : t('common.actions.delete')
61
61
  }
62
62
  confirmVariant="destructive"
63
63
  disabled={submitting}
@@ -80,7 +80,7 @@ export const GroupForm = ({
80
80
  {!isEdit ? (
81
81
  <View className="gap-y-2 px-1">
82
82
  <Label nativeID="handle">
83
- {t('groups.handle.title', { defaultValue: 'Handle' })}
83
+ {t('common.labels.handle', { defaultValue: 'Handle' })}
84
84
  </Label>
85
85
  <Input
86
86
  value={groupData.handle ?? ''}
@@ -101,7 +101,7 @@ export const GroupForm = ({
101
101
 
102
102
  <View className="gap-y-2 px-1">
103
103
  <Label nativeID="description">
104
- {t('groups.description.title', { defaultValue: 'Description' })}
104
+ {t('common.labels.description', { defaultValue: 'Description' })}
105
105
  </Label>
106
106
  <Textarea
107
107
  value={groupData.description ?? ''}
@@ -11,7 +11,7 @@ export const GroupNameFromId = ({ groupId }: { groupId: string }) => {
11
11
  <ThemedText>
12
12
  {group
13
13
  ? group.displayName || `@${group?.handle}`
14
- : t('common.form.loading')}
14
+ : t('common.states.loading')}
15
15
  </ThemedText>
16
16
  );
17
17
  };
@@ -100,9 +100,9 @@ export const GroupNotificationSettingsModal = ({
100
100
  ) : null}
101
101
  <SheetFooter
102
102
  onCancel={onClose}
103
- cancelText={t('common.cancel')}
103
+ cancelText={t('common.actions.cancel')}
104
104
  onConfirm={() => void onSave()}
105
- confirmText={saving ? t('common.saving') : t('common.save')}
105
+ confirmText={saving ? t('common.saving') : t('common.actions.save')}
106
106
  disabled={saving || !ready}
107
107
  isLoading={saving}
108
108
  />
@@ -35,7 +35,7 @@ export const JoinGroupButton = ({ group, onJoined }: JoinGroupButtonProps) => {
35
35
  return (
36
36
  <Button variant="outline" disabled={submitting} onPress={onPress}>
37
37
  <ThemedText>
38
- {submitting ? t('common.form.loading') : t('groups.join.submit')}
38
+ {submitting ? t('common.states.loading') : t('groups.join.submit')}
39
39
  </ThemedText>
40
40
  </Button>
41
41
  );
@@ -48,7 +48,7 @@ export const useFooterControls = () => {
48
48
  new Promise<boolean>((resolve) => {
49
49
  Alert.alert('', t('jams.recording.stopConfirm'), [
50
50
  {
51
- text: t('common.cancel'),
51
+ text: t('common.actions.cancel'),
52
52
  style: 'cancel',
53
53
  onPress: () => resolve(false),
54
54
  },
@@ -70,9 +70,7 @@ export const JamGuestForm = () => {
70
70
  </View>
71
71
 
72
72
  <View className="gap-2">
73
- <Label nativeID="guest-email">
74
- {t('jams.lobby.guestEmailLabel')}
75
- </Label>
73
+ <Label nativeID="guest-email">{t('common.labels.email')}</Label>
76
74
  <Input
77
75
  aria-labelledby="guest-email"
78
76
  value={guestData.email}
@@ -39,7 +39,7 @@ export const LeaveCloseButton = () => {
39
39
  style: 'destructive',
40
40
  onPress: () => void handleLeave(),
41
41
  },
42
- { style: 'cancel', text: t('common.cancel') },
42
+ { style: 'cancel', text: t('common.actions.cancel') },
43
43
  ]);
44
44
  setConfirmOpen(false);
45
45
  }, [confirmOpen, handleClose, handleLeave, setConfirmOpen, t]);
@@ -61,7 +61,7 @@ export const MarkdownOverlay = ({
61
61
  <View className="mt-4 flex justify-end">
62
62
  <Button onPress={() => setOpen(false)}>
63
63
  <ThemedText>
64
- {t('posts.truncatedMarkdown.close', {
64
+ {t('common.actions.close', {
65
65
  defaultValue: 'Close',
66
66
  })}
67
67
  </ThemedText>
@@ -309,7 +309,7 @@ const RsvpGroup: React.FC<{
309
309
  }
310
310
  >
311
311
  <ThemedText className="text-destructive">
312
- {t('events.rsvp.removeAttendee')}
312
+ {t('common.actions.remove')}
313
313
  </ThemedText>
314
314
  </Button>
315
315
  )
@@ -234,9 +234,9 @@ export const EventRsvpScopeDialog = forwardRef<
234
234
  confirmText={
235
235
  joiningWaitlist
236
236
  ? t('events.rsvp.joinWaitlist')
237
- : t('events.rsvp.scope.confirm')
237
+ : t('common.actions.confirm')
238
238
  }
239
- cancelText={t('events.rsvp.scope.cancel')}
239
+ cancelText={t('common.actions.cancel')}
240
240
  disabled={confirmDisabled}
241
241
  isLoading={isLoading}
242
242
  />
@@ -50,7 +50,7 @@ export const EventWaitlistJoinDialog = forwardRef<
50
50
  }}
51
51
  onConfirm={onConfirm}
52
52
  confirmText={t('events.rsvp.joinWaitlist')}
53
- cancelText={t('events.rsvp.scope.cancel')}
53
+ cancelText={t('common.actions.cancel')}
54
54
  disabled={isLoading}
55
55
  isLoading={isLoading}
56
56
  />
@@ -47,7 +47,7 @@ export const GalleryModal = ({
47
47
  <View className="flex-1 items-center justify-center bg-black/80">
48
48
  <Pressable
49
49
  accessibilityRole="button"
50
- accessibilityLabel={t('posts.gallery.close')}
50
+ accessibilityLabel={t('common.actions.close')}
51
51
  className="absolute right-4 top-12 z-50 rounded-full bg-primary p-2"
52
52
  onPress={onClose}
53
53
  >
@@ -44,7 +44,7 @@ export const CancelEventModal = forwardRef<
44
44
 
45
45
  <SheetFooter
46
46
  onCancel={() => bottomSheetClose(ref)}
47
- cancelText={t('posts.deleteEvent.cancel')}
47
+ cancelText={t('common.actions.cancel')}
48
48
  onConfirm={handleDelete}
49
49
  disabled={isLoading}
50
50
  confirmText={
@@ -45,7 +45,7 @@ export const DeleteEventModal = forwardRef<
45
45
  <SheetFooter
46
46
  onCancel={() => bottomSheetClose(ref)}
47
47
  onConfirm={handleDelete}
48
- cancelText={t('posts.deleteEvent.cancel')}
48
+ cancelText={t('common.actions.cancel')}
49
49
  disabled={isLoading}
50
50
  confirmText={
51
51
  isLoading
@@ -85,7 +85,7 @@ export const ComposeAttachments: React.FC<MediaPreviewProps> = ({
85
85
  <TouchableOpacity
86
86
  onPress={handleAltModalPress}
87
87
  accessibilityRole="button"
88
- accessibilityLabel={t('form.imageEditModal.altText', {
88
+ accessibilityLabel={t('common.labels.altText', {
89
89
  defaultValue: 'Alt text',
90
90
  })}
91
91
  className="min-h-10 px-3 rounded-full bg-background/90 border border-border items-center justify-center"
@@ -118,7 +118,9 @@ export const DateSheet = forwardRef<BottomSheetModal, DateSheetProps>(
118
118
  >
119
119
  <ThemedText>
120
120
  {t('common.form.switchTo')}{' '}
121
- {mode === 'date' ? t('common.form.time') : t('common.form.date')}
121
+ {mode === 'date'
122
+ ? t('common.form.time')
123
+ : t('common.labels.date')}
122
124
  </ThemedText>
123
125
  </Button>
124
126
  <Button
@@ -141,9 +143,9 @@ export const DateSheet = forwardRef<BottomSheetModal, DateSheetProps>(
141
143
  {t('common.form.select')}{' '}
142
144
  {Platform.OS === 'ios'
143
145
  ? mode === 'date'
144
- ? t('common.form.date')
146
+ ? t('common.labels.date')
145
147
  : t('common.form.time')
146
- : t('common.form.date')}
148
+ : t('common.labels.date')}
147
149
  </ThemedText>
148
150
 
149
151
  {Platform.OS === 'ios' ? renderIOSPicker() : renderAndroidPicker()}
@@ -1,4 +1,4 @@
1
- import React, { useRef, useState } from 'react';
1
+ import React, { useRef } 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';
@@ -101,7 +101,6 @@ export const EventForm = ({
101
101
  onNotifyChange,
102
102
  }: EventFormProps) => {
103
103
  const { t } = useTranslation();
104
- const [endBeforeStart, setEndBeforeStart] = useState(false);
105
104
  const startSheetRef = useRef<BottomSheetModal>(null);
106
105
  const endSheetRef = useRef<BottomSheetModal>(null);
107
106
  const untilSheetRef = useRef<BottomSheetModal>(null);
@@ -113,6 +112,9 @@ export const EventForm = ({
113
112
  repeatFreq,
114
113
  repeatEnd,
115
114
  preview,
115
+ endBeforeStart,
116
+ changeStart,
117
+ changeEnd,
116
118
  patchEvent,
117
119
  setEvent,
118
120
  setAudience,
@@ -348,7 +350,7 @@ export const EventForm = ({
348
350
 
349
351
  <View className="gap-y-1">
350
352
  <Label nativeID="event-visibility">
351
- {t('events.form.visibility')}
353
+ {t('common.labels.visibility')}
352
354
  </Label>
353
355
  <ThemedText className="text-sm text-muted-foreground">
354
356
  {t('events.form.visibilityNotChangeable')}
@@ -447,21 +449,14 @@ export const EventForm = ({
447
449
  ref={startSheetRef}
448
450
  value={event.start}
449
451
  timeZone={eventTimeZone}
450
- onChange={(start) => patchEvent({ start })}
452
+ onChange={changeStart}
451
453
  onClose={() => bottomSheetClose(startSheetRef)}
452
454
  />
453
455
  <DateSheet
454
456
  ref={endSheetRef}
455
457
  value={event.end}
456
458
  timeZone={eventTimeZone}
457
- onChange={(end) => {
458
- if (end && event.start && new Date(end) <= new Date(event.start)) {
459
- setEndBeforeStart(true);
460
- return;
461
- }
462
- setEndBeforeStart(false);
463
- patchEvent({ end });
464
- }}
459
+ onChange={changeEnd}
465
460
  onClose={() => bottomSheetClose(endSheetRef)}
466
461
  />
467
462
  <DateSheet
@@ -145,7 +145,7 @@ export const VisibilitySheet = forwardRef<
145
145
  });
146
146
  setIsShowSelectGroup(false);
147
147
  }}
148
- confirmText={t('common.form.save')}
148
+ confirmText={t('common.actions.save')}
149
149
  />
150
150
  </>
151
151
  ) : (
@@ -458,7 +458,9 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
458
458
  }
459
459
  >
460
460
  <ThemedText>
461
- {t('events.tabs.description', { defaultValue: 'Description' })}
461
+ {t('common.labels.description', {
462
+ defaultValue: 'Description',
463
+ })}
462
464
  </ThemedText>
463
465
  </TabsTrigger>
464
466
  ) : null}
@@ -578,7 +580,7 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
578
580
  </ThemedText>
579
581
  ) : recordingsQuery.isLoading ? (
580
582
  <ThemedText className="py-4 text-sm text-muted-foreground">
581
- {t('common.loading', { defaultValue: 'Loading…' })}
583
+ {t('common.states.loading', { defaultValue: 'Loading…' })}
582
584
  </ThemedText>
583
585
  ) : recordingsQuery.data?.length ? (
584
586
  recordingsQuery.data.map((recording: JamRecording) => (
@@ -756,7 +758,7 @@ const JamRecordingItem = ({
756
758
  </ThemedText>
757
759
  <SheetFooter
758
760
  onCancel={() => setConfirmOpen(false)}
759
- cancelText={t('common.cancel')}
761
+ cancelText={t('common.actions.cancel')}
760
762
  onConfirm={() => void handleDelete()}
761
763
  confirmText={t('events.deleteRecording', {
762
764
  defaultValue: 'Delete recording',
@@ -73,7 +73,7 @@ export const FollowUnfollowButton = ({
73
73
  className={isFollowing ? undefined : 'text-primary-foreground'}
74
74
  >
75
75
  {isLoading
76
- ? t('common.form.loading')
76
+ ? t('common.states.loading')
77
77
  : isFollowing
78
78
  ? t('profile.actions.unfollow')
79
79
  : t('profile.actions.follow')}
@@ -46,7 +46,7 @@ const SummaryBody = ({ summary }: { summary: ProfileActivitySummaryData }) => {
46
46
  <CountSection title={t('profile.activity.yourContent')}>
47
47
  <CountCard
48
48
  value={summary.postsCount}
49
- label={t('profile.activity.postsCount')}
49
+ label={t('common.entities.posts')}
50
50
  />
51
51
  <CountCard
52
52
  value={summary.repliesCount}
@@ -54,7 +54,7 @@ const SummaryBody = ({ summary }: { summary: ProfileActivitySummaryData }) => {
54
54
  />
55
55
  <CountCard
56
56
  value={summary.eventsCount}
57
- label={t('profile.activity.eventsCount')}
57
+ label={t('common.entities.events')}
58
58
  />
59
59
  </CountSection>
60
60
 
@@ -73,11 +73,11 @@ const SummaryBody = ({ summary }: { summary: ProfileActivitySummaryData }) => {
73
73
  />
74
74
  <CountCard
75
75
  value={summary.bookmarksCount}
76
- label={t('profile.activity.bookmarksCount')}
76
+ label={t('common.entities.bookmarks')}
77
77
  />
78
78
  <CountCard
79
79
  value={summary.groupsCount}
80
- label={t('profile.activity.groupsCount')}
80
+ label={t('common.entities.groups')}
81
81
  />
82
82
  </CountSection>
83
83
 
@@ -38,7 +38,7 @@ export const ProfileBadge = ({
38
38
  {onRemove ? (
39
39
  <Pressable
40
40
  accessibilityRole="button"
41
- accessibilityLabel={t('profile.selector.remove', {
41
+ accessibilityLabel={t('common.actions.remove', {
42
42
  defaultValue: 'Remove',
43
43
  })}
44
44
  className="ml-0.5 rounded-full p-0.5"
@@ -68,7 +68,7 @@ export const ProfilePageAction = ({
68
68
  t('profile.block.title', { handle: profile.handle }),
69
69
  t('profile.block.description', { handle: profile.handle }),
70
70
  [
71
- { text: t('common.cancel'), style: 'cancel' },
71
+ { text: t('common.actions.cancel'), style: 'cancel' },
72
72
  {
73
73
  text: t('profile.block.confirm'),
74
74
  style: 'destructive',
@@ -60,7 +60,7 @@ export const ProfilePostsAndReplies = ({
60
60
  className="w-full flex-row rounded-none border-b border-muted bg-transparent p-0"
61
61
  >
62
62
  <TabsTrigger value="posts" className={tabClass('posts')}>
63
- <ThemedText>{t('profile.posts')}</ThemedText>
63
+ <ThemedText>{t('common.entities.posts')}</ThemedText>
64
64
  </TabsTrigger>
65
65
  {isCurrentProfile ? (
66
66
  <TabsTrigger value="activity" className={tabClass('activity')}>
@@ -68,7 +68,7 @@ export const ProfilePostsAndReplies = ({
68
68
  </TabsTrigger>
69
69
  ) : null}
70
70
  <TabsTrigger value="groups" className={tabClass('groups')}>
71
- <ThemedText>{t('profile.groups.tabName')}</ThemedText>
71
+ <ThemedText>{t('common.entities.groups')}</ThemedText>
72
72
  </TabsTrigger>
73
73
  </TabsList>
74
74
  <TabsContent value="posts" className="p-0">
@@ -217,7 +217,7 @@ export const ReportProfileOrPostModal = forwardRef<
217
217
  confirmVariant={'destructive'}
218
218
  confirmText={
219
219
  isSubmitting
220
- ? t('common.form.loading')
220
+ ? t('common.states.loading')
221
221
  : t('reports.create.sendReport')
222
222
  }
223
223
  />
@@ -0,0 +1,262 @@
1
+ /**
2
+ * Regression tests for the ResourceCard download action (list layout).
3
+ *
4
+ * The action used to be enabled with `actionLabel === 'Download'`,
5
+ * comparing the *translated* label against the English copy. In any
6
+ * non-English locale the comparison fails and the download action
7
+ * silently degrades to inert text — resources could no longer be
8
+ * opened/downloaded (issue #1820). The gate must use the stable
9
+ * `resource.resourceKind === 'file'` property, mirroring the web card.
10
+ */
11
+
12
+ const React = require('react');
13
+ const ReactTestRenderer = require('react-test-renderer');
14
+
15
+ let mockTranslations: Record<string, string> = {};
16
+
17
+ jest.mock('react-native', () => ({
18
+ View: (props: { children?: unknown }) =>
19
+ React.createElement('View', null, props.children),
20
+ Pressable: (props: {
21
+ children?: unknown;
22
+ onPress?: () => void;
23
+ disabled?: boolean;
24
+ }) =>
25
+ React.createElement(
26
+ 'Pressable',
27
+ { onPress: props.onPress, disabled: props.disabled },
28
+ props.children
29
+ ),
30
+ Linking: { openURL: jest.fn() },
31
+ }));
32
+
33
+ jest.mock('react-i18next', () => ({
34
+ useTranslation: () => ({
35
+ t: (key: string) => mockTranslations[key] ?? key,
36
+ }),
37
+ }));
38
+
39
+ jest.mock('@react-navigation/native', () => ({
40
+ useNavigation: () => ({ navigate: jest.fn() }),
41
+ }));
42
+
43
+ jest.mock('@openpeepshq/common/lib', () => {
44
+ // Mirrored from platform/common/src/lib/resources.ts — the built
45
+ // package ships ESM which Jest's node transform doesn't cover.
46
+ const attachmentMediaKind = (att: {
47
+ type?: string;
48
+ meta?: { mimetype?: string };
49
+ }): string => {
50
+ const mime = att.meta?.mimetype ?? '';
51
+ const type = att.type ?? '';
52
+ if (type === 'image' || mime.startsWith('image/')) return 'image';
53
+ if (type === 'video' || mime.startsWith('video/')) return 'video';
54
+ if (type === 'audio' || mime.startsWith('audio/')) return 'audio';
55
+ return 'file';
56
+ };
57
+ const formatSize = (bytes: number): string => `${bytes} B`;
58
+ const normalizeResourceTags = (
59
+ tags: readonly string[] | undefined
60
+ ): string[] => {
61
+ const seen = new Set<string>();
62
+ const out: string[] = [];
63
+ for (const raw of tags ?? []) {
64
+ const tag = raw.replace(/^#/, '').trim().toLowerCase();
65
+ if (!tag || seen.has(tag)) continue;
66
+ seen.add(tag);
67
+ out.push(tag);
68
+ }
69
+ return out;
70
+ };
71
+ return {
72
+ attachmentMediaKind,
73
+ formatSize,
74
+ groupName: (group: { name?: string } | null) => group?.name,
75
+ normalizeResourceTags,
76
+ };
77
+ });
78
+
79
+ jest.mock('@openpeepshq/react', () => ({
80
+ useOpenpeeps: () => ({
81
+ openpeepsApi: {
82
+ useCurrentProfile: () => ({ data: null }),
83
+ useCurrentProfileBookmarkedIds: () => ({ data: undefined }),
84
+ bookmarkPostAction: () => () => {},
85
+ unbookmarkPostAction: () => () => {},
86
+ },
87
+ }),
88
+ }));
89
+
90
+ jest.mock('../navigation/helpers', () => ({
91
+ buildGoto: () => jest.fn(),
92
+ }));
93
+
94
+ jest.mock('../custom/common', () => ({
95
+ CachedImage: () => null,
96
+ }));
97
+
98
+ jest.mock('../ui/themed-text', () => ({
99
+ ThemedText: (props: { children?: unknown }) =>
100
+ React.createElement('ThemedText', null, props.children),
101
+ }));
102
+
103
+ jest.mock('../post/VideoPlayOverlay', () => ({
104
+ VideoPlayOverlay: () => null,
105
+ }));
106
+
107
+ jest.mock('../post/TruncatedMarkdown', () => ({
108
+ TruncatedMarkdown: () => null,
109
+ }));
110
+
111
+ jest.mock('../icons', () => ({
112
+ BookmarkPlusIcon: () => React.createElement('BookmarkPlusIcon'),
113
+ BookmarkMinusIcon: () => React.createElement('BookmarkMinusIcon'),
114
+ LinkIcon: () => React.createElement('LinkIcon'),
115
+ ImageOffIcon: () => React.createElement('ImageOffIcon'),
116
+ AudioLinesIcon: () => React.createElement('AudioLinesIcon'),
117
+ }));
118
+
119
+ import type { ResourceCardProps } from './ResourceCard';
120
+ import { ResourceCard } from './ResourceCard';
121
+
122
+ const Linking = require('react-native').Linking;
123
+
124
+ const EN = {
125
+ 'resources.actions.download': 'Download',
126
+ 'resources.actions.watch': 'Watch',
127
+ 'resources.kinds.file': 'File',
128
+ 'resources.kinds.video': 'Video',
129
+ };
130
+
131
+ // German stand-in: the translated label never equals the English copy.
132
+ const DE = {
133
+ 'resources.actions.download': 'Herunterladen',
134
+ 'resources.actions.watch': 'Ansehen',
135
+ 'resources.kinds.file': 'Datei',
136
+ 'resources.kinds.video': 'Video',
137
+ };
138
+
139
+ const resourcePost = (
140
+ data: Record<string, unknown>
141
+ ): ResourceCardProps['post'] =>
142
+ ({
143
+ id: 'post-1',
144
+ group: null,
145
+ data: { type: 'resource', ...data },
146
+ }) as unknown as ResourceCardProps['post'];
147
+
148
+ const filePost = resourcePost({
149
+ title: 'Spec PDF',
150
+ resourceKind: 'file',
151
+ attachments: [
152
+ {
153
+ url: 'https://example.com/spec.pdf',
154
+ type: 'file',
155
+ filename: 'spec.pdf',
156
+ meta: { mimetype: 'application/pdf', size: 1234 },
157
+ },
158
+ ],
159
+ });
160
+
161
+ const videoPost = resourcePost({
162
+ title: 'Talk',
163
+ resourceKind: 'video',
164
+ attachments: [
165
+ {
166
+ url: 'https://example.com/talk.mp4',
167
+ type: 'video',
168
+ meta: { mimetype: 'video/mp4', size: 99 },
169
+ },
170
+ ],
171
+ });
172
+
173
+ const linkPost = resourcePost({
174
+ title: 'Docs',
175
+ resourceKind: 'link',
176
+ url: 'https://example.com/docs',
177
+ });
178
+
179
+ const renderCard = (post: ResourceCardProps['post']) => {
180
+ let tree: ReturnType<typeof ReactTestRenderer.create>;
181
+ ReactTestRenderer.act(() => {
182
+ tree = ReactTestRenderer.create(
183
+ React.createElement(ResourceCard, {
184
+ post,
185
+ layout: 'list' as const,
186
+ })
187
+ );
188
+ });
189
+ return tree;
190
+ };
191
+
192
+ // The bookmark button is also a Pressable; it renders disabled for the
193
+ // anonymous profile the mock returns, so enabled Pressables are the
194
+ // card's actions only.
195
+ const enabledPressables = (tree: ReturnType<typeof ReactTestRenderer.create>) =>
196
+ tree.root
197
+ .findAllByType('Pressable')
198
+ .filter((node: { props: { disabled?: boolean } }) => !node.props.disabled);
199
+
200
+ const actionTexts = (tree: ReturnType<typeof ReactTestRenderer.create>) =>
201
+ tree.root
202
+ .findAllByType('ThemedText')
203
+ .map((node: { props: { children?: unknown } }) => node.props.children);
204
+
205
+ describe('ResourceCard list-layout actions', () => {
206
+ beforeEach(() => {
207
+ mockTranslations = EN;
208
+ Linking.openURL.mockClear();
209
+ });
210
+
211
+ it('enables the download action for a file resource (en locale)', () => {
212
+ const tree = renderCard(filePost);
213
+ const [action] = enabledPressables(tree);
214
+ expect(action).toBeDefined();
215
+ expect(actionTexts(tree)).toContain('Download');
216
+ ReactTestRenderer.act(() => {
217
+ action.props.onPress();
218
+ });
219
+ expect(Linking.openURL).toHaveBeenCalledWith(
220
+ 'https://example.com/spec.pdf'
221
+ );
222
+ tree.unmount();
223
+ });
224
+
225
+ it('keeps the download action enabled in non-English locales', () => {
226
+ mockTranslations = DE;
227
+ const tree = renderCard(filePost);
228
+ const [action] = enabledPressables(tree);
229
+ expect(action).toBeDefined();
230
+ expect(actionTexts(tree)).toContain('Herunterladen');
231
+ ReactTestRenderer.act(() => {
232
+ action.props.onPress();
233
+ });
234
+ expect(Linking.openURL).toHaveBeenCalledWith(
235
+ 'https://example.com/spec.pdf'
236
+ );
237
+ tree.unmount();
238
+ });
239
+
240
+ it('renders an inert label for a file resource without an attachment', () => {
241
+ const tree = renderCard(
242
+ resourcePost({ title: 'Empty', resourceKind: 'file' })
243
+ );
244
+ expect(enabledPressables(tree)).toHaveLength(0);
245
+ expect(actionTexts(tree)).toContain('Download');
246
+ tree.unmount();
247
+ });
248
+
249
+ it('does not make the watch label pressable for a video resource', () => {
250
+ const tree = renderCard(videoPost);
251
+ expect(enabledPressables(tree)).toHaveLength(0);
252
+ expect(actionTexts(tree)).toContain('Watch');
253
+ tree.unmount();
254
+ });
255
+
256
+ it('renders no action for a link resource', () => {
257
+ const tree = renderCard(linkPost);
258
+ expect(enabledPressables(tree)).toHaveLength(0);
259
+ expect(actionTexts(tree)).not.toContain('Download');
260
+ tree.unmount();
261
+ });
262
+ });
@@ -231,7 +231,10 @@ export const ResourceCard = ({
231
231
  </View>
232
232
  <View className="flex-row items-center gap-2">
233
233
  {resource.resourceKind !== 'link' && actionLabel ? (
234
- actionLabel === 'Download' && downloadUrl ? (
234
+ // Gate on the stable resource kind, not the translated label:
235
+ // in non-English locales the label differs and the download
236
+ // action would silently stop working (web gates the same way).
237
+ resource.resourceKind === 'file' && downloadUrl ? (
235
238
  <Pressable onPress={() => Linking.openURL(downloadUrl)}>
236
239
  <ThemedText className="text-primary text-xs font-medium">
237
240
  {actionLabel}
@@ -11,7 +11,7 @@ export type MediaPermissionType = 'photo' | 'video' | 'audio' | 'file';
11
11
 
12
12
  const showPermissionAlert = (t: TFunction) => {
13
13
  Alert.alert(t('media.permissions.title'), t('media.permissions.message'), [
14
- { text: t('common.cancel'), style: 'cancel' },
14
+ { text: t('common.actions.cancel'), style: 'cancel' },
15
15
  {
16
16
  text: t('media.permissions.openSettings'),
17
17
  onPress: () => Linking.openSettings(),
@@ -50,7 +50,7 @@ export const Members: React.FC<DirectoryProps> = ({ navigation }) => {
50
50
  }, [searchQuery, profiles, currentProfile]);
51
51
 
52
52
  useSetPageHeader(
53
- t('navigation.members'),
53
+ t('common.entities.members'),
54
54
  isSearchButtonClicked ? (
55
55
  <View className="max-w-[200px] flex-row items-center">
56
56
  <Input
@@ -65,7 +65,7 @@ export const Login = ({
65
65
  name="email"
66
66
  render={({ field }) => (
67
67
  <FormInput
68
- label={t('auth.login.email')}
68
+ label={t('common.labels.email')}
69
69
  placeholder=""
70
70
  {...field}
71
71
  className="rounded-md"
@@ -150,7 +150,7 @@ export const Register = ({
150
150
  name="handle"
151
151
  render={({ field }) => (
152
152
  <FormInput
153
- label={t('auth.register.handle')}
153
+ label={t('common.labels.handle')}
154
154
  placeholder={t('auth.register.handlePlaceholder')}
155
155
  autoCapitalize="none"
156
156
  {...field}
@@ -162,7 +162,7 @@ export const Register = ({
162
162
  name="displayName"
163
163
  render={({ field }) => (
164
164
  <FormInput
165
- label={t('auth.register.name')}
165
+ label={t('common.labels.name')}
166
166
  placeholder={t('auth.register.namePlaceholder')}
167
167
  {...field}
168
168
  />
@@ -173,7 +173,7 @@ export const Register = ({
173
173
  name="email"
174
174
  render={({ field }) => (
175
175
  <FormInput
176
- label={t('auth.register.email')}
176
+ label={t('common.labels.email')}
177
177
  placeholder={t('auth.register.emailPlaceholder')}
178
178
  autoCapitalize="none"
179
179
  keyboardType="email-address"
@@ -204,7 +204,7 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
204
204
  }, [id, currentProfile, messages, isLoading, markPostsSeen]);
205
205
 
206
206
  const searchLabel = searchOpen
207
- ? t('common.close', { defaultValue: 'Close' })
207
+ ? t('common.actions.close', { defaultValue: 'Close' })
208
208
  : t('conversations.search.toggle', {
209
209
  defaultValue: 'Search this conversation',
210
210
  });
@@ -46,7 +46,7 @@ export const EventsIndex = ({
46
46
  const visibility = useDefaultVisibility();
47
47
 
48
48
  useSetPageHeader(
49
- t('navigation.events', { defaultValue: 'Events' }),
49
+ t('common.entities.events', { defaultValue: 'Events' }),
50
50
  <DropdownMenu>
51
51
  <DropdownMenuTrigger asChild className="px-2">
52
52
  <Pressable>
@@ -30,7 +30,7 @@ export const FeedsBookmarks: React.FC<HomeScreenProps> = () => {
30
30
  setRefreshing(false);
31
31
  }, [query]);
32
32
 
33
- useSetPageHeader(t('navigation.bookmarks'));
33
+ useSetPageHeader(t('common.entities.bookmarks'));
34
34
 
35
35
  return (
36
36
  <>
@@ -40,7 +40,7 @@ export const EditGroupInfo = ({ route }: EditGroupInfoProps) => {
40
40
  title={
41
41
  submitting
42
42
  ? t('common.saving', { defaultValue: 'Saving…' })
43
- : t('common.save', { defaultValue: 'Save' })
43
+ : t('common.actions.save', { defaultValue: 'Save' })
44
44
  }
45
45
  onPress={() => void submit()}
46
46
  disabled={submitting || !groupData}
@@ -72,7 +72,7 @@ export const EditGroupRoles = ({ route }: EditGroupRolesProps) => {
72
72
  title={
73
73
  submitting
74
74
  ? t('common.saving', { defaultValue: 'Saving…' })
75
- : t('common.save', { defaultValue: 'Save' })
75
+ : t('common.actions.save', { defaultValue: 'Save' })
76
76
  }
77
77
  onPress={() => void submit()}
78
78
  disabled={submitting || !groupData || !canEditCapabilities}
@@ -63,7 +63,7 @@ export const GroupsIndex: React.FC<GroupsProps> = ({ navigation }) => {
63
63
 
64
64
  const canCreate = canCreateGroup(currentProfile?.roles ?? []);
65
65
 
66
- useSetPageHeader(t('navigation.groups', { defaultValue: 'Groups' }));
66
+ useSetPageHeader(t('common.entities.groups', { defaultValue: 'Groups' }));
67
67
  useSetPlusButtonActions(
68
68
  canCreate
69
69
  ? {
@@ -147,7 +147,7 @@ export const GroupInfoAsComponent: React.FC<GroupInfoAsComponentProps> = ({
147
147
  </View>
148
148
  <View>
149
149
  <ThemedText className="font-semibold">
150
- {t('groups.visibility.title')}
150
+ {t('common.labels.visibility')}
151
151
  </ThemedText>
152
152
  <ThemedText className="">
153
153
  {t(`groups.visibility.${visibilityValue}.description`)}
@@ -24,8 +24,8 @@ export const GroupMembers = ({ route }: GroupMembersProps) => {
24
24
  const group = groupQuery.data;
25
25
 
26
26
  const title = group
27
- ? `${truncateText(groupName(group), 20)} - ${t('groups.members.title')}`
28
- : t('groups.members.title');
27
+ ? `${truncateText(groupName(group), 20)} - ${t('common.entities.members')}`
28
+ : t('common.entities.members');
29
29
 
30
30
  useSetPageHeader(
31
31
  title,
@@ -75,7 +75,7 @@ export const NewGroup: React.FC<NewGroupProps> = ({ navigation }) => {
75
75
  />
76
76
  <View className="gap-y-2 px-1">
77
77
  <Label nativeID="group-members">
78
- {t('groups.form.members', { defaultValue: 'Members' })}
78
+ {t('common.entities.members', { defaultValue: 'Members' })}
79
79
  </Label>
80
80
  <ProfilesInput
81
81
  value={members}
@@ -120,10 +120,10 @@ export const GroupShow = ({ route, navigation }: GroupProps) => {
120
120
  >
121
121
  <TabsList className="w-full flex-row rounded-none border-b border-muted bg-transparent p-0 px-3">
122
122
  <TabsTrigger value="posts" className={tabClass('posts')}>
123
- <ThemedText>{t('groups.sections.posts')}</ThemedText>
123
+ <ThemedText>{t('common.entities.posts')}</ThemedText>
124
124
  </TabsTrigger>
125
125
  <TabsTrigger value="events" className={tabClass('events')}>
126
- <ThemedText>{t('groups.sections.events')}</ThemedText>
126
+ <ThemedText>{t('common.entities.events')}</ThemedText>
127
127
  </TabsTrigger>
128
128
  <TabsTrigger
129
129
  value="resources"
@@ -135,7 +135,7 @@ export const GroupShow = ({ route, navigation }: GroupProps) => {
135
135
  value="description"
136
136
  className={tabClass('description')}
137
137
  >
138
- <ThemedText>{t('groups.sections.description')}</ThemedText>
138
+ <ThemedText>{t('common.labels.description')}</ThemedText>
139
139
  </TabsTrigger>
140
140
  </TabsList>
141
141
  <TabsContent value="posts" className="p-0">
@@ -106,9 +106,7 @@ export const AccessTokensSettings: React.FC<AccessTokensSettingsProps> = () => {
106
106
  {t('settings.accessTokens.createDescription')}
107
107
  </ThemedText>
108
108
  <View className="gap-2">
109
- <Label nativeID="token-name">
110
- {t('settings.accessTokens.name')}
111
- </Label>
109
+ <Label nativeID="token-name">{t('common.labels.name')}</Label>
112
110
  <Input
113
111
  value={form.name}
114
112
  placeholder={t('settings.accessTokens.namePlaceholder')}
@@ -117,7 +115,7 @@ export const AccessTokensSettings: React.FC<AccessTokensSettingsProps> = () => {
117
115
  </View>
118
116
  <View className="gap-2">
119
117
  <Label nativeID="token-description">
120
- {t('settings.accessTokens.descriptionLabel')}
118
+ {t('common.labels.description')}
121
119
  </Label>
122
120
  <Input
123
121
  value={form.description ?? ''}
@@ -166,7 +164,7 @@ export const AccessTokensSettings: React.FC<AccessTokensSettingsProps> = () => {
166
164
  disabled={(form.scopes?.length ?? 0) === 1}
167
165
  onPress={() => removeScope(index)}
168
166
  >
169
- <ThemedText>{t('common.remove')}</ThemedText>
167
+ <ThemedText>{t('common.actions.remove')}</ThemedText>
170
168
  </Button>
171
169
  </View>
172
170
  ))}
@@ -233,7 +231,7 @@ export const AccessTokensSettings: React.FC<AccessTokensSettingsProps> = () => {
233
231
  {t('settings.accessTokens.expiresAt')}:{' '}
234
232
  {token.expiresAt
235
233
  ? new Date(token.expiresAt).toLocaleString()
236
- : t('settings.accessTokens.never')}
234
+ : t('common.states.never')}
237
235
  </ThemedText>
238
236
  </View>
239
237
  <Button
@@ -152,7 +152,9 @@ export const AccountSettings: React.FC<AccountSettingsProps> = () => {
152
152
  useSetPageHeader(
153
153
  t('settings.account.title', { defaultValue: 'Account' }),
154
154
  <HeaderActionButton
155
- title={isSubmitting ? t('common.form.loading') : t('common.form.save')}
155
+ title={
156
+ isSubmitting ? t('common.states.loading') : t('common.actions.save')
157
+ }
156
158
  onPress={() => void handleSubmit()}
157
159
  disabled={isSubmitting}
158
160
  loading={isSubmitting}
@@ -179,7 +181,7 @@ export const AccountSettings: React.FC<AccountSettingsProps> = () => {
179
181
  name="email"
180
182
  render={({ field }) => (
181
183
  <FormInput
182
- label={t('settings.account.email')}
184
+ label={t('common.labels.email')}
183
185
  placeholder={t('settings.account.emailPlaceholder')}
184
186
  {...field}
185
187
  value={field.value || ''}
@@ -35,7 +35,7 @@ export const FeedSettings: React.FC<FeedSettingsProps> = () => {
35
35
  useSetPageHeader(
36
36
  t('settings.feed.title'),
37
37
  <HeaderActionButton
38
- title={submitting ? t('common.form.loading') : t('common.form.save')}
38
+ title={submitting ? t('common.states.loading') : t('common.actions.save')}
39
39
  onPress={() => void handleSubmit()}
40
40
  disabled={submitting}
41
41
  loading={submitting}
@@ -42,7 +42,7 @@ export const LanguageSettings: React.FC<LanguageSettingsProps> = () => {
42
42
  useSetPageHeader(
43
43
  t('settings.language.title'),
44
44
  <HeaderActionButton
45
- title={saving ? t('common.form.loading') : t('common.form.save')}
45
+ title={saving ? t('common.states.loading') : t('common.actions.save')}
46
46
  onPress={() => void save()}
47
47
  disabled={saving}
48
48
  loading={saving}
@@ -122,10 +122,9 @@ export const PushEnabledDevices: React.FC<PushEnabledDevicesProps> = () => {
122
122
  onPress={() => setConfirmId(null)}
123
123
  >
124
124
  <Text>
125
- {t(
126
- 'settings.notifications.pushEnabledDevices.delete.cancel',
127
- { defaultValue: 'Cancel' }
128
- )}
125
+ {t('common.actions.cancel', {
126
+ defaultValue: 'Cancel',
127
+ })}
129
128
  </Text>
130
129
  </Button>
131
130
  </View>
@@ -62,7 +62,7 @@ export const ThemeSettings: React.FC<ThemeSettingsProps> = () => {
62
62
  useSetPageHeader(
63
63
  t('settings.theme.title'),
64
64
  <HeaderActionButton
65
- title={submitting ? t('common.form.loading') : t('common.form.save')}
65
+ title={submitting ? t('common.states.loading') : t('common.actions.save')}
66
66
  onPress={() => void handleSubmit()}
67
67
  disabled={submitting}
68
68
  loading={submitting}
@@ -42,7 +42,7 @@ export const TimezoneSettings: React.FC<TimezoneSettingsProps> = () => {
42
42
  useSetPageHeader(
43
43
  t('settings.timezone.title'),
44
44
  <HeaderActionButton
45
- title={saving ? t('common.form.loading') : t('common.form.save')}
45
+ title={saving ? t('common.states.loading') : t('common.actions.save')}
46
46
  onPress={() => void save()}
47
47
  disabled={saving}
48
48
  loading={saving}