@openpeepshq/react 0.7.0 → 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 (251) hide show
  1. package/dist/components/configuration/ConfigurationCategory.js +3 -2
  2. package/dist/components/configuration/ConfigurationList.js +1 -1
  3. package/dist/components/form/LocationInput.js +1 -1
  4. package/dist/components/jams/JamCapacityGate.js +1 -1
  5. package/dist/components/jams/JamConference.js +2 -0
  6. package/dist/components/jams/JamParticipantConference.js +2 -0
  7. package/dist/components/jams/JamRoom.js +2 -3
  8. package/dist/components/jams/LiveJamsSection.js +8 -2
  9. package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
  10. package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
  11. package/dist/components/jams/dropLateAudio.d.ts +22 -0
  12. package/dist/components/jams/dropLateAudio.js +115 -0
  13. package/dist/components/jams/index.d.ts +1 -0
  14. package/dist/components/jams/index.js +1 -0
  15. package/dist/components/markdown/compileMarkdown.js +1 -0
  16. package/dist/components/navigation/FooterMobile.js +4 -3
  17. package/dist/components/navigation/HeaderMobile.js +5 -2
  18. package/dist/components/navigation/MobileMenuItem.d.ts +3 -1
  19. package/dist/components/navigation/MobileMenuItem.js +7 -2
  20. package/dist/components/navigation/NavWithTooltip.d.ts +9 -0
  21. package/dist/components/navigation/NavWithTooltip.js +4 -0
  22. package/dist/components/navigation/index.d.ts +2 -0
  23. package/dist/components/navigation/index.js +1 -0
  24. package/dist/components/navigation/sideBarNavLinkClass.d.ts +6 -4
  25. package/dist/components/navigation/sideBarNavLinkClass.js +6 -2
  26. package/dist/components/notifications/TypedNotification.js +46 -4
  27. package/dist/components/post/CompactReplyParent.js +5 -6
  28. package/dist/components/post/Markdown.d.ts +2 -2
  29. package/dist/components/post/Markdown.js +1 -1
  30. package/dist/components/post/TruncatedMarkdown.d.ts +27 -0
  31. package/dist/components/post/TruncatedMarkdown.js +37 -0
  32. package/dist/components/post/attachmentPreview.js +1 -1
  33. package/dist/components/post/helpers.d.ts +2 -2
  34. package/dist/components/post/helpers.js +3 -16
  35. package/dist/components/post/index.d.ts +2 -0
  36. package/dist/components/post/index.js +1 -0
  37. package/dist/components/post/pieces/Attachments.js +23 -17
  38. package/dist/components/post/pieces/EventLocation.js +14 -0
  39. package/dist/components/post/pieces/EventRsvpButton.js +39 -7
  40. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  41. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  42. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  43. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  44. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  45. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  46. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  47. package/dist/components/post/pieces/PollContent.js +8 -2
  48. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  49. package/dist/components/post/pieces/PostActions.js +20 -12
  50. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  51. package/dist/components/post/pieces/ShareMenu.js +40 -7
  52. package/dist/components/post/post-form/ArticleForm.js +1 -1
  53. package/dist/components/post/post-form/EventForm.js +33 -5
  54. package/dist/components/post/post-form/ResourceForm.d.ts +3 -1
  55. package/dist/components/post/post-form/ResourceForm.js +48 -7
  56. package/dist/components/post/post-form/VisibilitySelector.js +9 -3
  57. package/dist/components/post/types/Article.js +2 -3
  58. package/dist/components/post/types/Event.js +10 -1
  59. package/dist/components/post/types/article/FullArticle.js +1 -1
  60. package/dist/components/post/types/event/CardEvent.js +2 -1
  61. package/dist/components/post/types/event/FullEvent.js +22 -13
  62. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  63. package/dist/components/post/types/resource/FullResource.js +3 -3
  64. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  65. package/dist/components/preview-link/PreviewLink.js +1 -1
  66. package/dist/components/preview-link/helpers.d.ts +5 -0
  67. package/dist/components/preview-link/helpers.js +27 -1
  68. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  69. package/dist/components/preview-link/local/WelcomePreview.js +8 -0
  70. package/dist/components/profile/Avatar.js +2 -2
  71. package/dist/components/profile/ProfileFromId.js +1 -1
  72. package/dist/components/resources/ResourceCard.d.ts +5 -1
  73. package/dist/components/resources/ResourceCard.js +29 -5
  74. package/dist/components/resources/ResourceCard.test.d.ts +1 -0
  75. package/dist/components/resources/ResourceCard.test.js +75 -0
  76. package/dist/components/resources/ResourceLibrary.js +1 -1
  77. package/dist/components/server-data/context.d.ts +1 -0
  78. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  79. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  80. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  81. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  82. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  83. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  84. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  85. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  86. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  87. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  88. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  89. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  90. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  91. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  92. package/dist/hooks/events/useEventForm.d.ts +1 -0
  93. package/dist/hooks/events/useEventRsvp.d.ts +12 -2
  94. package/dist/hooks/events/useEventRsvp.js +59 -10
  95. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  96. package/dist/hooks/groups/useNewGroup.js +22 -2
  97. package/dist/hooks/index.d.ts +5 -1
  98. package/dist/hooks/index.js +4 -1
  99. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  100. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  101. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  102. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  103. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  104. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  105. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  106. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  107. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  108. package/dist/hooks/posts/useResourceComposer.d.ts +95 -41
  109. package/dist/hooks/posts/useResourceComposer.js +135 -27
  110. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  111. package/dist/hooks/posts/useShareMenu.js +7 -0
  112. package/dist/hooks/resources/useResourceLibrary.d.ts +177 -79
  113. package/dist/hooks/resources/useResourceLibrary.js +6 -2
  114. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  115. package/dist/hooks/useWelcomePreview.d.ts +16 -0
  116. package/dist/hooks/useWelcomePreview.js +40 -0
  117. package/dist/lib/groupFormErrors.d.ts +1 -0
  118. package/dist/lib/groupFormErrors.js +5 -2
  119. package/dist/lib/threadHelpers.js +1 -5
  120. package/dist/navigation/menuItems.js +15 -0
  121. package/dist/navigation/targets.d.ts +2 -0
  122. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  123. package/dist/pages/admin/Diagnostics.js +1 -1
  124. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  125. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  126. package/dist/pages/admin/Invites.js +5 -3
  127. package/dist/pages/admin/Media.d.ts +1 -0
  128. package/dist/pages/admin/Media.js +135 -0
  129. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  130. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  131. package/dist/pages/admin/community/CommunityMarkdownPage.js +2 -1
  132. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  133. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  134. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  135. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  136. package/dist/pages/auth/Register.js +33 -9
  137. package/dist/pages/conversations/Show.js +11 -0
  138. package/dist/pages/index.d.ts +3 -0
  139. package/dist/pages/index.js +3 -0
  140. package/dist/pages/jams/Index.js +2 -4
  141. package/dist/pages/resources/Edit.js +3 -3
  142. package/dist/pages/resources/New.js +2 -2
  143. package/dist/pages/settings/Account.js +30 -2
  144. package/dist/pages/settings/PublicProfile.js +15 -3
  145. package/dist/pwa/sw.d.ts +0 -1
  146. package/dist/react-native.d.ts +1 -0
  147. package/dist/react-native.js +1 -0
  148. package/dist/stores/newPosts.d.ts +4 -2
  149. package/dist/stores/newPosts.js +6 -1
  150. package/package.json +12 -7
  151. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  152. package/src/components/configuration/ConfigurationList.tsx +6 -1
  153. package/src/components/form/LocationInput.tsx +7 -1
  154. package/src/components/jams/JamCapacityGate.tsx +1 -1
  155. package/src/components/jams/JamConference.tsx +2 -0
  156. package/src/components/jams/JamParticipantConference.tsx +2 -0
  157. package/src/components/jams/JamRoom.tsx +2 -6
  158. package/src/components/jams/LiveJamsSection.tsx +16 -2
  159. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  160. package/src/components/jams/dropLateAudio.ts +153 -0
  161. package/src/components/jams/index.ts +1 -0
  162. package/src/components/markdown/compileMarkdown.ts +1 -0
  163. package/src/components/navigation/FooterMobile.tsx +41 -33
  164. package/src/components/navigation/HeaderMobile.tsx +55 -41
  165. package/src/components/navigation/MobileMenuItem.tsx +15 -2
  166. package/src/components/navigation/NavWithTooltip.tsx +26 -0
  167. package/src/components/navigation/index.ts +2 -0
  168. package/src/components/navigation/sideBarNavLinkClass.ts +9 -6
  169. package/src/components/notifications/TypedNotification.tsx +81 -9
  170. package/src/components/post/CompactReplyParent.tsx +17 -10
  171. package/src/components/post/Markdown.tsx +8 -2
  172. package/src/components/post/TruncatedMarkdown.tsx +91 -0
  173. package/src/components/post/attachmentPreview.ts +1 -3
  174. package/src/components/post/helpers.ts +4 -18
  175. package/src/components/post/index.ts +2 -0
  176. package/src/components/post/pieces/Attachments.tsx +93 -78
  177. package/src/components/post/pieces/EventLocation.tsx +27 -0
  178. package/src/components/post/pieces/EventRsvpButton.tsx +110 -7
  179. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  180. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  181. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  182. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  183. package/src/components/post/pieces/PollContent.tsx +8 -2
  184. package/src/components/post/pieces/PostActions.tsx +73 -42
  185. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  186. package/src/components/post/post-form/ArticleForm.tsx +1 -1
  187. package/src/components/post/post-form/EventForm.tsx +69 -15
  188. package/src/components/post/post-form/ResourceForm.tsx +132 -4
  189. package/src/components/post/post-form/VisibilitySelector.tsx +12 -5
  190. package/src/components/post/types/Article.tsx +6 -6
  191. package/src/components/post/types/Event.tsx +68 -7
  192. package/src/components/post/types/article/FullArticle.tsx +2 -2
  193. package/src/components/post/types/event/CardEvent.tsx +26 -14
  194. package/src/components/post/types/event/FullEvent.tsx +48 -35
  195. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  196. package/src/components/post/types/note/FullNote.tsx +1 -4
  197. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  198. package/src/components/post/types/resource/FullResource.tsx +9 -1
  199. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  200. package/src/components/preview-link/PreviewLink.tsx +2 -7
  201. package/src/components/preview-link/helpers.ts +32 -1
  202. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  203. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  204. package/src/components/preview-link/local/WelcomePreview.tsx +45 -0
  205. package/src/components/profile/Avatar.tsx +6 -2
  206. package/src/components/profile/ProfileFromId.tsx +1 -5
  207. package/src/components/resources/ResourceCard.tsx +68 -11
  208. package/src/components/resources/ResourceLibrary.tsx +2 -2
  209. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  210. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  211. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  212. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  213. package/src/css.d.ts +4 -0
  214. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  215. package/src/hooks/events/useEventRsvp.ts +69 -13
  216. package/src/hooks/groups/useNewGroup.ts +28 -3
  217. package/src/hooks/index.ts +8 -1
  218. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  219. package/src/hooks/posts/useResourceComposer.ts +165 -39
  220. package/src/hooks/posts/useShareMenu.ts +9 -0
  221. package/src/hooks/resources/useResourceLibrary.ts +6 -2
  222. package/src/hooks/useWelcomePreview.ts +61 -0
  223. package/src/i18n/I18nProvider.tsx +1 -4
  224. package/src/lib/groupFormErrors.ts +9 -2
  225. package/src/lib/threadHelpers.ts +1 -5
  226. package/src/navigation/menuItems.ts +16 -0
  227. package/src/navigation/targets.ts +2 -0
  228. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  229. package/src/pages/admin/Diagnostics.tsx +4 -0
  230. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  231. package/src/pages/admin/Invites.tsx +23 -1
  232. package/src/pages/admin/Media.tsx +290 -0
  233. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  234. package/src/pages/admin/community/CommunityMarkdownPage.tsx +5 -1
  235. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  236. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  237. package/src/pages/auth/Register.tsx +45 -4
  238. package/src/pages/conversations/Show.tsx +11 -0
  239. package/src/pages/index.ts +3 -0
  240. package/src/pages/jams/Index.tsx +2 -6
  241. package/src/pages/resources/Edit.tsx +3 -2
  242. package/src/pages/resources/New.tsx +6 -1
  243. package/src/pages/settings/Account.tsx +51 -1
  244. package/src/pages/settings/PublicProfile.tsx +20 -2
  245. package/src/pwa/sw.ts +6 -3
  246. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  247. package/src/react-native.ts +1 -0
  248. package/src/stores/newPosts.ts +6 -1
  249. package/src/streaming.ts +3 -3
  250. package/dist/setupTests.d.ts +0 -1
  251. package/dist/setupTests.js +0 -5
