@openpeepshq/react 0.7.0 → 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 (188) 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/notifications/TypedNotification.js +46 -4
  16. package/dist/components/post/Markdown.d.ts +2 -2
  17. package/dist/components/post/Markdown.js +1 -1
  18. package/dist/components/post/attachmentPreview.js +1 -1
  19. package/dist/components/post/pieces/Attachments.js +23 -17
  20. package/dist/components/post/pieces/EventRsvpButton.js +37 -7
  21. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  22. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  23. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  24. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  25. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  26. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  27. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  28. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  29. package/dist/components/post/pieces/PostActions.js +20 -12
  30. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  31. package/dist/components/post/pieces/ShareMenu.js +40 -7
  32. package/dist/components/post/post-form/EventForm.js +10 -2
  33. package/dist/components/post/types/Article.js +1 -1
  34. package/dist/components/post/types/article/FullArticle.js +1 -1
  35. package/dist/components/post/types/event/CardEvent.js +2 -1
  36. package/dist/components/post/types/event/FullEvent.js +22 -13
  37. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  38. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  39. package/dist/components/preview-link/PreviewLink.js +1 -1
  40. package/dist/components/preview-link/helpers.d.ts +5 -0
  41. package/dist/components/preview-link/helpers.js +27 -1
  42. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  43. package/dist/components/preview-link/local/WelcomePreview.js +6 -0
  44. package/dist/components/profile/Avatar.js +2 -2
  45. package/dist/components/profile/ProfileFromId.js +1 -1
  46. package/dist/components/server-data/context.d.ts +1 -0
  47. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  48. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  49. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  50. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  51. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  52. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  53. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  54. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  55. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  56. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  57. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  58. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  59. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  60. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  61. package/dist/hooks/events/useEventForm.d.ts +1 -0
  62. package/dist/hooks/events/useEventRsvp.d.ts +11 -2
  63. package/dist/hooks/events/useEventRsvp.js +46 -5
  64. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  65. package/dist/hooks/groups/useNewGroup.js +22 -2
  66. package/dist/hooks/index.d.ts +5 -1
  67. package/dist/hooks/index.js +4 -1
  68. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  69. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  70. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  71. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  72. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  73. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  74. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  75. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  76. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  77. package/dist/hooks/posts/useResourceComposer.d.ts +93 -41
  78. package/dist/hooks/posts/useResourceComposer.js +4 -2
  79. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  80. package/dist/hooks/posts/useShareMenu.js +7 -0
  81. package/dist/hooks/resources/useResourceLibrary.d.ts +176 -78
  82. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  83. package/dist/hooks/useWelcomePreview.d.ts +13 -0
  84. package/dist/hooks/useWelcomePreview.js +39 -0
  85. package/dist/lib/groupFormErrors.d.ts +1 -0
  86. package/dist/lib/groupFormErrors.js +5 -2
  87. package/dist/lib/threadHelpers.js +1 -5
  88. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  89. package/dist/pages/admin/Diagnostics.js +1 -1
  90. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  91. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  92. package/dist/pages/admin/Invites.js +5 -3
  93. package/dist/pages/admin/Media.d.ts +1 -0
  94. package/dist/pages/admin/Media.js +135 -0
  95. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  96. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  97. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  98. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  99. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  100. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  101. package/dist/pages/auth/Register.js +30 -8
  102. package/dist/pages/conversations/Show.js +11 -0
  103. package/dist/pages/index.d.ts +3 -0
  104. package/dist/pages/index.js +3 -0
  105. package/dist/pages/jams/Index.js +2 -4
  106. package/dist/pages/settings/PublicProfile.js +15 -3
  107. package/dist/pwa/sw.d.ts +0 -1
  108. package/dist/react-native.d.ts +1 -0
  109. package/dist/react-native.js +1 -0
  110. package/dist/stores/newPosts.d.ts +4 -2
  111. package/dist/stores/newPosts.js +6 -1
  112. package/package.json +12 -7
  113. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  114. package/src/components/configuration/ConfigurationList.tsx +6 -1
  115. package/src/components/form/LocationInput.tsx +7 -1
  116. package/src/components/jams/JamCapacityGate.tsx +1 -1
  117. package/src/components/jams/JamConference.tsx +2 -0
  118. package/src/components/jams/JamParticipantConference.tsx +2 -0
  119. package/src/components/jams/JamRoom.tsx +2 -6
  120. package/src/components/jams/LiveJamsSection.tsx +16 -2
  121. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  122. package/src/components/jams/dropLateAudio.ts +153 -0
  123. package/src/components/jams/index.ts +1 -0
  124. package/src/components/notifications/TypedNotification.tsx +81 -9
  125. package/src/components/post/Markdown.tsx +8 -2
  126. package/src/components/post/attachmentPreview.ts +1 -3
  127. package/src/components/post/pieces/Attachments.tsx +93 -78
  128. package/src/components/post/pieces/EventRsvpButton.tsx +107 -7
  129. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  130. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  131. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  132. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  133. package/src/components/post/pieces/PostActions.tsx +73 -42
  134. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  135. package/src/components/post/post-form/EventForm.tsx +26 -0
  136. package/src/components/post/post-form/VisibilitySelector.tsx +1 -2
  137. package/src/components/post/types/Article.tsx +1 -1
  138. package/src/components/post/types/article/FullArticle.tsx +2 -2
  139. package/src/components/post/types/event/CardEvent.tsx +26 -14
  140. package/src/components/post/types/event/FullEvent.tsx +48 -35
  141. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  142. package/src/components/post/types/note/FullNote.tsx +1 -4
  143. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  144. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  145. package/src/components/preview-link/PreviewLink.tsx +2 -7
  146. package/src/components/preview-link/helpers.ts +32 -1
  147. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  148. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  149. package/src/components/preview-link/local/WelcomePreview.tsx +36 -0
  150. package/src/components/profile/Avatar.tsx +6 -2
  151. package/src/components/profile/ProfileFromId.tsx +1 -5
  152. package/src/components/resources/ResourceCard.tsx +0 -1
  153. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  154. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  155. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  156. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  157. package/src/css.d.ts +4 -0
  158. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  159. package/src/hooks/events/useEventRsvp.ts +51 -7
  160. package/src/hooks/groups/useNewGroup.ts +28 -3
  161. package/src/hooks/index.ts +8 -1
  162. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  163. package/src/hooks/posts/useResourceComposer.ts +8 -6
  164. package/src/hooks/posts/useShareMenu.ts +9 -0
  165. package/src/hooks/useWelcomePreview.ts +57 -0
  166. package/src/i18n/I18nProvider.tsx +1 -4
  167. package/src/lib/groupFormErrors.ts +9 -2
  168. package/src/lib/threadHelpers.ts +1 -5
  169. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  170. package/src/pages/admin/Diagnostics.tsx +4 -0
  171. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  172. package/src/pages/admin/Invites.tsx +23 -1
  173. package/src/pages/admin/Media.tsx +290 -0
  174. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  175. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  176. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  177. package/src/pages/auth/Register.tsx +33 -4
  178. package/src/pages/conversations/Show.tsx +11 -0
  179. package/src/pages/index.ts +3 -0
  180. package/src/pages/jams/Index.tsx +2 -6
  181. package/src/pages/settings/PublicProfile.tsx +20 -2
  182. package/src/pwa/sw.ts +6 -3
  183. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  184. package/src/react-native.ts +1 -0
  185. package/src/stores/newPosts.ts +6 -1
  186. package/src/streaming.ts +3 -3
  187. package/dist/setupTests.d.ts +0 -1
  188. package/dist/setupTests.js +0 -5
