@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
@@ -1,5 +1,10 @@
1
1
  import { useEffect, useMemo, useState } from 'react';
2
- import { ZodObject, type ZodRawShape, ZodArray, type ZodType } from '@openpeepshq/common/zod';
2
+ import {
3
+ ZodObject,
4
+ type ZodRawShape,
5
+ ZodArray,
6
+ type ZodType,
7
+ } from '@openpeepshq/common/zod';
3
8
  import type { ConfigTree } from '@openpeepshq/common/types';
4
9
  import { capitalizeFirstLetter } from '@openpeepshq/common';
5
10
  import { ExpandableBox } from '@openpeepshq/react-ui';
@@ -36,8 +41,8 @@ export function ConfigurationCategory({
36
41
  }: ConfigurationCategoryProps) {
37
42
  const t = useT();
38
43
  const disabled = disabledProp ?? schema.description === 'fixed';
39
- const [value, setValue] = useState<Record<string, unknown>>(
40
- () => structuredClone(valueProp ?? config),
44
+ const [value, setValue] = useState<Record<string, unknown>>(() =>
45
+ structuredClone(valueProp ?? config),
41
46
  );
42
47
 
43
48
  useEffect(() => {
@@ -51,10 +56,10 @@ export function ConfigurationCategory({
51
56
 
52
57
  const dirty = !equal(config as ConfigTree, value as ConfigTree);
53
58
  const dirtyPaths = useMemo(() => {
54
- const diff = diffConfigTrees(config as ConfigTree, value as ConfigTree) as Record<
55
- string,
56
- unknown
57
- >;
59
+ const diff = diffConfigTrees(
60
+ config as ConfigTree,
61
+ value as ConfigTree,
62
+ ) as Record<string, unknown>;
58
63
  return Object.keys(diff).flatMap((key) => [...path.map(String), key]);
59
64
  }, [config, value, path]);
60
65
 
@@ -110,11 +115,18 @@ export function ConfigurationCategory({
110
115
  />
111
116
  );
112
117
  return collapsible ? (
113
- <ExpandableBox key={String(field.key)} title={title} initialOpen={false}>
118
+ <ExpandableBox
119
+ key={String(field.key)}
120
+ title={title}
121
+ initialOpen={false}
122
+ >
114
123
  {nested}
115
124
  </ExpandableBox>
116
125
  ) : (
117
- <div key={String(field.key)}>{title}{nested}</div>
126
+ <div key={String(field.key)}>
127
+ {title}
128
+ {nested}
129
+ </div>
118
130
  );
119
131
  }
120
132
 
@@ -152,7 +164,8 @@ export function ConfigurationCategory({
152
164
  <div className={collapsible ? 'mt-4 pl-4' : ''}>
153
165
  {collapsible && (
154
166
  <p className={dirty ? 'font-bold' : ''}>
155
- {pathName || t('configuration.title', { defaultValue: 'Configuration' })}
167
+ {pathName ||
168
+ t('configuration.title', { defaultValue: 'Configuration' })}
156
169
  </p>
157
170
  )}
158
171
  {body}
@@ -1,5 +1,10 @@
1
1
  import { useMemo, useState } from 'react';
2
- import { z, ZodArray, type ZodType, type ZodTypeAny } from '@openpeepshq/common/zod';
2
+ import {
3
+ z,
4
+ ZodArray,
5
+ type ZodType,
6
+ type ZodTypeAny,
7
+ } from '@openpeepshq/common/zod';
3
8
  import { Minus, Plus } from 'lucide-react';
4
9
  import { useT } from '../../i18n';
5
10
  import {
@@ -1,6 +1,12 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
  import { MapPin } from 'lucide-react';
3
- import { Button, Input, Label, LoadingSpinner, cn } from '@openpeepshq/react-ui';
3
+ import {
4
+ Button,
5
+ Input,
6
+ Label,
7
+ LoadingSpinner,
8
+ cn,
9
+ } from '@openpeepshq/react-ui';
4
10
  import type { GeocodingResult, Location } from '@openpeepshq/common';
5
11
  import { useOpenpeeps } from '../../contexts/openpeeps';
6
12
  import { useT } from '../../i18n';
@@ -21,7 +21,7 @@ export const JamCapacityGate = ({
21
21
  const me = useCurrentProfile();
22
22
  const eventData = jamPost.data?.type === 'event' ? jamPost.data : undefined;
23
23
  const showRsvp =
24
- reason === 'rsvp-required' &&
24
+ (reason === 'rsvp-required' || reason === 'full') &&
25
25
  !!me &&
26
26
  !!eventData &&
27
27
  isCapacityEvent(eventData);
@@ -6,6 +6,7 @@ import {
6
6
  } from '@livekit/components-react';
7
7
  import { Track } from 'livekit-client';
8
8
  import { useJamObserver } from './JamContext';
9
+ import { useDropLateAudio } from './dropLateAudio';
9
10
  import { JamParticipantConference } from './JamParticipantConference';
10
11
  import { JamEventsProvider } from './JamEventsContext';
11
12
  import { JamObserverShell } from './JamObserverShell';
@@ -50,6 +51,7 @@ function JamObserverConference() {
50
51
 
51
52
  function JamObserverRoom() {
52
53
  const room = useRoomContext();
54
+ useDropLateAudio(room);
53
55
  return (
54
56
  <JamEventsProvider room={room}>
55
57
  <JamObserverConference />
@@ -19,6 +19,7 @@ import { JamPeopleDrawer } from './JamPeopleDrawer';
19
19
  import { JamNetworkQuality, JamRecordingIndicator } from './JamRoomIndicators';
20
20
  import { JamVideoLayout } from './JamVideoLayout';
21
21
  import { useJamLocalSettings } from './jamLocalSettings';
22
+ import { useDropLateAudio } from './dropLateAudio';
22
23
 
23
24
  type Drawer = 'chat' | 'people' | 'details' | null;
24
25
 
@@ -162,6 +163,7 @@ function JamParticipantConferenceInner() {
162
163
  */
163
164
  export function JamParticipantConference() {
164
165
  const room = useRoomContext();
166
+ useDropLateAudio(room);
165
167
  return (
166
168
  <JamEventsProvider room={room}>
167
169
  <JamParticipantConferenceInner />
@@ -11,6 +11,7 @@ import { JamLobby } from './JamLobby';
11
11
  import { JamCapacityGate } from './JamCapacityGate';
12
12
  import { JamRequestJoin } from './JamRequestJoin';
13
13
  import { JamVideoCall } from './JamVideoCall';
14
+ import { LivekitUnavailableNotice } from './LivekitUnavailableNotice';
14
15
 
15
16
  export interface JamRoomProps {
16
17
  jamPost: PublicPost;
@@ -81,12 +82,7 @@ function JamRoomInner() {
81
82
  <div className="w-full max-w-md space-y-5 text-center">
82
83
  <h3 className="text-lg">{jamEvent.name}</h3>
83
84
  <div className="bg-surface flex w-full flex-col items-center justify-center space-y-3 rounded border p-4">
84
- <p role="status">
85
- {t('jams.unavailable.message', {
86
- defaultValue:
87
- 'Jams are unavailable because LiveKit is not connected.',
88
- })}
89
- </p>
85
+ <LivekitUnavailableNotice />
90
86
  <a
91
87
  href={`/posts/${jamPost.id}`}
92
88
  className="text-primary text-sm underline"
@@ -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';
@@ -64,6 +64,7 @@ export const compileMarkdownToHtml = (
64
64
  }
65
65
  if (isExternalLink(cleaned, origin) || opensNewTab) {
66
66
  out += ' target="_blank" rel="noopener noreferrer"';
67
+ out += ' class="external-link"';
67
68
  }
68
69
  out += `>${text}</a>`;
69
70
  return out;
@@ -1,4 +1,5 @@
1
1
  import { Bell, Home, Newspaper, PlusSquare, Users } from 'lucide-react';
2
+ import { TooltipProvider } from '@openpeepshq/react-ui';
2
3
  import { MobileMenuItem } from './MobileMenuItem';
3
4
  import { useHrefOf } from '../../contexts/router';
4
5
  import { useOpenpeeps } from '../../contexts/openpeeps';
@@ -16,38 +17,45 @@ export function FooterMobile({ onNewPost }: FooterMobileProps = {}) {
16
17
  const notificationStats = openpeepsApi.useCurrentProfileNotificationStats();
17
18
 
18
19
  return (
19
- <nav
20
- aria-label={t('navigation.primaryMobile', {
21
- defaultValue: 'Primary',
22
- })}
23
- className="bg-surface flex h-20 w-full items-center justify-evenly md:hidden"
24
- >
25
- <MobileMenuItem
26
- title={t('navigation.home')}
27
- icon={Home}
28
- action={hrefOf({ type: 'feed', feed: 'local' })}
29
- />
30
- <MobileMenuItem
31
- title={t('navigation.myFeed')}
32
- icon={Newspaper}
33
- action={hrefOf({ type: 'feed', feed: 'my' })}
34
- />
35
- <MobileMenuItem
36
- title={t('navigation.newPost')}
37
- icon={PlusSquare}
38
- action={onNewPost ?? hrefOf({ type: 'postNew' })}
39
- />
40
- <MobileMenuItem
41
- title={t('navigation.groups')}
42
- icon={Users}
43
- action={hrefOf({ type: 'groups' })}
44
- />
45
- <MobileMenuItem
46
- title={t('navigation.openNotifications')}
47
- icon={Bell}
48
- action={hrefOf({ type: 'notifications' })}
49
- badge={notificationStats.data?.unseen}
50
- />
51
- </nav>
20
+ <TooltipProvider delayDuration={300}>
21
+ <nav
22
+ aria-label={t('navigation.primaryMobile', {
23
+ defaultValue: 'Primary',
24
+ })}
25
+ className="bg-surface flex h-20 w-full items-center justify-evenly md:hidden"
26
+ >
27
+ <MobileMenuItem
28
+ title={t('navigation.home')}
29
+ tooltip={t('navigation.tooltips.community')}
30
+ icon={Home}
31
+ action={hrefOf({ type: 'feed', feed: 'local' })}
32
+ />
33
+ <MobileMenuItem
34
+ title={t('navigation.myFeed')}
35
+ tooltip={t('navigation.tooltips.myFeed')}
36
+ icon={Newspaper}
37
+ action={hrefOf({ type: 'feed', feed: 'my' })}
38
+ />
39
+ <MobileMenuItem
40
+ title={t('navigation.newPost')}
41
+ tooltip={t('navigation.tooltips.newPost')}
42
+ icon={PlusSquare}
43
+ action={onNewPost ?? hrefOf({ type: 'postNew' })}
44
+ />
45
+ <MobileMenuItem
46
+ title={t('navigation.groups')}
47
+ tooltip={t('navigation.tooltips.groups')}
48
+ icon={Users}
49
+ action={hrefOf({ type: 'groups' })}
50
+ />
51
+ <MobileMenuItem
52
+ title={t('navigation.openNotifications')}
53
+ tooltip={t('navigation.tooltips.notifications')}
54
+ icon={Bell}
55
+ action={hrefOf({ type: 'notifications' })}
56
+ badge={notificationStats.data?.unseen}
57
+ />
58
+ </nav>
59
+ </TooltipProvider>
52
60
  );
53
61
  }
@@ -6,7 +6,9 @@ import {
6
6
  DialogPortal,
7
7
  DialogOverlay,
8
8
  DialogTrigger,
9
+ TooltipProvider,
9
10
  } from '@openpeepshq/react-ui';
11
+ import { NavWithTooltip } from './NavWithTooltip';
10
12
  import { getTheme } from '@openpeepshq/common';
11
13
  import { useServerInfo } from '../server-data';
12
14
  import {
@@ -37,9 +39,11 @@ export function HeaderMobile({ avatar, sideBar }: HeaderMobileProps = {}) {
37
39
  const t = useT();
38
40
  const [open, setOpen] = useState(false);
39
41
  const menuLabel = t('navigation.openMenu', { defaultValue: 'Open menu' });
42
+ const menuTooltip = t('navigation.tooltips.openMenu');
40
43
  const messagesLabel = t('navigation.openMessages', {
41
44
  defaultValue: 'Open messages',
42
45
  });
46
+ const messagesTooltip = t('navigation.tooltips.openMessages');
43
47
 
44
48
  const logoSmall = getTheme(
45
49
  serverInfo.communityConfig,
@@ -58,49 +62,59 @@ export function HeaderMobile({ avatar, sideBar }: HeaderMobileProps = {}) {
58
62
 
59
63
  return (
60
64
  <header className="bg-background sticky top-0 z-10 flex px-4 py-2 md:hidden">
61
- <div className="flex w-full items-center justify-between">
62
- <Dialog open={open} onOpenChange={setOpen}>
63
- <DialogTrigger asChild>
64
- <button type="button" title={menuLabel} aria-label={menuLabel}>
65
- {trigger}
66
- <span className="sr-only">{menuLabel}</span>
67
- </button>
68
- </DialogTrigger>
69
- <DialogPortal>
70
- <DialogOverlay />
71
- <DialogContent
72
- showCloseButton={false}
73
- className="left-0 top-0 h-screen w-[380px] translate-x-0 translate-y-0 rounded-none border-r p-0"
74
- >
75
- <SidebarNavCloseContext.Provider value={() => setOpen(false)}>
76
- <SideBar
77
- onClose={() => setOpen(false)}
78
- mainMenu={sideBar?.mainMenu?.()}
79
- profileMenu={sideBar?.profileMenu?.()}
80
- />
81
- </SidebarNavCloseContext.Provider>
82
- </DialogContent>
83
- </DialogPortal>
84
- </Dialog>
65
+ <TooltipProvider delayDuration={300}>
66
+ <div className="flex w-full items-center justify-between">
67
+ <Dialog open={open} onOpenChange={setOpen}>
68
+ <NavWithTooltip label={menuTooltip} side="bottom">
69
+ <DialogTrigger asChild>
70
+ <button
71
+ type="button"
72
+ title={menuTooltip}
73
+ aria-label={menuLabel}
74
+ >
75
+ {trigger}
76
+ <span className="sr-only">{menuLabel}</span>
77
+ </button>
78
+ </DialogTrigger>
79
+ </NavWithTooltip>
80
+ <DialogPortal>
81
+ <DialogOverlay />
82
+ <DialogContent
83
+ showCloseButton={false}
84
+ className="left-0 top-0 h-screen w-[380px] translate-x-0 translate-y-0 rounded-none border-r p-0"
85
+ >
86
+ <SidebarNavCloseContext.Provider value={() => setOpen(false)}>
87
+ <SideBar
88
+ onClose={() => setOpen(false)}
89
+ mainMenu={sideBar?.mainMenu?.()}
90
+ profileMenu={sideBar?.profileMenu?.()}
91
+ />
92
+ </SidebarNavCloseContext.Provider>
93
+ </DialogContent>
94
+ </DialogPortal>
95
+ </Dialog>
85
96
 
86
- <div>
87
- {logoSmall && (
88
- <a href="/">
89
- <img src={logoSmall} alt="logo" className="h-6 px-4" />
90
- </a>
91
- )}
92
- </div>
97
+ <div>
98
+ {logoSmall && (
99
+ <a href="/">
100
+ <img src={logoSmall} alt="logo" className="h-6 px-4" />
101
+ </a>
102
+ )}
103
+ </div>
93
104
 
94
- <button
95
- type="button"
96
- title={messagesLabel}
97
- aria-label={messagesLabel}
98
- onClick={() => router.navigate({ type: 'conversation' })}
99
- >
100
- <MessageSquareText aria-hidden="true" />
101
- <span className="sr-only">{messagesLabel}</span>
102
- </button>
103
- </div>
105
+ <NavWithTooltip label={messagesTooltip} side="bottom">
106
+ <button
107
+ type="button"
108
+ title={messagesTooltip}
109
+ aria-label={messagesLabel}
110
+ onClick={() => router.navigate({ type: 'conversation' })}
111
+ >
112
+ <MessageSquareText aria-hidden="true" />
113
+ <span className="sr-only">{messagesLabel}</span>
114
+ </button>
115
+ </NavWithTooltip>
116
+ </div>
117
+ </TooltipProvider>
104
118
  </header>
105
119
  );
106
120
  }
@@ -2,11 +2,14 @@ import { formatBadgeCount } from '@openpeepshq/common';
2
2
  import { cn } from '@openpeepshq/react-ui';
3
3
  import type { IconType } from '@openpeepshq/react-ui';
4
4
  import { useRouter } from '../../contexts/router';
5
+ import { NavWithTooltip } from './NavWithTooltip';
5
6
 
6
7
  export interface MobileMenuItemProps {
7
8
  action: string | (() => unknown);
8
9
  icon: IconType;
9
10
  title?: string;
11
+ /** Describes the action on hover (icon-only mobile footer). */
12
+ tooltip?: string;
10
13
  /** Unread/unseen count shown as a badge on the icon. */
11
14
  badge?: number;
12
15
  }
@@ -15,16 +18,18 @@ export function MobileMenuItem({
15
18
  action,
16
19
  icon: Icon,
17
20
  title,
21
+ tooltip,
18
22
  badge,
19
23
  }: MobileMenuItemProps) {
20
24
  const router = useRouter();
21
25
  const active = typeof action === 'string' && router.pathname === action;
22
26
  const showBadge = (badge ?? 0) > 0;
27
+ const hint = tooltip ?? title;
23
28
 
24
- return (
29
+ const button = (
25
30
  <button
26
31
  type="button"
27
- title={title}
32
+ title={hint}
28
33
  aria-label={title}
29
34
  className="relative"
30
35
  onClick={() => {
@@ -53,4 +58,12 @@ export function MobileMenuItem({
53
58
  </span>
54
59
  </button>
55
60
  );
61
+
62
+ if (!hint) return button;
63
+
64
+ return (
65
+ <NavWithTooltip label={hint} side="top">
66
+ {button}
67
+ </NavWithTooltip>
68
+ );
56
69
  }