@@ -0,0 +1,263 @@
1
+ import { useState } from 'react';
2
+ import type { InviteLinkWithMeta } from '@openpeepshq/common/types';
3
+ import { useOpenpeeps, useT } from '../../../index';
4
+ import {
5
+ Dialog,
6
+ DialogActions,
7
+ DialogContent,
8
+ DialogHeader,
9
+ DialogTitle,
10
+ Input,
11
+ Label,
12
+ } from '@openpeepshq/react-ui';
13
+ import { DAY_MS, EXPIRY_OPTIONS, UNLIMITED_USES } from './InviteWithLinkModal';
14
+
15
+ const NEVER_DAYS =
16
+ EXPIRY_OPTIONS.find((option) => option.value === 'P100Y')?.days ?? 365 * 100;
17
+
18
+ const FAR_FUTURE_MS = 50 * 365 * DAY_MS;
19
+
20
+ const pad = (value: number) => String(value).padStart(2, '0');
21
+
22
+ const toDatetimeLocal = (iso: string) => {
23
+ const date = new Date(iso);
24
+ if (Number.isNaN(date.getTime())) return '';
25
+ const day = [
26
+ date.getFullYear(),
27
+ pad(date.getMonth() + 1),
28
+ pad(date.getDate()),
29
+ ].join('-');
30
+ const time = [pad(date.getHours()), pad(date.getMinutes())].join(':');
31
+ return `${day}T${time}`;
32
+ };
33
+
34
+ const isFarFuture = (iso: string) =>
35
+ new Date(iso).getTime() - Date.now() > FAR_FUTURE_MS;
36
+
37
+ const useChoices = (invite: InviteLinkWithMeta) => {
38
+ const floor = Math.max(invite.redemptions.length, 1);
39
+ const current = invite.maxUses < UNLIMITED_USES ? [invite.maxUses] : [];
40
+ return [...new Set([1, 5, 10, 15, 20, ...current])]
41
+ .filter((count) => count >= floor)
42
+ .sort((a, b) => a - b);
43
+ };
44
+
45
+ const initialUses = (invite: InviteLinkWithMeta) => {
46
+ if (
47
+ invite.maxUses >= UNLIMITED_USES ||
48
+ invite.maxUses < invite.redemptions.length
49
+ ) {
50
+ return 'unlimited';
51
+ }
52
+ return String(invite.maxUses);
53
+ };
54
+
55
+ const errorMessage = (err: unknown, fallback: string) => {
56
+ if (
57
+ err &&
58
+ typeof err === 'object' &&
59
+ 'message' in err &&
60
+ typeof err.message === 'string' &&
61
+ err.message
62
+ ) {
63
+ return err.message;
64
+ }
65
+ return fallback;
66
+ };
67
+
68
+ export const EditInviteLinkModal = ({
69
+ invite,
70
+ onClose,
71
+ }: {
72
+ invite: InviteLinkWithMeta;
73
+ onClose: () => void;
74
+ }) => {
75
+ const t = useT();
76
+ const { openpeepsApi } = useOpenpeeps();
77
+ const updateInvite = openpeepsApi.admin.updateInviteAction({
78
+ id: invite.id,
79
+ });
80
+ const used = invite.redemptions.length;
81
+ const choices = useChoices(invite);
82
+ const startsNever = isFarFuture(invite.expiresAt);
83
+
84
+ const [maxUses, setMaxUses] = useState(() => initialUses(invite));
85
+ const [never, setNever] = useState(startsNever);
86
+ const [expiresLocal, setExpiresLocal] = useState(() =>
87
+ toDatetimeLocal(
88
+ startsNever
89
+ ? new Date(Date.now() + 7 * DAY_MS).toISOString()
90
+ : invite.expiresAt,
91
+ ),
92
+ );
93
+ const [submitting, setSubmitting] = useState(false);
94
+ const [error, setError] = useState<string | null>(null);
95
+
96
+ const parsedExpiry = new Date(expiresLocal);
97
+ const expiresInPast =
98
+ !never &&
99
+ expiresLocal !== '' &&
100
+ !Number.isNaN(parsedExpiry.getTime()) &&
101
+ parsedExpiry.getTime() <= Date.now();
102
+
103
+ const submit = async () => {
104
+ setError(null);
105
+ const unlimited = maxUses === 'unlimited';
106
+ const nextMaxUses = unlimited ? UNLIMITED_USES : Number(maxUses);
107
+ if (!unlimited && (!Number.isInteger(nextMaxUses) || nextMaxUses < used)) {
108
+ setError(
109
+ t('admin.invites.maxUsesTooLow', {
110
+ defaultValue:
111
+ 'Number of uses cannot be lower than {{count}}, the number of accounts that already joined.',
112
+ count: used,
113
+ }),
114
+ );
115
+ return;
116
+ }
117
+
118
+ const patch: { maxUses?: number; expiresAt?: string } = {};
119
+ if (nextMaxUses !== invite.maxUses) patch.maxUses = nextMaxUses;
120
+
121
+ if (never) {
122
+ if (!startsNever) {
123
+ patch.expiresAt = new Date(
124
+ Date.now() + NEVER_DAYS * DAY_MS,
125
+ ).toISOString();
126
+ }
127
+ } else if (toDatetimeLocal(invite.expiresAt) !== expiresLocal) {
128
+ if (!expiresLocal || Number.isNaN(parsedExpiry.getTime())) {
129
+ setError(
130
+ t('admin.invites.expiresRequired', {
131
+ defaultValue: 'Choose an expiration date.',
132
+ }),
133
+ );
134
+ return;
135
+ }
136
+ patch.expiresAt = parsedExpiry.toISOString();
137
+ }
138
+
139
+ if (patch.maxUses == null && patch.expiresAt == null) {
140
+ onClose();
141
+ return;
142
+ }
143
+
144
+ setSubmitting(true);
145
+ try {
146
+ await updateInvite(patch);
147
+ onClose();
148
+ } catch (err) {
149
+ setError(
150
+ errorMessage(
151
+ err,
152
+ t('admin.invites.updateError', {
153
+ defaultValue: 'Failed to update invite link',
154
+ }),
155
+ ),
156
+ );
157
+ } finally {
158
+ setSubmitting(false);
159
+ }
160
+ };
161
+
162
+ return (
163
+ <Dialog open onOpenChange={(open) => !open && onClose()}>
164
+ <DialogContent className="max-w-md" data-testid="edit-invite-link">
165
+ <DialogHeader>
166
+ <DialogTitle>
167
+ {t('admin.invites.editTitle', {
168
+ defaultValue: 'Edit invite link',
169
+ })}
170
+ </DialogTitle>
171
+ </DialogHeader>
172
+ <div className="space-y-4 px-1">
173
+ <p className="text-muted-foreground text-sm">
174
+ {t('admin.invites.editDescription', {
175
+ defaultValue:
176
+ 'Update how many times this link can be used, or when it expires.',
177
+ })}
178
+ </p>
179
+ <p className="font-mono text-xs">{invite.slug}</p>
180
+ <div className="space-y-2">
181
+ <Label htmlFor="edit-invite-uses">
182
+ {t('admin.inviteLink.numberOfUses', {
183
+ defaultValue: 'Number of Uses',
184
+ })}
185
+ </Label>
186
+ <select
187
+ id="edit-invite-uses"
188
+ className="border-input bg-background w-full rounded-md border p-2 text-sm"
189
+ value={maxUses}
190
+ onChange={(e) => setMaxUses(e.target.value)}
191
+ >
192
+ {choices.map((count) => (
193
+ <option key={count} value={String(count)}>
194
+ {count}
195
+ </option>
196
+ ))}
197
+ <option value="unlimited">
198
+ {t('admin.inviteLink.unlimited', {
199
+ defaultValue: 'Unlimited',
200
+ })}
201
+ </option>
202
+ </select>
203
+ {used > 0 ? (
204
+ <p className="text-muted-foreground text-xs">
205
+ {t('admin.invites.alreadyJoined', {
206
+ defaultValue: 'Already joined: {{count}}',
207
+ count: used,
208
+ })}
209
+ </p>
210
+ ) : null}
211
+ </div>
212
+ <div className="space-y-2">
213
+ <Label htmlFor="edit-invite-expiry">
214
+ {t('admin.invites.expirationDate', {
215
+ defaultValue: 'Expiration date',
216
+ })}
217
+ </Label>
218
+ <Input
219
+ id="edit-invite-expiry"
220
+ type="datetime-local"
221
+ value={expiresLocal}
222
+ disabled={never}
223
+ onChange={(e) => setExpiresLocal(e.target.value)}
224
+ />
225
+ <label className="flex items-center gap-2 text-sm">
226
+ <input
227
+ type="checkbox"
228
+ className="size-4"
229
+ checked={never}
230
+ onChange={(e) => setNever(e.target.checked)}
231
+ />
232
+ <span>
233
+ {t('admin.invites.neverExpires', {
234
+ defaultValue: 'Never expires',
235
+ })}
236
+ </span>
237
+ </label>
238
+ {expiresInPast ? (
239
+ <p className="text-muted-foreground text-xs">
240
+ {t('admin.invites.pastExpiration', {
241
+ defaultValue:
242
+ 'This date is in the past, so the link will be inactive.',
243
+ })}
244
+ </p>
245
+ ) : null}
246
+ </div>
247
+ {error ? (
248
+ <p className="border-error/40 text-error rounded-md border p-2 text-sm">
249
+ {error}
250
+ </p>
251
+ ) : null}
252
+ </div>
253
+ <DialogActions
254
+ cancelLabel={t('common.cancel', { defaultValue: 'Cancel' })}
255
+ onCancel={onClose}
256
+ actionLabel={t('common.save', { defaultValue: 'Save' })}
257
+ onAction={submit}
258
+ disabled={submitting}
259
+ />
260
+ </DialogContent>
261
+ </Dialog>
262
+ );
263
+ };
@@ -8,6 +8,9 @@ import { Eye, EyeOff } from 'lucide-react';
8
8
  import { useForm } from 'react-hook-form';
