@openpeepshq/react 0.6.2 → 0.7.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 (39) hide show
  1. package/dist/components/groups/GroupHeader.js +2 -1
  2. package/dist/components/groups/GroupNotificationSettingsModal.d.ts +9 -0
  3. package/dist/components/groups/GroupNotificationSettingsModal.js +57 -0
  4. package/dist/components/groups/GroupShareMenu.js +30 -8
  5. package/dist/components/groups/index.d.ts +2 -0
  6. package/dist/components/groups/index.js +1 -0
  7. package/dist/components/jams/JamFooter.js +5 -9
  8. package/dist/components/jams/JamRoomIndicators.js +3 -2
  9. package/dist/components/jams/jamRecordingState.d.ts +7 -0
  10. package/dist/components/jams/jamRecordingState.js +32 -1
  11. package/dist/components/post/types/event/FullEvent.js +3 -2
  12. package/dist/hooks/groups/useGroupNotificationLevel.d.ts +9 -0
  13. package/dist/hooks/groups/useGroupNotificationLevel.js +57 -0
  14. package/dist/hooks/index.d.ts +1 -0
  15. package/dist/hooks/index.js +1 -0
  16. package/dist/hooks/jams/useJamDetails.d.ts +153 -153
  17. package/dist/hooks/jams/useJamFooterControls.d.ts +1 -0
  18. package/dist/hooks/jams/useJamFooterControls.js +10 -2
  19. package/dist/hooks/jams/useJamLobby.d.ts +1 -1
  20. package/dist/hooks/jams/useJamRoom.d.ts +307 -307
  21. package/dist/hooks/posts/usePostDetailTitle.d.ts +153 -153
  22. package/dist/pages/admin/configurationSsoShared.d.ts +7 -3
  23. package/dist/pages/groups/Show.js +22 -19
  24. package/dist/react-native.d.ts +2 -2
  25. package/dist/react-native.js +2 -2
  26. package/package.json +4 -4
  27. package/src/components/groups/GroupHeader.tsx +2 -0
  28. package/src/components/groups/GroupNotificationSettingsModal.tsx +163 -0
  29. package/src/components/groups/GroupShareMenu.tsx +77 -12
  30. package/src/components/groups/index.ts +5 -0
  31. package/src/components/jams/JamFooter.tsx +9 -13
  32. package/src/components/jams/JamRoomIndicators.tsx +6 -1
  33. package/src/components/jams/jamRecordingState.ts +35 -1
  34. package/src/components/post/types/event/FullEvent.tsx +6 -1
  35. package/src/hooks/groups/useGroupNotificationLevel.ts +57 -0
  36. package/src/hooks/index.ts +1 -0
  37. package/src/hooks/jams/useJamFooterControls.ts +14 -2
  38. package/src/pages/groups/Show.tsx +60 -53
  39. package/src/react-native.ts +3 -1
