@openpeepshq/react 0.6.3 → 0.7.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 (204) 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/groups/GroupHeader.js +2 -1
  5. package/dist/components/groups/GroupNotificationSettingsModal.d.ts +9 -0
  6. package/dist/components/groups/GroupNotificationSettingsModal.js +57 -0
  7. package/dist/components/groups/GroupShareMenu.js +30 -8
  8. package/dist/components/groups/index.d.ts +2 -0
  9. package/dist/components/groups/index.js +1 -0
  10. package/dist/components/jams/JamCapacityGate.js +1 -1
  11. package/dist/components/jams/JamConference.js +2 -0
  12. package/dist/components/jams/JamParticipantConference.js +2 -0
  13. package/dist/components/jams/JamRoom.js +2 -3
  14. package/dist/components/jams/LiveJamsSection.js +8 -2
  15. package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
  16. package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
  17. package/dist/components/jams/dropLateAudio.d.ts +22 -0
  18. package/dist/components/jams/dropLateAudio.js +115 -0
  19. package/dist/components/jams/index.d.ts +1 -0
  20. package/dist/components/jams/index.js +1 -0
  21. package/dist/components/notifications/TypedNotification.js +46 -4
  22. package/dist/components/post/Markdown.d.ts +2 -2
  23. package/dist/components/post/Markdown.js +1 -1
  24. package/dist/components/post/attachmentPreview.js +1 -1
  25. package/dist/components/post/pieces/Attachments.js +23 -17
  26. package/dist/components/post/pieces/EventRsvpButton.js +37 -7
  27. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  28. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  29. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  30. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  31. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  32. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  33. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  34. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  35. package/dist/components/post/pieces/PostActions.js +20 -12
  36. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  37. package/dist/components/post/pieces/ShareMenu.js +40 -7
  38. package/dist/components/post/post-form/EventForm.js +10 -2
  39. package/dist/components/post/types/Article.js +1 -1
  40. package/dist/components/post/types/article/FullArticle.js +1 -1
  41. package/dist/components/post/types/event/CardEvent.js +2 -1
  42. package/dist/components/post/types/event/FullEvent.js +21 -11
  43. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  44. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  45. package/dist/components/preview-link/PreviewLink.js +1 -1
  46. package/dist/components/preview-link/helpers.d.ts +5 -0
  47. package/dist/components/preview-link/helpers.js +27 -1
  48. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  49. package/dist/components/preview-link/local/WelcomePreview.js +6 -0
  50. package/dist/components/profile/Avatar.js +2 -2
  51. package/dist/components/profile/ProfileFromId.js +1 -1
  52. package/dist/components/server-data/context.d.ts +1 -0
  53. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  54. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  55. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  56. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  57. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  58. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  59. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  60. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  61. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  62. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  63. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  64. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  65. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  66. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  67. package/dist/hooks/events/useEventForm.d.ts +1 -0
  68. package/dist/hooks/events/useEventRsvp.d.ts +11 -2
  69. package/dist/hooks/events/useEventRsvp.js +46 -5
  70. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  71. package/dist/hooks/groups/useGroupNotificationLevel.d.ts +9 -0
  72. package/dist/hooks/groups/useGroupNotificationLevel.js +57 -0
  73. package/dist/hooks/groups/useNewGroup.js +22 -2
  74. package/dist/hooks/index.d.ts +6 -1
  75. package/dist/hooks/index.js +5 -1
  76. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  77. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  78. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  79. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  80. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  81. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  82. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  83. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  84. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  85. package/dist/hooks/posts/useResourceComposer.d.ts +93 -41
  86. package/dist/hooks/posts/useResourceComposer.js +4 -2
  87. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  88. package/dist/hooks/posts/useShareMenu.js +7 -0
  89. package/dist/hooks/resources/useResourceLibrary.d.ts +176 -78
  90. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  91. package/dist/hooks/useWelcomePreview.d.ts +13 -0
  92. package/dist/hooks/useWelcomePreview.js +39 -0
  93. package/dist/lib/groupFormErrors.d.ts +1 -0
  94. package/dist/lib/groupFormErrors.js +5 -2
  95. package/dist/lib/threadHelpers.js +1 -5
  96. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  97. package/dist/pages/admin/Diagnostics.js +1 -1
  98. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  99. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  100. package/dist/pages/admin/Invites.js +5 -3
  101. package/dist/pages/admin/Media.d.ts +1 -0
  102. package/dist/pages/admin/Media.js +135 -0
  103. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  104. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  105. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  106. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  107. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  108. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  109. package/dist/pages/admin/configurationSsoShared.d.ts +4 -0
  110. package/dist/pages/auth/Register.js +30 -8
  111. package/dist/pages/conversations/Show.js +11 -0
  112. package/dist/pages/groups/Show.js +22 -19
  113. package/dist/pages/index.d.ts +3 -0
  114. package/dist/pages/index.js +3 -0
  115. package/dist/pages/jams/Index.js +2 -4
  116. package/dist/pages/settings/PublicProfile.js +15 -3
  117. package/dist/pwa/sw.d.ts +0 -1
  118. package/dist/react-native.d.ts +2 -1
  119. package/dist/react-native.js +2 -1
  120. package/dist/stores/newPosts.d.ts +4 -2
  121. package/dist/stores/newPosts.js +6 -1
  122. package/package.json +11 -6
  123. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  124. package/src/components/configuration/ConfigurationList.tsx +6 -1
  125. package/src/components/form/LocationInput.tsx +7 -1
  126. package/src/components/groups/GroupHeader.tsx +2 -0
  127. package/src/components/groups/GroupNotificationSettingsModal.tsx +163 -0
  128. package/src/components/groups/GroupShareMenu.tsx +77 -12
  129. package/src/components/groups/index.ts +5 -0
  130. package/src/components/jams/JamCapacityGate.tsx +1 -1
  131. package/src/components/jams/JamConference.tsx +2 -0
  132. package/src/components/jams/JamParticipantConference.tsx +2 -0
  133. package/src/components/jams/JamRoom.tsx +2 -6
  134. package/src/components/jams/LiveJamsSection.tsx +16 -2
  135. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  136. package/src/components/jams/dropLateAudio.ts +153 -0
  137. package/src/components/jams/index.ts +1 -0
  138. package/src/components/notifications/TypedNotification.tsx +81 -9
  139. package/src/components/post/Markdown.tsx +8 -2
  140. package/src/components/post/attachmentPreview.ts +1 -3
  141. package/src/components/post/pieces/Attachments.tsx +93 -78
  142. package/src/components/post/pieces/EventRsvpButton.tsx +107 -7
  143. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  144. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  145. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  146. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  147. package/src/components/post/pieces/PostActions.tsx +73 -42
  148. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  149. package/src/components/post/post-form/EventForm.tsx +26 -0
  150. package/src/components/post/post-form/VisibilitySelector.tsx +1 -2
  151. package/src/components/post/types/Article.tsx +1 -1
  152. package/src/components/post/types/article/FullArticle.tsx +2 -2
  153. package/src/components/post/types/event/CardEvent.tsx +26 -14
  154. package/src/components/post/types/event/FullEvent.tsx +47 -29
  155. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  156. package/src/components/post/types/note/FullNote.tsx +1 -4
  157. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  158. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  159. package/src/components/preview-link/PreviewLink.tsx +2 -7
  160. package/src/components/preview-link/helpers.ts +32 -1
  161. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  162. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  163. package/src/components/preview-link/local/WelcomePreview.tsx +36 -0
  164. package/src/components/profile/Avatar.tsx +6 -2
  165. package/src/components/profile/ProfileFromId.tsx +1 -5
  166. package/src/components/resources/ResourceCard.tsx +0 -1
  167. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  168. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  169. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  170. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  171. package/src/css.d.ts +4 -0
  172. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  173. package/src/hooks/events/useEventRsvp.ts +51 -7
  174. package/src/hooks/groups/useGroupNotificationLevel.ts +57 -0
  175. package/src/hooks/groups/useNewGroup.ts +28 -3
  176. package/src/hooks/index.ts +9 -1
  177. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  178. package/src/hooks/posts/useResourceComposer.ts +8 -6
  179. package/src/hooks/posts/useShareMenu.ts +9 -0
  180. package/src/hooks/useWelcomePreview.ts +57 -0
  181. package/src/i18n/I18nProvider.tsx +1 -4
  182. package/src/lib/groupFormErrors.ts +9 -2
  183. package/src/lib/threadHelpers.ts +1 -5
  184. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  185. package/src/pages/admin/Diagnostics.tsx +4 -0
  186. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  187. package/src/pages/admin/Invites.tsx +23 -1
  188. package/src/pages/admin/Media.tsx +290 -0
  189. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  190. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  191. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  192. package/src/pages/auth/Register.tsx +33 -4
  193. package/src/pages/conversations/Show.tsx +11 -0
  194. package/src/pages/groups/Show.tsx +60 -53
  195. package/src/pages/index.ts +3 -0
  196. package/src/pages/jams/Index.tsx +2 -6
  197. package/src/pages/settings/PublicProfile.tsx +20 -2
  198. package/src/pwa/sw.ts +6 -3
  199. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  200. package/src/react-native.ts +2 -1
  201. package/src/stores/newPosts.ts +6 -1
  202. package/src/streaming.ts +3 -3
  203. package/dist/setupTests.d.ts +0 -1
  204. 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(() => {
@@ -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
@@ -1,5 +1,6 @@
1
- import { useState } from 'react';
2
- import { useNavigate, useParams } from 'react-router-dom';
1
+ import { useEffect, useState } from 'react';
2
+ import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
3
+ import { groupSectionFromHash } from '@openpeepshq/common/lib';
3
4
  import { useT, useOpenpeeps } from '../../index';
4
5
  import {
5
6
  EventsView,
@@ -18,6 +19,7 @@ import { ResourceLibrary } from '../../components/resources/ResourceLibrary';
18
19
  export function GroupShow() {
19
20
  const t = useT();
20
21
  const navigate = useNavigate();
22
+ const location = useLocation();
21
23
  const { handle: handleParam = '' } = useParams<{ handle: string }>();
22
24
  const handle = routeHandleParam(handleParam);
23
25
  const { openpeepsApi } = useOpenpeeps();
@@ -25,9 +27,21 @@ export function GroupShow() {
25
27
  const groupQuery = openpeepsApi.useGroupByHandle(handle);
26
28
  const group = groupQuery.data;
27
29
  const currentProfile = useCurrentProfile();
28
- const [tab, setTab] = useState<
29
- 'posts' | 'events' | 'resources' | 'description'
30
- >('posts');
30
+ const tab = groupSectionFromHash(location.hash);
31
+
32
+ // Raw anchors (shared links, markdown) change the hash without going
33
+ // through the router. Mirror that into the location so the tab follows.
34
+ useEffect(() => {
35
+ const syncHash = () => {
36
+ if (window.location.hash === location.hash) return;
37
+ navigate(
38
+ { pathname: location.pathname, hash: window.location.hash },
39
+ { replace: true },
40
+ );
41
+ };
42
+ window.addEventListener('hashchange', syncHash);
43
+ return () => window.removeEventListener('hashchange', syncHash);
44
+ }, [location.hash, location.pathname, navigate]);
31
45
 
32
46
  const upcomingEvents = openpeepsApi.useGroupUpcomingEventsFeed(
33
47
  group?.id ?? '',
@@ -91,57 +105,30 @@ export function GroupShow() {
91
105
  className="border-border flex border-b"
92
106
  data-testid="tab-group"
93
107
  >
94
- <TabButton
95
- active={tab === 'posts'}
96
- onClick={() => {
97
- setTab('posts');
98
- window.history.replaceState(null, '', window.location.pathname);
99
- }}
100
- >
108
+ <TabLink active={tab === 'posts'} hash="">
101
109
  {t('groups.sections.posts', { defaultValue: 'Posts' })}
102
- </TabButton>
103
- <TabButton
110
+ </TabLink>
111
+ <TabLink
104
112
  active={tab === 'events'}
105
- onClick={() => {
106
- setTab('events');
107
- window.history.replaceState(
108
- null,
109
- '',
110
- `${window.location.pathname}#events`,
111
- );
112
- }}
113
+ hash="#events"
113
114
  testId="groups-tab-events"
114
115
  >
115
116
  {t('groups.sections.events', { defaultValue: 'Events' })}
116
- </TabButton>
117
- <TabButton
117
+ </TabLink>
118
+ <TabLink
118
119
  active={tab === 'resources'}
119
- onClick={() => {
120
- setTab('resources');
121
- window.history.replaceState(
122
- null,
123
- '',
124
- `${window.location.pathname}#resources`,
125
- );
126
- }}
120
+ hash="#resources"
127
121
  testId="groups-tab-resources"
128
122
  >
129
123
  {t('groups.sections.resources', { defaultValue: 'Resources' })}
130
- </TabButton>
131
- <TabButton
124
+ </TabLink>
125
+ <TabLink
132
126
  active={tab === 'description'}
133
- onClick={() => {
134
- setTab('description');
135
- window.history.replaceState(
136
- null,
137
- '',
138
- `${window.location.pathname}#description`,
139
- );
140
- }}
127
+ hash="#description"
141
128
  testId="groups-tab-description"
142
129
  >
143
130
  {t('groups.sections.description', { defaultValue: 'Description' })}
144
- </TabButton>
131
+ </TabLink>
145
132
  </nav>
146
133
 
147
134
  {tab === 'posts' && <GroupFeed group={group} />}
@@ -247,25 +234,45 @@ export function GroupShow() {
247
234
  );
248
235
  }
249
236
 
250
- function TabButton({
237
+ const TabLink = ({
251
238
  active,
252
- onClick,
239
+ hash,
253
240
  children,
254
241
  testId,
255
242
  }: {
256
243
  active: boolean;
257
- onClick: () => void;
244
+ hash: string;
258
245
  children: React.ReactNode;
259
246
  testId?: string;
260
- }) {
247
+ }) => {
248
+ const location = useLocation();
261
249
  return (
262
- <button
263
- type="button"
264
- onClick={onClick}
250
+ <Link
251
+ replace
252
+ to={{ pathname: location.pathname, hash }}
265
253
  data-testid={testId}
266
- className={`px-4 py-2 text-sm ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`}
254
+ aria-current={active ? 'page' : undefined}
255
+ className={`px-4 py-2 text-sm no-underline ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`}
267
256
  >
268
257
  {children}
269
- </button>
258
+ </Link>
270
259
  );
271
- }
260
+ };
261
+
262
+ const TabButton = ({
263
+ active,
264
+ onClick,
265
+ children,
266
+ }: {
267
+ active: boolean;
268
+ onClick: () => void;
269
+ children: React.ReactNode;
270
+ }) => (
271
+ <button
272
+ type="button"
273
+ onClick={onClick}
274
+ className={`px-4 py-2 text-sm ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`}
275
+ >
276
+ {children}
277
+ </button>
278
+ );
@@ -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
 
@@ -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();
@@ -15,7 +15,7 @@ export {
15
15
  hueFromHandle,
16
16
  initialsBackground,
17
17
  } from './lib/initialsAvatar';
18
- export { svgCoverSrc } from './lib/svgCover';
18
+ export { isSvgUrl, svgCoverSrc } from './lib/svgCover';
19
19
  export * from './lib/capabilityMatrix';
20
20
  export * from './lib/groupFormErrors';
21
21
  export * from './lib/passwordStrength';
@@ -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,