9
9
  import { zodResolver } from '@hookform/resolvers/zod';
10
10
  import {
11
+ accountNameSchema,
12
+ HANDLE_RESERVED_MESSAGE,
13
+ isForbiddenHandle,
11
14
  registerRequestSchema,
12
15
  type RegisterRequest,
13
16
  } from '@openpeepshq/common/types';
@@ -43,7 +46,10 @@ const INVITE_INACTIVE_MESSAGES = new Set([
43
46
  'Invalid Invite Code',
44
47
  ]);
45
48
 
46
- const buildRegisterFormSchema = (t: TFunction) =>
49
+ const buildRegisterFormSchema = (
50
+ t: TFunction,
51
+ additionalForbiddenHandles: readonly string[] = [],
52
+ ) =>
47
53
  registerRequestSchema
48
54
  .refine((d) => d.password === d.confirmPassword, {
49
55
  message: t('auth.register.passwordsDoNotMatch', {
@@ -56,14 +62,32 @@ const buildRegisterFormSchema = (t: TFunction) =>
56
62
  defaultValue: 'You must agree to the privacy policy',
57
63
  }),
58
64
  path: ['privacyPolicyAccepted'],
65
+ })
66
+ .superRefine((data, ctx) => {
67
+ if (!isForbiddenHandle(data.handle, additionalForbiddenHandles)) return;
68
+ // Built-in names already fail accountNameSchema.
69
+ if (!accountNameSchema.safeParse(data.handle).success) return;
70
+ ctx.addIssue({
71
+ code: 'custom',
72
+ path: ['handle'],
73
+ message: t('profile.form.handleReserved', {
74
+ defaultValue: 'That handle is reserved. Please choose another.',
75
+ }),
76
+ });
59
77
  });