@@ -0,0 +1,57 @@
1
+ import { useEffect, useState } from 'react';
2
+ import type { GroupNotificationLevel } from '@openpeepshq/common';
3
+ import { useOpenpeeps } from '../../contexts/openpeeps';
4
+
5
+ export const useGroupNotificationLevel = (groupId: string) => {
6
+ const { openpeepsApi } = useOpenpeeps();
7
+ const settingsQuery = openpeepsApi.useCurrentProfileSettings();
8
+ const updateSettings = openpeepsApi.updateCurrentProfileSettingsAction();
9
+ const [level, setLevel] = useState<GroupNotificationLevel>('all');
10
+ const [ready, setReady] = useState(false);
11
+ const [saving, setSaving] = useState(false);
12
+ const [error, setError] = useState<string | null>(null);
13
+
14
+ useEffect(() => {
15
+ const settings = settingsQuery.data;
16
+ if (!settings || ready) return;
17
+ setLevel(settings.groupNotificationLevels?.[groupId] ?? 'all');
18
+ setReady(true);
19
+ }, [settingsQuery.data, groupId, ready]);
20
+
21
+ const save = async () => {
22
+ const current = settingsQuery.data;
23
+ if (!current) return false;
24
+ setError(null);
25
+ setSaving(true);
26
+ try {
27
+ const groupNotificationLevels = {
28
+ ...(current.groupNotificationLevels ?? {}),
29
+ };
30
+ if (level === 'all') {
31
+ delete groupNotificationLevels[groupId];
32
+ } else {
33
+ groupNotificationLevels[groupId] = level;
34
+ }
35
+ await updateSettings({
36
+ ...current,
37
+ groupNotificationLevels,
38
+ });
39
+ return true;
40
+ } catch (err) {
41
+ setError((err as Error).message);
42
+ return false;
43
+ } finally {
44
+ setSaving(false);
45
+ }
46
+ };
47
+
48
+ return {
49
+ level,
50
+ setLevel,
51
+ save,
52
+ saving,
53
+ ready: ready && !settingsQuery.isLoading,
54
+ loadFailed: settingsQuery.isError,
55
+ error,
56
+ };
57
+ };
@@ -1,4 +1,5 @@
1
1
  export { useJoinGroup } from './groups/useJoinGroup';
2
+ export { useGroupNotificationLevel } from './groups/useGroupNotificationLevel';
2
3
  export { useCreateConversation } from './conversations/useCreateConversation';
3
4
  export type { UseCreateConversationArgs } from './conversations/useCreateConversation';
4
5
  export { useLeaveCloseJam } from './jams/useLeaveCloseJam';
@@ -9,6 +9,9 @@ import { useJamEventsContext } from '../../components/jams/JamEventsContext';
9
9
  import { useJamRecordingState } from '../../components/jams/jamRecordingState';
10
10
  import { toggleHand } from '../../components/jams/jamEventActions';
11
11
  import { useRaisedHands } from '../../components/jams/useJamHands';
12
+ import { logger } from '../../log';
13
+
14
+ const log = logger('jams:recording');
12
15
 
13
16
  export type UseJamFooterControlsArgs = {
14
17
  room: Room;
@@ -65,13 +68,15 @@ export const useJamFooterControls = ({
65
68
  undefined,
66
69
  occurrence ? { occurrence } : undefined,
67
70
  );
68
- onSuccess(t('jams.recording.stopped', { id: recording.id }));
71
+ log.info('recording stopped', recording.id);
72
+ onSuccess(t('jams.recording.stopped'));
69
73
  } else {
70
74
  const recording = await startRecording(
71
75
  undefined,
72
76
  occurrence ? { occurrence } : undefined,
73
77
  );
74
- onSuccess(t('jams.recording.started', { id: recording.id }));
78
+ log.info('recording started', recording.id);
79
+ onSuccess(t('jams.recording.started'));
75
80
  }
76
81
  } catch {
77
82
  onError(
@@ -84,9 +89,16 @@ export const useJamFooterControls = ({
84
89
  }
85
90
  };
86
91
 
92
+ const recordingLabel = busy
93
+ ? t(isRecording ? 'jams.recording.stopping' : 'jams.recording.starting')
94
+ : t(
95
+ isRecording ? 'jams.recording.stopTitle' : 'jams.recording.recordTitle',
96
+ );
97
+
87
98
  return {
88
99
  isModerator,
89
100
  isRecording,
101
+ recordingLabel,
90
102
  recordingEnabled,
91
103
  handRaised,
92
104
  busy,
@@ -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
+ );
@@ -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';
@@ -141,6 +141,8 @@ export { useRaisedHands } from './components/jams/useJamHands';
141
141
  export {
142
142
  calculateRecordingState,
143
143
  calculateRtmpStreamState,
144
+ formatRecordingElapsed,
145
+ useJamRecordingElapsed,
144
146
  useJamRecordingState,
145
147
  useJamRtmpStreamState,
146
148
  } from './components/jams/jamRecordingState';