@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.
- package/dist/components/configuration/ConfigurationCategory.js +3 -2
- package/dist/components/configuration/ConfigurationList.js +1 -1
- package/dist/components/form/LocationInput.js +1 -1
- package/dist/components/groups/GroupHeader.js +2 -1
- package/dist/components/groups/GroupNotificationSettingsModal.d.ts +9 -0
- package/dist/components/groups/GroupNotificationSettingsModal.js +57 -0
- package/dist/components/groups/GroupShareMenu.js +30 -8
- package/dist/components/groups/index.d.ts +2 -0
- package/dist/components/groups/index.js +1 -0
- package/dist/components/jams/JamCapacityGate.js +1 -1
- package/dist/components/jams/JamConference.js +2 -0
- package/dist/components/jams/JamParticipantConference.js +2 -0
- package/dist/components/jams/JamRoom.js +2 -3
- package/dist/components/jams/LiveJamsSection.js +8 -2
- package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
- package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
- package/dist/components/jams/dropLateAudio.d.ts +22 -0
- package/dist/components/jams/dropLateAudio.js +115 -0
- package/dist/components/jams/index.d.ts +1 -0
- package/dist/components/jams/index.js +1 -0
- package/dist/components/notifications/TypedNotification.js +46 -4
- package/dist/components/post/Markdown.d.ts +2 -2
- package/dist/components/post/Markdown.js +1 -1
- package/dist/components/post/attachmentPreview.js +1 -1
- package/dist/components/post/pieces/Attachments.js +23 -17
- package/dist/components/post/pieces/EventRsvpButton.js +37 -7
- package/dist/components/post/pieces/EventRsvpList.js +23 -3
- package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
- package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
- package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
- package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
- package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
- package/dist/components/post/pieces/ParticipantsCard.js +1 -1
- package/dist/components/post/pieces/PostActions.d.ts +1 -1
- package/dist/components/post/pieces/PostActions.js +20 -12
- package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
- package/dist/components/post/pieces/ShareMenu.js +40 -7
- package/dist/components/post/post-form/EventForm.js +10 -2
- package/dist/components/post/types/Article.js +1 -1
- package/dist/components/post/types/article/FullArticle.js +1 -1
- package/dist/components/post/types/event/CardEvent.js +2 -1
- package/dist/components/post/types/event/FullEvent.js +21 -11
- package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
- package/dist/components/preview-link/LocalPreviewLink.js +4 -2
- package/dist/components/preview-link/PreviewLink.js +1 -1
- package/dist/components/preview-link/helpers.d.ts +5 -0
- package/dist/components/preview-link/helpers.js +27 -1
- package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
- package/dist/components/preview-link/local/WelcomePreview.js +6 -0
- package/dist/components/profile/Avatar.js +2 -2
- package/dist/components/profile/ProfileFromId.js +1 -1
- package/dist/components/server-data/context.d.ts +1 -0
- package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
- package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
- package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
- package/dist/contexts/openpeeps/hooks/admin.js +11 -3
- package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
- package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
- package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
- package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
- package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
- package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
- package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
- package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
- package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
- package/dist/hooks/events/useEventComposer.d.ts +94 -41
- package/dist/hooks/events/useEventForm.d.ts +1 -0
- package/dist/hooks/events/useEventRsvp.d.ts +11 -2
- package/dist/hooks/events/useEventRsvp.js +46 -5
- package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
- package/dist/hooks/groups/useGroupNotificationLevel.d.ts +9 -0
- package/dist/hooks/groups/useGroupNotificationLevel.js +57 -0
- package/dist/hooks/groups/useNewGroup.js +22 -2
- package/dist/hooks/index.d.ts +6 -1
- package/dist/hooks/index.js +5 -1
- package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
- package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
- package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
- package/dist/hooks/jams/useJamDetails.d.ts +87 -38
- package/dist/hooks/jams/useJamLobby.d.ts +1 -0
- package/dist/hooks/jams/useJamRoom.d.ts +175 -76
- package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
- package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
- package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
- package/dist/hooks/posts/useResourceComposer.d.ts +93 -41
- package/dist/hooks/posts/useResourceComposer.js +4 -2
- package/dist/hooks/posts/useShareMenu.d.ts +2 -0
- package/dist/hooks/posts/useShareMenu.js +7 -0
- package/dist/hooks/resources/useResourceLibrary.d.ts +176 -78
- package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
- package/dist/hooks/useWelcomePreview.d.ts +13 -0
- package/dist/hooks/useWelcomePreview.js +39 -0
- package/dist/lib/groupFormErrors.d.ts +1 -0
- package/dist/lib/groupFormErrors.js +5 -2
- package/dist/lib/threadHelpers.js +1 -5
- package/dist/pages/admin/ConfigurationCommunity.js +1 -1
- package/dist/pages/admin/Diagnostics.js +1 -1
- package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
- package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
- package/dist/pages/admin/Invites.js +5 -3
- package/dist/pages/admin/Media.d.ts +1 -0
- package/dist/pages/admin/Media.js +135 -0
- package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
- package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
- package/dist/pages/admin/community/CommunityRoles.js +1 -1
- package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
- package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
- package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
- package/dist/pages/admin/configurationSsoShared.d.ts +4 -0
- package/dist/pages/auth/Register.js +30 -8
- package/dist/pages/conversations/Show.js +11 -0
- package/dist/pages/groups/Show.js +22 -19
- package/dist/pages/index.d.ts +3 -0
- package/dist/pages/index.js +3 -0
- package/dist/pages/jams/Index.js +2 -4
- package/dist/pages/settings/PublicProfile.js +15 -3
- package/dist/pwa/sw.d.ts +0 -1
- package/dist/react-native.d.ts +2 -1
- package/dist/react-native.js +2 -1
- package/dist/stores/newPosts.d.ts +4 -2
- package/dist/stores/newPosts.js +6 -1
- package/package.json +11 -6
- package/src/components/configuration/ConfigurationCategory.tsx +23 -10
- package/src/components/configuration/ConfigurationList.tsx +6 -1
- package/src/components/form/LocationInput.tsx +7 -1
- package/src/components/groups/GroupHeader.tsx +2 -0
- package/src/components/groups/GroupNotificationSettingsModal.tsx +163 -0
- package/src/components/groups/GroupShareMenu.tsx +77 -12
- package/src/components/groups/index.ts +5 -0
- package/src/components/jams/JamCapacityGate.tsx +1 -1
- package/src/components/jams/JamConference.tsx +2 -0
- package/src/components/jams/JamParticipantConference.tsx +2 -0
- package/src/components/jams/JamRoom.tsx +2 -6
- package/src/components/jams/LiveJamsSection.tsx +16 -2
- package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
- package/src/components/jams/dropLateAudio.ts +153 -0
- package/src/components/jams/index.ts +1 -0
- package/src/components/notifications/TypedNotification.tsx +81 -9
- package/src/components/post/Markdown.tsx +8 -2
- package/src/components/post/attachmentPreview.ts +1 -3
- package/src/components/post/pieces/Attachments.tsx +93 -78
- package/src/components/post/pieces/EventRsvpButton.tsx +107 -7
- package/src/components/post/pieces/EventRsvpList.tsx +64 -0
- package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
- package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
- package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
- package/src/components/post/pieces/PostActions.tsx +73 -42
- package/src/components/post/pieces/ShareMenu.tsx +67 -9
- package/src/components/post/post-form/EventForm.tsx +26 -0
- package/src/components/post/post-form/VisibilitySelector.tsx +1 -2
- package/src/components/post/types/Article.tsx +1 -1
- package/src/components/post/types/article/FullArticle.tsx +2 -2
- package/src/components/post/types/event/CardEvent.tsx +26 -14
- package/src/components/post/types/event/FullEvent.tsx +47 -29
- package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
- package/src/components/post/types/note/FullNote.tsx +1 -4
- package/src/components/post/types/poll/FullPoll.tsx +1 -4
- package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
- package/src/components/preview-link/PreviewLink.tsx +2 -7
- package/src/components/preview-link/helpers.ts +32 -1
- package/src/components/preview-link/local/GroupPreview.tsx +1 -1
- package/src/components/preview-link/local/JamPreview.tsx +1 -1
- package/src/components/preview-link/local/WelcomePreview.tsx +36 -0
- package/src/components/profile/Avatar.tsx +6 -2
- package/src/components/profile/ProfileFromId.tsx +1 -5
- package/src/components/resources/ResourceCard.tsx +0 -1
- package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
- package/src/contexts/openpeeps/hooks/admin.ts +11 -3
- package/src/contexts/openpeeps/hooks/other.ts +9 -12
- package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
- package/src/css.d.ts +4 -0
- package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
- package/src/hooks/events/useEventRsvp.ts +51 -7
- package/src/hooks/groups/useGroupNotificationLevel.ts +57 -0
- package/src/hooks/groups/useNewGroup.ts +28 -3
- package/src/hooks/index.ts +9 -1
- package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
- package/src/hooks/posts/useResourceComposer.ts +8 -6
- package/src/hooks/posts/useShareMenu.ts +9 -0
- package/src/hooks/useWelcomePreview.ts +57 -0
- package/src/i18n/I18nProvider.tsx +1 -4
- package/src/lib/groupFormErrors.ts +9 -2
- package/src/lib/threadHelpers.ts +1 -5
- package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
- package/src/pages/admin/Diagnostics.tsx +4 -0
- package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
- package/src/pages/admin/Invites.tsx +23 -1
- package/src/pages/admin/Media.tsx +290 -0
- package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
- package/src/pages/admin/community/CommunityRoles.tsx +2 -2
- package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
- package/src/pages/auth/Register.tsx +33 -4
- package/src/pages/conversations/Show.tsx +11 -0
- package/src/pages/groups/Show.tsx +60 -53
- package/src/pages/index.ts +3 -0
- package/src/pages/jams/Index.tsx +2 -6
- package/src/pages/settings/PublicProfile.tsx +20 -2
- package/src/pwa/sw.ts +6 -3
- package/src/pwa/useNotificationBadgeSync.ts +3 -1
- package/src/react-native.ts +2 -1
- package/src/stores/newPosts.ts +6 -1
- package/src/streaming.ts +3 -3
- package/dist/setupTests.d.ts +0 -1
- package/dist/setupTests.js +0 -5
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { useMemo, useState } from 'react';
|
|
2
|
-
import {
|
|
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 {
|
|
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';
|
|
@@ -4,6 +4,7 @@ import { groupName } from '@openpeepshq/common/lib';
|
|
|
4
4
|
import { useT } from '../../i18n';
|
|
5
5
|
import { useCurrentProfile } from '../layout/IdentityContext';
|
|
6
6
|
import { JoinGroupButton } from './JoinGroupButton';
|
|
7
|
+
import { GroupNotificationButton } from './GroupNotificationSettingsModal';
|
|
7
8
|
import { GroupOptionsMenu } from './GroupOptionsMenu';
|
|
8
9
|
import { GroupShareMenu } from './GroupShareMenu';
|
|
9
10
|
import { GroupAvatar } from './GroupAvatar';
|
|
@@ -42,6 +43,7 @@ export function GroupHeader({ group }: GroupHeaderProps) {
|
|
|
42
43
|
) : (
|
|
43
44
|
<>
|
|
44
45
|
<GroupShareMenu group={group} />
|
|
46
|
+
<GroupNotificationButton group={group} />
|
|
45
47
|
<GroupOptionsMenu group={group} />
|
|
46
48
|
</>
|
|
47
49
|
)}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Bell } from 'lucide-react';
|
|
3
|
+
import {
|
|
4
|
+
groupName,
|
|
5
|
+
groupNotificationLevelOptions,
|
|
6
|
+
type GroupNotificationLevel,
|
|
7
|
+
type GroupWithMeta,
|
|
8
|
+
} from '@openpeepshq/common';
|
|
9
|
+
import {
|
|
10
|
+
Dialog,
|
|
11
|
+
DialogActions,
|
|
12
|
+
DialogContent,
|
|
13
|
+
DialogHeader,
|
|
14
|
+
DialogTitle,
|
|
15
|
+
LoadingSpinner,
|
|
16
|
+
RadioGroup,
|
|
17
|
+
RadioGroupItem,
|
|
18
|
+
} from '@openpeepshq/react-ui';
|
|
19
|
+
import { useT } from '../../i18n';
|
|
20
|
+
import { useGroupNotificationLevel } from '../../hooks';
|
|
21
|
+
import { useToast } from '../layout/ToastProvider';
|
|
22
|
+
|
|
23
|
+
export interface GroupNotificationSettingsModalProps {
|
|
24
|
+
group: GroupWithMeta;
|
|
25
|
+
onClose: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const optionLabelKey: Record<GroupNotificationLevel, string> = {
|
|
29
|
+
all: 'groups.modals.manageNotifications.options.all',
|
|
30
|
+
mostRelevant: 'groups.modals.manageNotifications.options.mostRelevant',
|
|
31
|
+
off: 'groups.modals.manageNotifications.options.off',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const optionDescriptionKey: Record<GroupNotificationLevel, string> = {
|
|
35
|
+
all: 'groups.modals.manageNotifications.options.allDescription',
|
|
36
|
+
mostRelevant:
|
|
37
|
+
'groups.modals.manageNotifications.options.mostRelevantDescription',
|
|
38
|
+
off: 'groups.modals.manageNotifications.options.offDescription',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const optionDescriptionDefault: Record<GroupNotificationLevel, string> = {
|
|
42
|
+
all: 'Every post and membership change, using your account notification settings.',
|
|
43
|
+
mostRelevant: 'Posts from people you follow.',
|
|
44
|
+
off: 'No posts or membership changes from this group.',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export function GroupNotificationSettingsModal({
|
|
48
|
+
group,
|
|
49
|
+
onClose,
|
|
50
|
+
}: GroupNotificationSettingsModalProps) {
|
|
51
|
+
const t = useT();
|
|
52
|
+
const { success } = useToast();
|
|
53
|
+
const { level, setLevel, save, saving, ready, loadFailed, error } =
|
|
54
|
+
useGroupNotificationLevel(group.id);
|
|
55
|
+
|
|
56
|
+
const onSave = async () => {
|
|
57
|
+
const saved = await save();
|
|
58
|
+
if (!saved) return;
|
|
59
|
+
success(
|
|
60
|
+
t('groups.modals.manageNotifications.saved', {
|
|
61
|
+
defaultValue: 'Group notification settings updated.',
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
onClose();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Dialog open onOpenChange={(open) => !open && onClose()}>
|
|
69
|
+
<DialogContent className="max-h-[85vh] max-w-md overflow-y-auto">
|
|
70
|
+
<DialogHeader>
|
|
71
|
+
<DialogTitle>
|
|
72
|
+
{t('groups.modals.manageNotifications.title', {
|
|
73
|
+
defaultValue: 'Manage notifications',
|
|
74
|
+
})}
|
|
75
|
+
</DialogTitle>
|
|
76
|
+
</DialogHeader>
|
|
77
|
+
<p className="text-muted-foreground px-1 text-sm">
|
|
78
|
+
{t('groups.modals.manageNotifications.description', {
|
|
79
|
+
defaultValue: 'Manage notifications about {{groupName}}.',
|
|
80
|
+
groupName: groupName(group),
|
|
81
|
+
})}
|
|
82
|
+
</p>
|
|
83
|
+
{ready ? (
|
|
84
|
+
<RadioGroup
|
|
85
|
+
value={level}
|
|
86
|
+
onValueChange={(value) => setLevel(value as GroupNotificationLevel)}
|
|
87
|
+
className="gap-3 px-1"
|
|
88
|
+
>
|
|
89
|
+
{groupNotificationLevelOptions.map((option) => (
|
|
90
|
+
<label key={option} className="flex items-start gap-2 text-sm">
|
|
91
|
+
<RadioGroupItem value={option} className="mt-0.5" />
|
|
92
|
+
<span>
|
|
93
|
+
<span className="font-medium">
|
|
94
|
+
{t(optionLabelKey[option], { defaultValue: option })}
|
|
95
|
+
</span>
|
|
96
|
+
<span className="text-muted-foreground mt-0.5 block">
|
|
97
|
+
{t(optionDescriptionKey[option], {
|
|
98
|
+
defaultValue: optionDescriptionDefault[option],
|
|
99
|
+
})}
|
|
100
|
+
</span>
|
|
101
|
+
</span>
|
|
102
|
+
</label>
|
|
103
|
+
))}
|
|
104
|
+
</RadioGroup>
|
|
105
|
+
) : loadFailed ? (
|
|
106
|
+
<p className="text-error px-1 text-sm">
|
|
107
|
+
{t('groups.modals.manageNotifications.loadError', {
|
|
108
|
+
defaultValue: 'Could not load notification settings.',
|
|
109
|
+
})}
|
|
110
|
+
</p>
|
|
111
|
+
) : (
|
|
112
|
+
<div className="text-muted-foreground flex h-24 items-center justify-center">
|
|
113
|
+
<LoadingSpinner />
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
{error ? (
|
|
117
|
+
<p className="border-error/40 text-error rounded-md border p-2 text-sm">
|
|
118
|
+
{error}
|
|
119
|
+
</p>
|
|
120
|
+
) : null}
|
|
121
|
+
<DialogActions
|
|
122
|
+
cancelLabel={t('common.cancel', { defaultValue: 'Cancel' })}
|
|
123
|
+
onCancel={onClose}
|
|
124
|
+
actionLabel={
|
|
125
|
+
saving
|
|
126
|
+
? t('common.saving', { defaultValue: 'Saving…' })
|
|
127
|
+
: t('common.save', { defaultValue: 'Save' })
|
|
128
|
+
}
|
|
129
|
+
onAction={onSave}
|
|
130
|
+
disabled={saving || !ready}
|
|
131
|
+
/>
|
|
132
|
+
</DialogContent>
|
|
133
|
+
</Dialog>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function GroupNotificationButton({ group }: { group: GroupWithMeta }) {
|
|
138
|
+
const t = useT();
|
|
139
|
+
const [open, setOpen] = useState(false);
|
|
140
|
+
const label = t('groups.modals.manageNotifications.title', {
|
|
141
|
+
defaultValue: 'Manage notifications',
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<>
|
|
146
|
+
<button
|
|
147
|
+
type="button"
|
|
148
|
+
title={label}
|
|
149
|
+
aria-label={label}
|
|
150
|
+
className="rounded-button inline-flex items-center justify-center"
|
|
151
|
+
onClick={() => setOpen(true)}
|
|
152
|
+
>
|
|
153
|
+
<Bell size={16} aria-hidden="true" />
|
|
154
|
+
</button>
|
|
155
|
+
{open ? (
|
|
156
|
+
<GroupNotificationSettingsModal
|
|
157
|
+
group={group}
|
|
158
|
+
onClose={() => setOpen(false)}
|
|
159
|
+
/>
|
|
160
|
+
) : null}
|
|
161
|
+
</>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Link, Pencil, Share } from 'lucide-react';
|
|
2
|
+
import { groupSectionPath, type GroupSection } from '@openpeepshq/common/lib';
|
|
2
3
|
import type { GroupWithMeta } from '@openpeepshq/common/types';
|
|
3
4
|
import {
|
|
4
5
|
PopupMenu,
|
|
@@ -20,11 +21,22 @@ export function GroupShareMenu({ group }: GroupShareMenuProps) {
|
|
|
20
21
|
const { openNewPost } = useNewPostModal();
|
|
21
22
|
const { openCreateConversation } = useCreateNewConversation();
|
|
22
23
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const sectionUrl = (section: GroupSection = 'posts') => {
|
|
25
|
+
const path = groupSectionPath(group.handle, section);
|
|
26
|
+
return typeof window !== 'undefined'
|
|
27
|
+
? `${window.location.origin}${path}`
|
|
28
|
+
: path;
|
|
29
|
+
};
|
|
30
|
+
const groupUrl = sectionUrl();
|
|
27
31
|
const inviteBlurb = t('groups.share.inviteBlurb', { url: groupUrl });
|
|
32
|
+
const copySectionLink = (
|
|
33
|
+
section: GroupSection,
|
|
34
|
+
copiedKey: string,
|
|
35
|
+
copiedDefault: string,
|
|
36
|
+
) => {
|
|
37
|
+
void navigator.clipboard.writeText(sectionUrl(section));
|
|
38
|
+
success(t(copiedKey, { defaultValue: copiedDefault }));
|
|
39
|
+
};
|
|
28
40
|
|
|
29
41
|
return (
|
|
30
42
|
<PopupMenu
|
|
@@ -39,7 +51,9 @@ export function GroupShareMenu({ group }: GroupShareMenuProps) {
|
|
|
39
51
|
})}
|
|
40
52
|
/>
|
|
41
53
|
<PopupMenuButton
|
|
42
|
-
title={t('groups.actions.shareToFeed', {
|
|
54
|
+
title={t('groups.actions.shareToFeed', {
|
|
55
|
+
defaultValue: 'Share to feed',
|
|
56
|
+
})}
|
|
43
57
|
text={t('groups.share.postToFeed', { defaultValue: 'Post to feed' })}
|
|
44
58
|
icon={Pencil}
|
|
45
59
|
action={() =>
|
|
@@ -57,18 +71,69 @@ export function GroupShareMenu({ group }: GroupShareMenuProps) {
|
|
|
57
71
|
action={() => openCreateConversation({ message: inviteBlurb })}
|
|
58
72
|
/>
|
|
59
73
|
<PopupSection
|
|
60
|
-
title={t('groups.actions.otherOptions', {
|
|
74
|
+
title={t('groups.actions.otherOptions', {
|
|
75
|
+
defaultValue: 'Other options',
|
|
76
|
+
})}
|
|
61
77
|
/>
|
|
62
78
|
<PopupMenuButton
|
|
63
79
|
title={t('groups.share.copyLink', { defaultValue: 'Copy link' })}
|
|
64
80
|
text={t('groups.share.copyLink', { defaultValue: 'Copy link' })}
|
|
65
81
|
icon={Link}
|
|
66
|
-
action={() =>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
action={() =>
|
|
83
|
+
copySectionLink(
|
|
84
|
+
'posts',
|
|
85
|
+
'groups.share.linkCopied',
|
|
86
|
+
'Group link copied',
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
/>
|
|
90
|
+
<PopupMenuButton
|
|
91
|
+
title={t('groups.share.copyEventsLink', {
|
|
92
|
+
defaultValue: 'Copy events link',
|
|
93
|
+
})}
|
|
94
|
+
text={t('groups.share.copyEventsLink', {
|
|
95
|
+
defaultValue: 'Copy events link',
|
|
96
|
+
})}
|
|
97
|
+
icon={Link}
|
|
98
|
+
action={() =>
|
|
99
|
+
copySectionLink(
|
|
100
|
+
'events',
|
|
101
|
+
'groups.share.eventsLinkCopied',
|
|
102
|
+
'Events link copied',
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
/>
|
|
106
|
+
<PopupMenuButton
|
|
107
|
+
title={t('groups.share.copyResourcesLink', {
|
|
108
|
+
defaultValue: 'Copy resources link',
|
|
109
|
+
})}
|
|
110
|
+
text={t('groups.share.copyResourcesLink', {
|
|
111
|
+
defaultValue: 'Copy resources link',
|
|
112
|
+
})}
|
|
113
|
+
icon={Link}
|
|
114
|
+
action={() =>
|
|
115
|
+
copySectionLink(
|
|
116
|
+
'resources',
|
|
117
|
+
'groups.share.resourcesLinkCopied',
|
|
118
|
+
'Resources link copied',
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
/>
|
|
122
|
+
<PopupMenuButton
|
|
123
|
+
title={t('groups.share.copyDescriptionLink', {
|
|
124
|
+
defaultValue: 'Copy description link',
|
|
125
|
+
})}
|
|
126
|
+
text={t('groups.share.copyDescriptionLink', {
|
|
127
|
+
defaultValue: 'Copy description link',
|
|
128
|
+
})}
|
|
129
|
+
icon={Link}
|
|
130
|
+
action={() =>
|
|
131
|
+
copySectionLink(
|
|
132
|
+
'description',
|
|
133
|
+
'groups.share.descriptionLinkCopied',
|
|
134
|
+
'Description link copied',
|
|
135
|
+
)
|
|
136
|
+
}
|
|
72
137
|
/>
|
|
73
138
|
</PopupMenu>
|
|
74
139
|
);
|
|
@@ -18,6 +18,11 @@ export { GroupCapabilityMatrix } from './GroupCapabilityMatrix';
|
|
|
18
18
|
export type { GroupCapabilityMatrixProps } from './GroupCapabilityMatrix';
|
|
19
19
|
export { GroupOptionsMenu } from './GroupOptionsMenu';
|
|
20
20
|
export type { GroupOptionsMenuProps } from './GroupOptionsMenu';
|
|
21
|
+
export {
|
|
22
|
+
GroupNotificationButton,
|
|
23
|
+
GroupNotificationSettingsModal,
|
|
24
|
+
} from './GroupNotificationSettingsModal';
|
|
25
|
+
export type { GroupNotificationSettingsModalProps } from './GroupNotificationSettingsModal';
|
|
21
26
|
export { GroupShareMenu } from './GroupShareMenu';
|
|
22
27
|
export type { GroupShareMenuProps } from './GroupShareMenu';
|
|
23
28
|
export { AddGroupMemberModal } from './AddGroupMemberModal';
|
|
@@ -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
|
-
<
|
|
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
|
|
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';
|