@@ -1,9 +1,10 @@
1
- import { useState } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
  import { ChevronDown, ChevronRight, PhoneOff } from 'lucide-react';
3
3
  import { useOpenpeeps } from '../../contexts/openpeeps';
4
4
  import { useT } from '../../i18n';
5
5
  import { AccessDeniedLoader } from '../layout/AccessDeniedLoader';
6
6
  import { CardEvent } from '../post/types/event/CardEvent';
7
+ import { LivekitUnavailableNotice } from './LivekitUnavailableNotice';
7
8
 
8
9
  export function LiveJamsSection() {
9
10
  const t = useT();
@@ -11,6 +12,14 @@ export function LiveJamsSection() {
11
12
  const liveJamsQuery = openpeepsApi.useJams();
12
13
  const [open, setOpen] = useState(true);
13
14
 
15
+ useEffect(() => {
16
+ if (!liveJamsQuery.isError) return;
17
+ console.error(
18
+ '[openpeeps] Live jams failed to load. Community admins can diagnose LiveKit at /admin/diagnostics/livekit.',
19
+ liveJamsQuery.error,
20
+ );
21
+ }, [liveJamsQuery.isError, liveJamsQuery.error]);
22
+
14
23
  return (
15
24
  <section className="mb-8">
16
25
  <button
@@ -29,7 +38,12 @@ export function LiveJamsSection() {
29
38
  </button>
30
39
 
31
40
  {open ? (
32
- <AccessDeniedLoader queries={[liveJamsQuery]}>
41
+ <AccessDeniedLoader
42
+ queries={[liveJamsQuery]}
43
+ fallbackError={
44
+ <LivekitUnavailableNotice className="text-destructive text-sm" />
45
+ }
46
+ >
33
47
  {(liveJamsQuery.data ?? []).length ? (
34
48
  <div
35
49
  role="feed"
@@ -0,0 +1,40 @@
1
+ import { Link } from 'react-router-dom';
2
+ import { useT } from '../../i18n';
3
+ import { useCanDiagnoseLivekit } from '../../hooks/jams/useCanDiagnoseLivekit';
4
+
5
+ export const LIVEKIT_DIAGNOSTICS_PATH = '/admin/diagnostics/livekit';
6
+
7
+ /**
8
+ * Shown when live jams are off or the live list fails. Only admins who can open
9
+ * Diagnostics get a link to the LiveKit diagnosis page; others just see the
10
+ * message (the failure itself is logged where the query is consumed).
11
+ */
12
+ export const LivekitUnavailableNotice = ({
13
+ className = 'text-destructive text-sm',
14
+ }: {
15
+ className?: string;
16
+ }) => {
17
+ const t = useT();
18
+ const canDiagnose = useCanDiagnoseLivekit();
19
+
20
+ return (
21
+ <p role="status" className={className}>
22
+ {t('jams.unavailable.message', {
23
+ defaultValue: 'Jams are unavailable because LiveKit is not connected.',
24
+ })}
25
+ {canDiagnose ? (
26
+ <>
27
+ {' '}
28
+ <Link
29
+ to={LIVEKIT_DIAGNOSTICS_PATH}
30
+ className="text-primary underline"
31
+ >
32
+ {t('jams.unavailable.diagnose', {
33
+ defaultValue: 'Diagnose LiveKit',
34
+ })}
35
+ </Link>
36
+ </>
37
+ ) : null}
38
+ </p>
39
+ );
40
+ };
@@ -0,0 +1,153 @@
1
+ import { useEffect } from 'react';
2
+ import {
3
+ RoomEvent,
4
+ Track,
5
+ isRemoteTrack,
6
+ type RemoteTrack,
7
+ type Room,
8
+ } from 'livekit-client';
9
+
10
+ const FRAME_MS = 20;
11
+ const CALIBRATION_DELTAS = 3;
12
+ const WARMUP_FRAMES = 8;
13
+ /**
14
+ * Audio older than this is the backlog Chromium otherwise holds and then
15
+ * plays faster until it matches the person speaking now.
16
+ */
17
+ const LATE_MS = 200;
18
+
19
+ type StampedFrame = { timestamp: number };
20
+
21
+ type EncodedReceiver = RTCRtpReceiver & {
22
+ createEncodedStreams?: () => {
23
+ readable: ReadableStream<StampedFrame>;
24
+ writable: WritableStream<StampedFrame>;
25
+ };
26
+ };
27
+
28
+ /** Opus frames are 20ms apart. The median gap is the receiver clock. */
29
+ export const audioClockPerMs = (deltas: number[]): number | undefined => {
30
+ if (deltas.length < CALIBRATION_DELTAS) return undefined;
31
+ const sorted = [...deltas].sort((a, b) => a - b);
32
+ const mid = sorted[Math.floor(sorted.length / 2)];
33
+ if (mid === undefined || mid <= 0) return undefined;
34
+ return mid / FRAME_MS;
35
+ };
36
+
37
+ export const isLateAudioFrame = (
38
+ timestamp: number,
39
+ expectedTimestamp: number,
40
+ clockPerMs: number,
41
+ ): boolean =>
42
+ clockPerMs > 0 && (expectedTimestamp - timestamp) / clockPerMs > LATE_MS;
43
+
44
+ /**
45
+ * Drop microphone frames that arrive already late, so Chromium's jitter
46
+ * buffer never builds the backlog it later time-stretches.
47
+ * Returns when the receiver has no encoded-stream hook or it was already taken.
48
+ */
49
+ export const installLateAudioDrop = (
50
+ receiver: EncodedReceiver,
51
+ now: () => number = () => performance.now(),
52
+ ): Promise<void> | undefined => {
53
+ if (!receiver.createEncodedStreams) return undefined;
54
+ let readable: ReadableStream<StampedFrame>;
55
+ let writable: WritableStream<StampedFrame>;
56
+ try {
57
+ ({ readable, writable } = receiver.createEncodedStreams());
58
+ } catch {
59
+ return undefined;
60
+ }
61
+
62
+ let anchorTimestamp: number | undefined;
63
+ let anchorWall: number | undefined;
64
+ let lastTimestamp: number | undefined;
65
+ let seen = 0;
66
+ const deltas: number[] = [];
67
+ let clockPerMs: number | undefined;
68
+
69
+ return readable
70
+ .pipeThrough(
71
+ new TransformStream<StampedFrame, StampedFrame>({
72
+ transform: (frame, controller) => {
73
+ let forwarded = false;
74
+ const forward = () => {
75
+ if (forwarded) return;
76
+ forwarded = true;
77
+ controller.enqueue(frame);
78
+ };
79
+ try {
80
+ const wall = now();
81
+ if (
82
+ lastTimestamp !== undefined &&
83
+ deltas.length < CALIBRATION_DELTAS
84
+ ) {
85
+ deltas.push(frame.timestamp - lastTimestamp);
86
+ clockPerMs = audioClockPerMs(deltas);
87
+ }
88
+ if (anchorTimestamp === undefined) {
89
+ anchorTimestamp = frame.timestamp;
90
+ anchorWall = wall;
91
+ }
92
+ lastTimestamp = frame.timestamp;
93
+ seen += 1;
94
+ const expected =
95
+ anchorTimestamp +
96
+ (wall - (anchorWall ?? wall)) * (clockPerMs ?? 0);
97
+ if (
98
+ clockPerMs !== undefined &&
99
+ seen > WARMUP_FRAMES &&
100
+ isLateAudioFrame(frame.timestamp, expected, clockPerMs)
101
+ ) {
102
+ // Closing a skipped frame tears the receiver down and the
103
+ // rest of the call goes silent.
104
+ return;
105
+ }
106
+ forward();
107
+ } catch {
108
+ forward();
109
+ }
110
+ },
111
+ }),
112
+ )
113
+ .pipeTo(writable)
114
+ .catch(() => undefined);
115
+ };
116
+
117
+ /** Skip late remote microphone audio for everyone in this room. */
118
+ export const useDropLateAudio = (room: Room) => {
119
+ useEffect(() => {
120
+ const installed = new WeakSet<RTCRtpReceiver>();
121
+ const install = (track: RemoteTrack, source: Track.Source) => {
122
+ if (
123
+ track.kind !== Track.Kind.Audio ||
124
+ source !== Track.Source.Microphone ||
125
+ !track.receiver ||
126
+ installed.has(track.receiver)
127
+ ) {
128
+ return;
129
+ }
130
+ installed.add(track.receiver);
131
+ installLateAudioDrop(track.receiver);
132
+ };
133
+
134
+ room.remoteParticipants.forEach((participant) => {
135
+ participant.audioTrackPublications.forEach((publication) => {
136
+ if (isRemoteTrack(publication.track)) {
137
+ install(publication.track, publication.source);
138
+ }
139
+ });
140
+ });
141
+
142
+ const onSubscribed = (
143
+ track: RemoteTrack,
144
+ publication: { source: Track.Source },
145
+ ) => {
146
+ install(track, publication.source);
147
+ };
148
+ room.on(RoomEvent.TrackSubscribed, onSubscribed);
149
+ return () => {
150
+ room.off(RoomEvent.TrackSubscribed, onSubscribed);
151
+ };
152
+ }, [room]);
153
+ };
@@ -21,4 +21,5 @@ export { JamDetailsDrawer } from './JamDetailsDrawer';
21
21
  export { JamEventsProvider, useJamEventsContext } from './JamEventsContext';
22
22
  export { JamGuestForm } from './JamGuestForm';
23
23
  export { LiveJamsSection } from './LiveJamsSection';
24
+ export { LivekitUnavailableNotice } from './LivekitUnavailableNotice';
24
25
  export { defaultRoomOptions, JAM_EMOJIS } from './constants';
@@ -11,7 +11,9 @@ import type { ReactNode } from 'react';
11
11
  import { profileName, groupName } from '@openpeepshq/common';
12
12
  import {
13
13
  isRsvpCancelNotice,
14
+ isWaitlistOfferNotice,
14
15
  rsvpCancelWhenLabels,
16
+ waitlistClaimPath,
15
17
  } from '@openpeepshq/common/lib';
16
18
  import type {
17
19
  GroupWithMeta,
@@ -388,6 +390,54 @@ function RsvpCanceledNotification({
388
390
  );
389
391
  }
390
392
 
393
+ function WaitlistOfferNotification({
394
+ notification,
395
+ }: {
396
+ notification: PublicNotification;
397
+ }) {
398
+ const t = useT();
399
+ const profile = notification.senderProfile ?? notification.post?.profile;
400
+ const post = notification.post;
401
+ const event =
402
+ post?.data?.type === 'event' ? post.data.name?.trim() : undefined;
403
+ const notice = isWaitlistOfferNotice(notification.data)
404
+ ? notification.data
405
+ : undefined;
406
+ const href = post
407
+ ? waitlistClaimPath(post.id, notice?.recurrenceId)
408
+ : '/notifications';
409
+ if (!profile) return null;
410
+ return (
411
+ <NotificationWrapper
412
+ profile={profile}
413
+ seen={notification.seen}
414
+ showProfile={false}
415
+ >
416
+ <a href={href} className="block w-full px-4 py-2">
417
+ <p className="mb-1 text-sm font-semibold">
418
+ {t('notification.waitlistOffer.text', {
419
+ defaultValue: 'A spot opened at {{eventName}}',
420
+ eventName:
421
+ event ||
422
+ t('notification.waitlistOffer.eventFallback', {
423
+ defaultValue: 'an event',
424
+ }),
425
+ })}
426
+ </p>
427
+ {notice?.offerExpiresAt ? (
428
+ <p className="text-muted-foreground mb-2 text-sm">
429
+ {t('notification.waitlistOffer.expires', {
430
+ defaultValue: 'Claim it before {{until}}.',
431
+ until: new Date(notice.offerExpiresAt).toLocaleString(),
432
+ })}
433
+ </p>
434
+ ) : null}
435
+ {post ? <FeedPost post={post} /> : null}
436
+ </a>
437
+ </NotificationWrapper>
438
+ );
439
+ }
440
+
391
441
  function GroupAvatarThumb({ group }: { group: GroupWithMeta }) {
392
442
  return <GroupAvatar group={group} size={2.5} borderless />;
393
443
  }
@@ -577,21 +627,42 @@ function JamNotification({
577
627
  const t = useT();
578
628
  const profile = notification.senderProfile!;
579
629
  const name = profileName(profile);
580
- const message = t(`notification.${notification.type}.text`, {
581
- defaultValue: `${name} — ${notification.type}`,
582
- profileName: name,
583
- groupName: notification.group?.displayName,
584
- });
630
+ const eventName =
631
+ notification.post?.data?.type === 'event'
632
+ ? notification.post.data.name?.trim()
633
+ : undefined;
634
+ const message = t(
635
+ notification.type === 'jamStarted'
636
+ ? eventName
637
+ ? 'notification.jamStarted.text'
638
+ : 'notification.jamStarted.textNoEvent'
639
+ : `notification.${notification.type}.text`,
640
+ {
641
+ defaultValue:
642
+ notification.type === 'jamStarted'
643
+ ? eventName
644
+ ? '{{profileName}} started a jam: {{eventName}}'
645
+ : '{{profileName}} started a jam'
646
+ : `${name} — ${notification.type}`,
647
+ profileName: name,
648
+ groupName: notification.group?.displayName,
649
+ eventName,
650
+ },
651
+ );
652
+ const postId = notification.post?.id;
653
+ const occurrence = notification.post?.occurrenceRecurrenceId;
654
+ const href = postId
655
+ ? `/posts/${postId}${
656
+ occurrence ? `?occurrence=${encodeURIComponent(occurrence)}` : ''
657
+ }`
658
+ : `/posts/${postId}`;
585
659
  return (
586
660
  <NotificationWrapper
587
661
  profile={profile}
588
662
  group={notification.group}
589
663
  seen={notification.seen}
590
664
  >
591
- <a
592
- href={`/posts/${notification.post?.id}`}
593
- className="block w-full px-4 py-2"
594
- >
665
+ <a href={href} className="block w-full px-4 py-2">
595
666
  <p className="mb-2 flex items-center gap-2 text-sm font-semibold">
596
667
  {message}
597
668
  <span className="text-muted-foreground text-xs font-normal">
@@ -664,6 +735,7 @@ const TYPED: Partial<
664
735
  pollEnded: PollEndedNotification,
665
736
  rsvp: RsvpNotification,
666
737
  rsvpCanceled: RsvpCanceledNotification,
738
+ waitlistOffer: WaitlistOfferNotification,
667
739
  groupAdded: NewGroupInvitationNotification,
668
740
  groupMemberJoined: NewGroupMemberNotification,
669
741
  groupMemberLeft: GroupMemberExitNotification,
@@ -1,2 +1,8 @@
1
- export { OpenpeepsMarkdown, OpenpeepsMarkdown as PostMarkdown } from '../markdown';
2
- export type { OpenpeepsMarkdownProps, OpenpeepsMarkdownProps as PostMarkdownProps } from '../markdown';
1
+ export {
2
+ OpenpeepsMarkdown,
3
+ OpenpeepsMarkdown as PostMarkdown,
4
+ } from '../markdown';
5
+ export type {
6
+ OpenpeepsMarkdownProps,
7
+ OpenpeepsMarkdownProps as PostMarkdownProps,
8
+ } from '../markdown';
@@ -18,7 +18,5 @@ export const resolveAttachmentPreviewUrl = (
18
18
  localPreviewUrl,
19
19
  ].filter((url): url is string => !!url);
20
20
 
21
- return (
22
- candidates.find((url) => !isBlobUrl(url)) ?? candidates[0] ?? ''
23
- );
21
+ return candidates.find((url) => !isBlobUrl(url)) ?? candidates[0] ?? '';
24
22
  };
@@ -29,14 +29,44 @@ export function Attachments({ post }: AttachmentsProps) {
29
29
 
30
30
  if (attachments.length === 0) return null;
31
31
 
32
- const indexed = attachments.map((att, idx) => ({ att, idx }));
33
- const visual = indexed.filter(({ att }) => !isAudioAttachment(att));
34
- const audio = indexed.filter(({ att }) => isAudioAttachment(att));
32
+ // A lone audio or video file plays inline. Anything else stays a gallery
33
+ // tile, including an audio or video file that shares the post with others.
34
+ const sole = attachments.length === 1 ? attachments[0] : undefined;
35
+ const inline =
36
+ sole && (isAudioAttachment(sole) || isVideo(sole)) ? sole : undefined;
35
37
 
36
- const single = visual.length === 1;
38
+ if (inline && isVideo(inline)) {
39
+ return (
40
+ <div className="bg-surface mt-2 w-full overflow-hidden rounded-md">
41
+ <video
42
+ src={inline.url}
43
+ poster={inline.previewUrl ?? undefined}
44
+ controls
45
+ playsInline
46
+ preload="metadata"
47
+ className="max-h-[70vh] w-full"
48
+ />
49
+ </div>
50
+ );
51
+ }
52
+
53
+ if (inline) {
54
+ return (
55
+ <div className="mt-2">
56
+ <AudioAttachment
57
+ src={inline.url}
58
+ label={inline.filename ?? inline.description}
59
+ size={inline.meta?.size}
60
+ />
61
+ </div>
62
+ );
63
+ }
64
+
65
+ const indexed = attachments.map((att, idx) => ({ att, idx }));
66
+ const single = indexed.length === 1;
37
67
  const cols = single
38
68
  ? ''
39
- : visual.length === 2
69
+ : indexed.length === 2
40
70
  ? 'grid grid-cols-2'
41
71
  : 'grid grid-cols-2 grid-rows-2';
42
72
  // With a single attachment the grid has no fixed height, so the children
@@ -51,81 +81,66 @@ export function Attachments({ post }: AttachmentsProps) {
51
81
 
52
82
  return (
53
83
  <>
54
- <div className="mt-2 flex w-full flex-col gap-2">
55
- {visual.length > 0 ? (
56
- <div
57
- className={`w-full gap-1 overflow-hidden rounded-md ${cols} ${height}`}
58
- >
59
- {visual.map(({ att, idx }) => {
60
- const tile = (
61
- <>
62
- {isImage(att) && (att.previewUrl || att.url) ? (
63
- <img
64
- src={att.previewUrl ?? att.url ?? ''}
65
- alt={att.description ?? `attachment ${idx + 1}`}
66
- className={mediaClass}
67
- />
68
- ) : isVideo(att) && (att.previewUrl || att.url) ? (
69
- <div className="relative h-full w-full">
70
- <img
71
- src={att.previewUrl ?? att.url ?? ''}
72
- alt={att.description ?? `attachment ${idx + 1}`}
73
- className={mediaClass}
74
- />
75
- <VideoPlayOverlay video />
76
- </div>
77
- ) : (
78
- <div className="text-muted-foreground flex min-h-24 w-full flex-col items-center justify-center gap-1 p-4 text-center text-xs">
79
- <span className="text-foreground break-all font-medium">
80
- {att.filename ??
81
- att.description ??
82
- `Attachment ${idx + 1}`}
83
- </span>
84
- {att.meta?.mimetype ? (
85
- <span className="uppercase">{att.meta.mimetype}</span>
86
- ) : null}
87
- </div>
88
- )}
89
- </>
90
- );
91
-
92
- if (staticRender) {
93
- return (
94
- <div
95
- key={`${att.url ?? idx}-${idx}`}
96
- className={`${tileClass} bg-surface overflow-hidden`}
97
- >
98
- {tile}
99
- </div>
100
- );
101
- }
84
+ <div
85
+ className={`mt-2 w-full gap-1 overflow-hidden rounded-md ${cols} ${height}`}
86
+ >
87
+ {indexed.map(({ att, idx }) => {
88
+ const tile = (
89
+ <>
90
+ {isImage(att) && (att.previewUrl || att.url) ? (
91
+ <img
92
+ src={att.previewUrl ?? att.url ?? ''}
93
+ alt={att.description ?? `attachment ${idx + 1}`}
94
+ className={mediaClass}
95
+ />
96
+ ) : isVideo(att) && (att.previewUrl || att.url) ? (
97
+ <div className="relative h-full w-full">
98
+ <img
99
+ src={att.previewUrl ?? att.url ?? ''}
100
+ alt={att.description ?? `attachment ${idx + 1}`}
101
+ className={mediaClass}
102
+ />
103
+ <VideoPlayOverlay video />
104
+ </div>
105
+ ) : (
106
+ <div className="text-muted-foreground flex min-h-24 w-full flex-col items-center justify-center gap-1 p-4 text-center text-xs">
107
+ <span className="text-foreground break-all font-medium">
108
+ {att.filename ?? att.description ?? `Attachment ${idx + 1}`}
109
+ </span>
110
+ {att.meta?.mimetype ? (
111
+ <span className="uppercase">{att.meta.mimetype}</span>
112
+ ) : null}
113
+ </div>
114
+ )}
115
+ </>
116
+ );
102
117
 
103
- return (
104
- <button
105
- key={`${att.url ?? idx}-${idx}`}
106
- type="button"
107
- className={`${tileClass} bg-surface overflow-hidden`}
108
- onClick={(e) => {
109
- e.preventDefault();
110
- e.stopPropagation();
111
- setGalleryIndex(idx);
112
- }}
113
- >
114
- {tile}
115
- </button>
116
- );
117
- })}
118
- </div>
119
- ) : null}
118
+ if (staticRender) {
119
+ return (
120
+ <div
121
+ key={`${att.url ?? idx}-${idx}`}
122
+ className={`${tileClass} bg-surface overflow-hidden`}
123
+ >
124
+ {tile}
125
+ </div>
126
+ );
127
+ }
120
128
 
121
- {audio.map(({ att, idx }) => (
122
- <AudioAttachment
123
- key={`${att.url ?? idx}-${idx}`}
124
- src={att.url}
125
- label={att.filename ?? att.description}
126
- size={att.meta?.size}
127
- />
128
- ))}
129
+ return (
130
+ <button
131
+ key={`${att.url ?? idx}-${idx}`}
132
+ type="button"
133
+ className={`${tileClass} bg-surface overflow-hidden`}
134
+ onClick={(e) => {
135
+ e.preventDefault();
136
+ e.stopPropagation();
137
+ setGalleryIndex(idx);
138
+ }}
139
+ >
140
+ {tile}
141
+ </button>
142
+ );
143
+ })}
129
144
  </div>
130
145
 
131
146
  {galleryIndex !== null ? (