60
78
 
61
- const registerErrorCopy = (raw: string, t: TFunction) =>
62
- INVITE_INACTIVE_MESSAGES.has(raw)
79
+ const registerErrorCopy = (raw: string, t: TFunction) => {
80
+ if (raw === HANDLE_RESERVED_MESSAGE) {
81
+ return t('profile.form.handleReserved', {
82
+ defaultValue: 'That handle is reserved. Please choose another.',
83
+ });
84
+ }
85
+ return INVITE_INACTIVE_MESSAGES.has(raw)
63
86
  ? t('auth.register.inviteInactive', {
64
87
  defaultValue: 'This invite link is expired or no longer active.',
65
88
  })
66
89
  : t(raw);
90
+ };
67
91
 
68
92
  export function Register({ invite = false }: RegisterProps) {
69
93
  const t = useT();
@@ -75,7 +99,12 @@ export function Register({ invite = false }: RegisterProps) {
75
99
  const serverInfo = useServerInfo();
76
100
  const { success, error: toastError } = useToast();
77
101
 
78
- const registerFormSchema = useMemo(() => buildRegisterFormSchema(t), [t]);
102
+ const additionalForbiddenHandles =
103
+ serverInfo.communityConfig?.settings?.additionalForbiddenHandles;
104
+ const registerFormSchema = useMemo(
105
+ () => buildRegisterFormSchema(t, additionalForbiddenHandles ?? []),
106
+ [t, additionalForbiddenHandles],
107
+ );
79
108
 
80
109
  const paymentParam = searchParams.get('payment');
81
110
  useEffect(() => {
@@ -311,6 +340,18 @@ export function Register({ invite = false }: RegisterProps) {
311
340
  )}
312
341
  />
313
342
 
343
+ {password && password.length > 0 && (
344
+ <p
345
+ data-testid="auth-register-password-rules"
346
+ className="text-xs text-muted-foreground"
347
+ >
348
+ {t('auth.register.passwordRules', {
349
+ defaultValue:
350
+ '8+ characters, with an uppercase letter, lowercase letter, number, and symbol',
351
+ })}
352
+ </p>
353
+ )}
354
+
314
355
  {(password ?? '').length > 0 &&
315
356
  (confirmPassword ?? '').length === 0 && (
316
357
  <div className="bg-surface border-border flex w-full justify-center rounded py-2">
@@ -139,6 +139,17 @@ export function ConversationShow() {
139
139
  };
140
140
  }, [id, client, queryClient, flushPostViews]);
141
141
 
142
+ // The URL may point at any root of a merged 1:1 conversation (e.g.
143
+ // notification links); unseen counts are merged under the pair's oldest
144
+ // root, so clear that key once the conversation's first message is known.
145
+ const firstMessageId = messages[0]?.id;
146
+ useEffect(() => {
147
+ if (!id || !firstMessageId || firstMessageId === id) return;
148
+ adjustUnseenCounts(queryClient, client, {
149
+ clearConversation: firstMessageId,
150
+ });
151
+ }, [id, firstMessageId, client, queryClient]);
152
+
142
153
  useEffect(() => {
143
154
  if (!id || !me || conversationQuery.isLoading) return;
144
155
  const unseenIds = messages
@@ -57,6 +57,7 @@ export { AnalyticsGroupsPage } from './admin/Analytics';
57
57
  export { AnalyticsPluginPage } from './admin/Analytics';
58
58
  export { AnalyticsReportSettingsPage } from './admin/Analytics';
59
59
  export { AdminBackups } from './admin/Backups';
60
+ export { AdminMedia } from './admin/Media';
60
61
  export { AdminGroups } from './admin/Groups';
61
62
  export { AdminInvites } from './admin/Invites';
62
63
  export { AdminMembers } from './admin/Members';
@@ -82,6 +83,7 @@ export { CommunityMarkdownPage } from './admin/community/CommunityMarkdownPage';
82
83
  export { AdminConfigurationCommunityFavicons } from './admin/community/CommunityFavicons';
83
84
  export { AdminConfigurationCommunityTheme } from './admin/community/CommunityTheme';
84
85
  export { AdminConfigurationCommunityProfileFields } from './admin/community/CommunityProfileFields';
86
+ export { AdminConfigurationCommunityForbiddenUsernames } from './admin/community/CommunityForbiddenUsernames';
85
87
  export { AdminConfigurationCommunityRoles } from './admin/community/CommunityRoles';
86
88
  export { AdminGroupMembers } from './admin/GroupMembers';
87
89
  export { AdminReports } from './admin/Reports';
@@ -89,6 +91,7 @@ export { AdminApiKeys } from './admin/ApiKeys';
89
91
  export { AdminPlugins } from './admin/Plugins';
90
92
  export { AdminDiagnostics } from './admin/Diagnostics';
91
93
  export { AdminDiagnosticsEmail } from './admin/DiagnosticsEmail';
94
+ export { AdminDiagnosticsLivekit } from './admin/DiagnosticsLivekit';
92
95
  export { AdminDiagnosticsLogs } from './admin/DiagnosticsLogs';
93
96
  export { AdminConfigurationEmail } from './admin/ConfigurationEmail';
94
97
  export { AdminConfigurationSso } from './admin/ConfigurationSso';
@@ -10,6 +10,7 @@ import {
10
10
  import {
11
11
  EventsFeed,
12
12
  LiveJamsSection,
13
+ LivekitUnavailableNotice,
13
14
  useCreateNewJam,
14
15
  useServerInfo,
15
16
  } from '../../components';
@@ -77,12 +78,7 @@ export function JamsIndex({ my = false }: Props) {
77
78
  return (
78
79
  <div className="p-4">
79
80
  {!serverInfo.jams.livekit.enabled ? (
80
- <p role="status" className="text-destructive mb-4 text-sm">
81
- {t('jams.unavailable.message', {
82
- defaultValue:
83
- 'Jams are unavailable because LiveKit is not connected.',
84
- })}
85
- </p>
81
+ <LivekitUnavailableNotice className="text-destructive mb-4 text-sm" />
86
82
  ) : null}
87
83
  {!my && serverInfo.jams.livekit.enabled ? <LiveJamsSection /> : null}
88
84
 
@@ -14,6 +14,7 @@ export const EditResource = () => {
14
14
  postData,
15
15
  setPostData,
16
16
  resourceTitle,
17
+ canSubmit,
17
18
  submitting,
18
19
  error,
19
20
  clearError,
@@ -26,14 +27,14 @@ export const EditResource = () => {
26
27
  title={t('resources.update.title', { defaultValue: 'Update resource' })}
27
28
  variant="default"
28
29
  action={submit}
29
- disabled={submitting}
30
+ disabled={submitting || !canSubmit}
30
31
  >
31
32
  {submitting
32
33
  ? t('common.saving', { defaultValue: 'Saving…' })
33
34
  : t('resources.update.title', { defaultValue: 'Update resource' })}
34
35
  </Button>
35
36
  ),
36
- [submit, submitting, t],
37
+ [canSubmit, submit, submitting, t],
37
38
  );
38
39
 
39
40
  useSetPageHeader(
@@ -10,6 +10,7 @@ export const NewResource = () => {
10
10
  postData,
11
11
  setPostData,
12
12
  canSubmit,
13
+ groupOnly,
13
14
  submitting,
14
15
  error,
15
16
  clearError,
@@ -40,7 +41,11 @@ export const NewResource = () => {
40
41
 
41
42
  return (
42
43
  <div className="pb-12">
43
- <ResourceForm postData={postData} onChange={setPostData} />
44
+ <ResourceForm
45
+ postData={postData}
46
+ onChange={setPostData}
47
+ groupOnly={groupOnly}
48
+ />
44
49
  {error ? (
45
50
  <div className="px-3">
46
51
  <Toast variant="error" onDismiss={clearError}>
@@ -1,11 +1,12 @@
1
1
  import { useState } from 'react';
2
2
  import { useT, useOpenpeeps, useSetPageHeader } from '../../index';
3
- import { useCurrentAccount } from '../../components';
3
+ import { useCurrentAccount, useToast } from '../../components';
4
4
  import { Button, Input, Label, Toast } from '@openpeepshq/react-ui';
5
5
 
6
6
  export function AccountSettings() {
7
7
  const t = useT();
8
8
  const { openpeepsApi, client } = useOpenpeeps();
9
+ const { success, error: toastError } = useToast();
9
10
  const account = useCurrentAccount();
10
11
  const updateAccount = openpeepsApi.updateCurrentAccountAction();
11
12
 
@@ -65,6 +66,29 @@ export function AccountSettings() {
65
66
  }
66
67
  };
67
68
 
69
+ const validateEmail = openpeepsApi.validationEmailAction();
70
+ const [verifying, setVerifying] = useState(false);
71
+
72
+ const handleVerifyEmail = async () => {
73
+ setVerifying(true);
74
+ try {
75
+ await validateEmail();
76
+ success(
77
+ t('settings.account.verifyEmailSent', {
78
+ defaultValue: 'Verification email sent',
79
+ }),
80
+ );
81
+ } catch {
82
+ toastError(
83
+ t('settings.account.verifyEmailError', {
84
+ defaultValue: 'Failed to send verification email',
85
+ }),
86
+ );
87
+ } finally {
88
+ setVerifying(false);
89
+ }
90
+ };
91
+
68
92
  const exportAccount = async () => {
69
93
  setExporting(true);
70
94
  try {
@@ -136,6 +160,32 @@ export function AccountSettings() {
136
160
  />
137
161
  </div>
138
162
 
163
+ {!account?.emailValidated ? (
164
+ <div className="space-y-2">
165
+ <p className="text-muted-foreground text-sm">
166
+ {t('settings.account.verifyEmailDescription', {
167
+ defaultValue:
168
+ 'Your email is not verified. Resend a verification email.',
169
+ })}
170
+ </p>
171
+ <Button
172
+ title={t('settings.account.verifyEmailButton', {
173
+ defaultValue: 'Verify email',
174
+ })}
175
+ variant="outline"
176
+ action={handleVerifyEmail}
177
+ loading={verifying}
178
+ data-testid="settings-verify-email-button"
179
+ >
180
+ {verifying
181
+ ? t('common.submitting', { defaultValue: 'Sending...' })
182
+ : t('settings.account.verifyEmailButton', {
183
+ defaultValue: 'Verify email',
184
+ })}
185
+ </Button>
186
+ </div>
187
+ ) : null}
188
+
139
189
  <div className="space-y-2">
140
190
  <Label htmlFor="newPassword">
141
191
  {t('settings.account.newPassword', {
@@ -2,6 +2,8 @@ import { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import type { ProfileWithMeta } from '@openpeepshq/common/types';
3
3
  import {
4
4
  accountNameSchema,
5
+ HANDLE_RESERVED_MESSAGE,
6
+ isForbiddenHandle,
5
7
  profileDataSchema,
6
8
  } from '@openpeepshq/common/types';
7
9
  import { useT, useOpenpeeps, useSetPageHeader } from '../../index';
@@ -62,11 +64,19 @@ export function PublicProfileSettings() {
62
64
 
63
65
  if (!me) return null;
64
66
 
67
+ const additionalForbiddenHandles =
68
+ serverInfo.communityConfig?.settings?.additionalForbiddenHandles;
69
+
65
70
  const validateHandle = (value: string): string | null => {
71
+ if (isForbiddenHandle(value, additionalForbiddenHandles)) {
72
+ return t('profile.form.handleReserved', {
73
+ defaultValue: 'That handle is reserved. Please choose another.',
74
+ });
75
+ }
66
76
  const result = accountNameSchema.safeParse(value);
67
77
  if (result.success) return null;
68
78
  const message = firstZodMessage(result.error);
69
- if (message === 'Handle is reserved') {
79
+ if (message === HANDLE_RESERVED_MESSAGE) {
70
80
  return t('profile.form.handleReserved', {
71
81
  defaultValue: 'That handle is reserved. Please choose another.',
72
82
  });
@@ -115,7 +125,7 @@ export function PublicProfileSettings() {
115
125
  const message = firstZodMessage(err);
116
126
  if (message?.toLowerCase().includes('handle')) {
117
127
  setHandleError(
118
- message === 'Handle is reserved'
128
+ message === HANDLE_RESERVED_MESSAGE
119
129
  ? t('profile.form.handleReserved', {
120
130
  defaultValue:
121
131
  'That handle is reserved. Please choose another.',
@@ -128,6 +138,14 @@ export function PublicProfileSettings() {
128
138
  return;
129
139
  }
130
140
  }
141
+ if ((err as Error).message === HANDLE_RESERVED_MESSAGE) {
142
+ setHandleError(
143
+ t('profile.form.handleReserved', {
144
+ defaultValue: 'That handle is reserved. Please choose another.',
145
+ }),
146
+ );
147
+ return;
148
+ }
131
149
  if (isDuplicateHandleError(err)) {
132
150
  const msg = t('profiles.handleExists', {
133
151
  defaultValue: 'This handle is already in use by someone else.',
package/src/pwa/sw.ts CHANGED
@@ -23,7 +23,10 @@
23
23
  * - notificationclick `goto:` action → focus matching client / open window
24
24
  */
25
25
 
26
- import type { NotificationOptionsType, PushMessage } from '@openpeepshq/common';
26
+ import type {
27
+ NotificationOptions as NotificationOptionsData,
28
+ PushMessage,
29
+ } from '@openpeepshq/common';
27
30
  import { resolveGotoTarget } from './navigationUrl';
28
31
 
29
32
  const PUSH_BASE_INVALIDATE_KEYS = [
@@ -120,7 +123,7 @@ self.addEventListener('push', (event) => {
120
123
  if (notification) {
121
124
  await self.registration.showNotification(
122
125
  notification.title ?? '',
123
- notification.options,
126
+ notification.options as unknown as NotificationOptions,
124
127
  );
125
128
  }
126
129
  })(),
@@ -130,7 +133,7 @@ self.addEventListener('push', (event) => {
130
133
  self.addEventListener('notificationclick', (event) => {
131
134
  const action =
132
135
  event.action ||
133
- (event.notification as unknown as NotificationOptionsType)?.actions?.[0]
136
+ (event.notification as unknown as NotificationOptionsData)?.actions?.[0]
134
137
  ?.action ||
135
138
  '';
136
139
 
@@ -27,7 +27,9 @@ export const useNotificationBadgeSync = (): void => {
27
27
  syncFromCache();
28
28
 
29
29
  return queryClient.getQueryCache().subscribe((event) => {
30
- if (!matchesQueryKey(event.query.queryKey, NOTIFICATION_STATS_QUERY_KEY)) {
30
+ if (
31
+ !matchesQueryKey(event.query.queryKey, NOTIFICATION_STATS_QUERY_KEY)
32
+ ) {
31
33
  return;
32
34
  }
33
35
  syncFromCache();
@@ -138,6 +138,7 @@ export {
138
138
  } from './components/jams/jamEventActions';
139
139
  export type { JamParticipantMetadata } from './components/jams/jamEventActions';
140
140
  export { useRaisedHands } from './components/jams/useJamHands';
141
+ export { useDropLateAudio } from './components/jams/dropLateAudio';
141
142
  export {
142
143
  calculateRecordingState,
143
144
  calculateRtmpStreamState,
@@ -92,7 +92,12 @@ export const eventSanitizer = (publicContent = false) => {
92
92
  end: event.data.end,
93
93
  attendeeListPublic: event.data.attendeeListPublic,
94
94
  ...(event.data.maxAttendees != null
95
- ? { maxAttendees: event.data.maxAttendees }
95
+ ? {
96
+ maxAttendees: event.data.maxAttendees,
97
+ ...(event.data.waitlistOfferMinutes != null
98
+ ? { waitlistOfferMinutes: event.data.waitlistOfferMinutes }
99
+ : {}),
100
+ }
96
101
  : {}),
97
102
  },
98
103
  mentions: event.mentions,
package/src/streaming.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * the origin the source URL was served from rather than the API base URL.
5
5
  */
6
6
  export const vodMasterPlaylistUrl = (
7
- storageId: string,
8
- origin: string,
7
+ storageId: string,
8
+ origin: string,
9
9
  ): string =>
10
- `${origin.replace(/\/$/, '')}/media/streaming/${storageId}/hls.m3u8`;
10
+ `${origin.replace(/\/$/, '')}/media/streaming/${storageId}/hls.m3u8`;
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1,5 +0,0 @@
1
- // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
- // allows you to do things like:
3
- // expect(element).toHaveTextContent(/react/i)
4
- // learn more: https://github.com/testing-library/jest-dom
5
- import '@testing-library/jest-dom';