@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
|
@@ -2,10 +2,9 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import type { PublicPost } from '@openpeepshq/common/types';
|
|
3
3
|
import type { ExpandedOccurrence } from '@openpeepshq/common/lib';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
seriesYesBlockedByCapacity,
|
|
5
|
+
canClaimYesRsvp,
|
|
6
|
+
canJoinWaitlist,
|
|
7
|
+
seriesClaimBlocked,
|
|
9
8
|
} from '@openpeepshq/common/lib';
|
|
10
9
|
import type { RsvpScopeChoice } from '../../../hooks/events/useEventRsvp';
|
|
11
10
|
import {
|
|
@@ -27,7 +26,7 @@ export type { RsvpScopeChoice };
|
|
|
27
26
|
export type EventRsvpScopeDialogProps = {
|
|
28
27
|
open: boolean;
|
|
29
28
|
post: PublicPost;
|
|
30
|
-
response: 'yes' | 'tentative' | 'no';
|
|
29
|
+
response: 'yes' | 'tentative' | 'no' | 'waitlist';
|
|
31
30
|
defaultRecurrenceId?: string;
|
|
32
31
|
occurrences: ExpandedOccurrence[];
|
|
33
32
|
error?: string | null;
|
|
@@ -60,19 +59,16 @@ export const EventRsvpScopeDialog = ({
|
|
|
60
59
|
}: EventRsvpScopeDialogProps) => {
|
|
61
60
|
const t = useT();
|
|
62
61
|
const profile = useCurrentProfile();
|
|
63
|
-
const
|
|
64
|
-
const capacityEvent = event ? isCapacityEvent(event) : false;
|
|
62
|
+
const joiningWaitlist = response === 'waitlist';
|
|
65
63
|
const seriesFull =
|
|
66
|
-
response === 'yes' &&
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'yes' &&
|
|
75
|
-
countYesRsvps(post, recurrenceId) >= event.maxAttendees;
|
|
64
|
+
response === 'yes' && !!profile && seriesClaimBlocked(post, profile.id);
|
|
65
|
+
const occurrenceIsFull = (recurrenceId: string) => {
|
|
66
|
+
if (!profile) return false;
|
|
67
|
+
if (joiningWaitlist)
|
|
68
|
+
return !canJoinWaitlist(post, profile.id, recurrenceId);
|
|
69
|
+
if (response !== 'yes') return false;
|
|
70
|
+
return !canClaimYesRsvp(post, profile.id, recurrenceId);
|
|
71
|
+
};
|
|
76
72
|
const currentFull =
|
|
77
73
|
!!defaultRecurrenceId && occurrenceIsFull(defaultRecurrenceId);
|
|
78
74
|
const initialScope: ScopeKind = currentFull
|
|
@@ -130,9 +126,13 @@ export const EventRsvpScopeDialog = ({
|
|
|
130
126
|
<DialogContent className="max-h-[85vh] max-w-md overflow-y-auto">
|
|
131
127
|
<DialogHeader>
|
|
132
128
|
<DialogTitle>
|
|
133
|
-
{
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
{joiningWaitlist
|
|
130
|
+
? t('events.rsvp.scope.waitlistTitle', {
|
|
131
|
+
defaultValue: 'Join the waitlist for which dates?',
|
|
132
|
+
})
|
|
133
|
+
: t('events.rsvp.scope.title', {
|
|
134
|
+
defaultValue: 'Which dates?',
|
|
135
|
+
})}
|
|
136
136
|
</DialogTitle>
|
|
137
137
|
</DialogHeader>
|
|
138
138
|
<RadioGroup
|
|
@@ -157,7 +157,7 @@ export const EventRsvpScopeDialog = ({
|
|
|
157
157
|
})}
|
|
158
158
|
</label>
|
|
159
159
|
) : null}
|
|
160
|
-
{currentFull ? null : (
|
|
160
|
+
{currentFull || joiningWaitlist ? null : (
|
|
161
161
|
<label className="flex items-start gap-2 text-sm">
|
|
162
162
|
<RadioGroupItem value="series" disabled={seriesFull} />
|
|
163
163
|
<span>
|
|
@@ -200,9 +200,15 @@ export const EventRsvpScopeDialog = ({
|
|
|
200
200
|
<span className={full ? 'text-muted-foreground' : ''}>
|
|
201
201
|
{formatOccurrenceStart(occurrence.start)}
|
|
202
202
|
{full
|
|
203
|
-
? ` — ${
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
? ` — ${
|
|
204
|
+
joiningWaitlist
|
|
205
|
+
? t('events.rsvp.spotsOpen', {
|
|
206
|
+
defaultValue: 'Spots still open',
|
|
207
|
+
})
|
|
208
|
+
: t('events.rsvp.full', {
|
|
209
|
+
defaultValue: 'Event is full',
|
|
210
|
+
})
|
|
211
|
+
}`
|
|
206
212
|
: ''}
|
|
207
213
|
</span>
|
|
208
214
|
</label>
|
|
@@ -225,9 +231,15 @@ export const EventRsvpScopeDialog = ({
|
|
|
225
231
|
defaultValue: 'Cancel',
|
|
226
232
|
})}
|
|
227
233
|
onCancel={onClose}
|
|
228
|
-
actionLabel={
|
|
229
|
-
|
|
230
|
-
|
|
234
|
+
actionLabel={
|
|
235
|
+
joiningWaitlist
|
|
236
|
+
? t('events.rsvp.joinWaitlist', {
|
|
237
|
+
defaultValue: 'Join waitlist',
|
|
238
|
+
})
|
|
239
|
+
: t('events.rsvp.scope.confirm', {
|
|
240
|
+
defaultValue: 'Confirm',
|
|
241
|
+
})
|
|
242
|
+
}
|
|
231
243
|
onAction={confirm}
|
|
232
244
|
disabled={confirmDisabled}
|
|
233
245
|
/>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { PublicPost } from '@openpeepshq/common/types';
|
|
2
|
+
import { waitlistOfferWindowMs } from '@openpeepshq/common/lib';
|
|
3
|
+
import {
|
|
4
|
+
Dialog,
|
|
5
|
+
DialogActions,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogHeader,
|
|
8
|
+
DialogTitle,
|
|
9
|
+
} from '@openpeepshq/react-ui';
|
|
10
|
+
import { useT } from '../../../i18n';
|
|
11
|
+
|
|
12
|
+
export type EventWaitlistJoinDialogProps = {
|
|
13
|
+
open: boolean;
|
|
14
|
+
post: PublicPost;
|
|
15
|
+
error?: string | null;
|
|
16
|
+
submitting?: boolean;
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
onConfirm: () => void | Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const EventWaitlistJoinDialog = ({
|
|
22
|
+
open,
|
|
23
|
+
post,
|
|
24
|
+
error,
|
|
25
|
+
submitting,
|
|
26
|
+
onClose,
|
|
27
|
+
onConfirm,
|
|
28
|
+
}: EventWaitlistJoinDialogProps) => {
|
|
29
|
+
const t = useT();
|
|
30
|
+
const event = post.data?.type === 'event' ? post.data : undefined;
|
|
31
|
+
const minutes = event
|
|
32
|
+
? Math.round(waitlistOfferWindowMs(event) / 60_000)
|
|
33
|
+
: 60;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Dialog
|
|
37
|
+
open={open}
|
|
38
|
+
onOpenChange={(next) => {
|
|
39
|
+
if (!next && !submitting) onClose();
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<DialogContent className="max-w-md">
|
|
43
|
+
<DialogHeader>
|
|
44
|
+
<DialogTitle>
|
|
45
|
+
{t('events.rsvp.waitlistConfirmTitle', {
|
|
46
|
+
defaultValue: 'Join the waitlist?',
|
|
47
|
+
})}
|
|
48
|
+
</DialogTitle>
|
|
49
|
+
</DialogHeader>
|
|
50
|
+
<p className="text-sm">
|
|
51
|
+
{t('events.rsvp.atCapacity', {
|
|
52
|
+
defaultValue: 'This event is at capacity.',
|
|
53
|
+
})}
|
|
54
|
+
</p>
|
|
55
|
+
<p className="text-muted-foreground text-sm">
|
|
56
|
+
{t('events.rsvp.waitlistConfirmBody', {
|
|
57
|
+
defaultValue:
|
|
58
|
+
'If a spot opens, you will have {{minutes}} minutes to claim it.',
|
|
59
|
+
minutes,
|
|
60
|
+
})}
|
|
61
|
+
</p>
|
|
62
|
+
{error ? <p className="text-error text-sm">{error}</p> : null}
|
|
63
|
+
<DialogActions
|
|
64
|
+
cancelLabel={t('events.rsvp.scope.cancel', {
|
|
65
|
+
defaultValue: 'Cancel',
|
|
66
|
+
})}
|
|
67
|
+
onCancel={onClose}
|
|
68
|
+
actionLabel={t('events.rsvp.joinWaitlist', {
|
|
69
|
+
defaultValue: 'Join waitlist',
|
|
70
|
+
})}
|
|
71
|
+
onAction={onConfirm}
|
|
72
|
+
disabled={submitting}
|
|
73
|
+
/>
|
|
74
|
+
</DialogContent>
|
|
75
|
+
</Dialog>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
@@ -22,7 +22,10 @@ function ParticipantAvatar({ id, size }: { id: string; size: number }) {
|
|
|
22
22
|
|
|
23
23
|
/** Overlapping avatar stack of the first jam participants. Mirrors the Svelte
|
|
24
24
|
* `ParticipantsCard`. */
|
|
25
|
-
export function ParticipantsCard({
|
|
25
|
+
export function ParticipantsCard({
|
|
26
|
+
jamState,
|
|
27
|
+
size = 1.5,
|
|
28
|
+
}: ParticipantsCardProps) {
|
|
26
29
|
return (
|
|
27
30
|
<div className="flex w-full items-center justify-between gap-4">
|
|
28
31
|
<div className="flex items-center">
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Reply, Repeat2, ThumbsUp } from 'lucide-react';
|
|
1
|
+
import { Reply, Repeat2, Share, ThumbsUp } from 'lucide-react';
|
|
2
2
|
import type { PublicPost } from '@openpeepshq/common/types';
|
|
3
|
-
import { Button } from '@openpeepshq/react-ui';
|
|
3
|
+
import { Button, cn } from '@openpeepshq/react-ui';
|
|
4
4
|
import { useT } from '../../../i18n';
|
|
5
5
|
import { useFeedPostActions } from '../../../hooks/posts/useFeedPostActions';
|
|
6
6
|
import { postReactionStats } from '../helpers';
|
|
7
|
+
import { ShareMenu } from './ShareMenu';
|
|
7
8
|
|
|
8
9
|
export interface PostActionsProps {
|
|
9
10
|
post: PublicPost;
|
|
@@ -30,18 +31,31 @@ export function PostActions({
|
|
|
30
31
|
toggleReaction,
|
|
31
32
|
} = useFeedPostActions(post);
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
const replyActive = !previewMode && canReply;
|
|
35
|
+
const repostActive = !previewMode && canRepost;
|
|
36
|
+
const reactActive = !previewMode && canReact;
|
|
37
|
+
const shareActive = !previewMode;
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
// Unstyled buttons skip the shared disabled treatment. Mute them, and let
|
|
40
|
+
// presses fall through to this row so a feed link does not open the post.
|
|
41
|
+
const actionClass = (active: boolean) =>
|
|
42
|
+
cn(
|
|
43
|
+
'rounded-button flex gap-2 p-2 text-sm',
|
|
44
|
+
active
|
|
45
|
+
? 'cursor-pointer hover:bg-surface'
|
|
46
|
+
: 'pointer-events-none cursor-default text-muted-foreground disabled:text-muted-foreground',
|
|
47
|
+
);
|
|
37
48
|
|
|
38
49
|
const replyLabel = t('posts.footer.reply', { defaultValue: 'Reply' });
|
|
39
50
|
const repostLabel = t('posts.footer.repost', { defaultValue: 'Repost' });
|
|
40
51
|
const likeLabel = t('posts.footer.like', { defaultValue: 'Like' });
|
|
52
|
+
const shareLabel = t('posts.footer.share', { defaultValue: 'Share' });
|
|
41
53
|
|
|
42
54
|
return (
|
|
43
55
|
<div
|
|
44
|
-
className=
|
|
56
|
+
className={`mx-auto flex w-full cursor-default items-center p-2 ${
|
|
57
|
+
me ? 'justify-between' : 'justify-end'
|
|
58
|
+
}`}
|
|
45
59
|
onClick={(e) => {
|
|
46
60
|
e.preventDefault();
|
|
47
61
|
e.stopPropagation();
|
|
@@ -49,43 +63,60 @@ export function PostActions({
|
|
|
49
63
|
onKeyDown={(e) => e.stopPropagation()}
|
|
50
64
|
role="presentation"
|
|
51
65
|
>
|
|
52
|
-
|
|
66
|
+
{me ? (
|
|
67
|
+
<>
|
|
68
|
+
<Button
|
|
69
|
+
variant="unstyled"
|
|
70
|
+
className={actionClass(replyActive)}
|
|
71
|
+
title={t('posts.actions.reply', { defaultValue: 'Reply' })}
|
|
72
|
+
action={reply}
|
|
73
|
+
disabled={!replyActive}
|
|
74
|
+
>
|
|
75
|
+
<Reply className="h-4 w-4" />
|
|
76
|
+
{compact ? post.replyCount || null : replyLabel}
|
|
77
|
+
</Button>
|
|
78
|
+
<Button
|
|
79
|
+
variant="unstyled"
|
|
80
|
+
className={cn(
|
|
81
|
+
actionClass(repostActive),
|
|
82
|
+
myRepost && repostActive && 'text-primary',
|
|
83
|
+
)}
|
|
84
|
+
title={t('posts.actions.repost', { defaultValue: 'Repost' })}
|
|
85
|
+
action={toggleRepost}
|
|
86
|
+
disabled={!repostActive}
|
|
87
|
+
spinnerOnlyOnLoading
|
|
88
|
+
data-testid="posts-repost-button"
|
|
89
|
+
>
|
|
90
|
+
<Repeat2 className="h-4 w-4" />
|
|
91
|
+
{compact ? post.repostCount || null : repostLabel}
|
|
92
|
+
</Button>
|
|
93
|
+
<Button
|
|
94
|
+
variant="unstyled"
|
|
95
|
+
className={cn(
|
|
96
|
+
actionClass(reactActive),
|
|
97
|
+
iReacted && reactActive && 'text-primary',
|
|
98
|
+
)}
|
|
99
|
+
title={t('posts.actions.react', { defaultValue: 'React' })}
|
|
100
|
+
action={toggleReaction}
|
|
101
|
+
disabled={!reactActive}
|
|
102
|
+
spinnerOnlyOnLoading
|
|
103
|
+
>
|
|
104
|
+
<ThumbsUp className="h-4 w-4" />
|
|
105
|
+
{compact
|
|
106
|
+
? post.reactions?.length
|
|
107
|
+
? ` · ${postReactionStats(post)}`
|
|
108
|
+
: null
|
|
109
|
+
: likeLabel}
|
|
110
|
+
</Button>
|
|
111
|
+
</>
|
|
112
|
+
) : null}
|
|
113
|
+
<ShareMenu
|
|
114
|
+
post={post}
|
|
53
115
|
variant="unstyled"
|
|
54
|
-
className={
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
>
|
|
59
|
-
<Reply className="h-4 w-4" />
|
|
60
|
-
{compact ? post.replyCount || null : replyLabel}
|
|
61
|
-
</Button>
|
|
62
|
-
<Button
|
|
63
|
-
variant="unstyled"
|
|
64
|
-
className={`${actionClass} justify-self-center ${myRepost ? 'text-primary' : ''}`}
|
|
65
|
-
title={t('posts.actions.repost', { defaultValue: 'Repost' })}
|
|
66
|
-
action={toggleRepost}
|
|
67
|
-
disabled={previewMode || !canRepost}
|
|
68
|
-
spinnerOnlyOnLoading
|
|
69
|
-
data-testid="posts-repost-button"
|
|
70
|
-
>
|
|
71
|
-
<Repeat2 className="h-4 w-4" />
|
|
72
|
-
{compact ? post.repostCount || null : repostLabel}
|
|
73
|
-
</Button>
|
|
74
|
-
<Button
|
|
75
|
-
variant="unstyled"
|
|
76
|
-
className={`${actionClass} justify-self-end ${iReacted ? 'text-primary' : ''}`}
|
|
77
|
-
title={t('posts.actions.react', { defaultValue: 'React' })}
|
|
78
|
-
action={toggleReaction}
|
|
79
|
-
disabled={previewMode || !canReact}
|
|
80
|
-
spinnerOnlyOnLoading
|
|
81
|
-
>
|
|
82
|
-
<ThumbsUp className="h-4 w-4" />
|
|
83
|
-
{compact
|
|
84
|
-
? post.reactions?.length
|
|
85
|
-
? ` · ${postReactionStats(post)}`
|
|
86
|
-
: null
|
|
87
|
-
: likeLabel}
|
|
88
|
-
</Button>
|
|
116
|
+
className={actionClass(shareActive)}
|
|
117
|
+
text={compact ? undefined : shareLabel}
|
|
118
|
+
menuButton={<Share className="h-4 w-4" />}
|
|
119
|
+
/>
|
|
89
120
|
</div>
|
|
90
121
|
);
|
|
91
122
|
}
|
|
@@ -5,28 +5,51 @@ import {
|
|
|
5
5
|
PopupMenuButton,
|
|
6
6
|
PopupSection,
|
|
7
7
|
PopupSeparator,
|
|
8
|
+
type PopupMenuProps,
|
|
8
9
|
} from '@openpeepshq/react-ui';
|
|
9
10
|
import { useT } from '../../../i18n';
|
|
10
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
postPublicPath,
|
|
13
|
+
useShareMenu,
|
|
14
|
+
} from '../../../hooks/posts/useShareMenu';
|
|
11
15
|
import { useCreateNewConversation } from '../../conversations/CreateNewConversationContext';
|
|
16
|
+
import { useToast } from '../../layout/ToastProvider';
|
|
12
17
|
|
|
13
18
|
export interface ShareMenuProps {
|
|
14
19
|
post: PublicPost;
|
|
15
20
|
menuButton?: React.ReactNode;
|
|
21
|
+
/** `unstyled` matches neighboring text actions, such as the post footer. */
|
|
22
|
+
variant?: PopupMenuProps['variant'] | 'unstyled';
|
|
23
|
+
className?: string;
|
|
24
|
+
text?: string;
|
|
16
25
|
}
|
|
17
26
|
|
|
18
|
-
|
|
27
|
+
const absolutePostUrl = (post: PublicPost) => {
|
|
28
|
+
const path = postPublicPath(post);
|
|
29
|
+
return typeof window !== 'undefined'
|
|
30
|
+
? `${window.location.origin}${path}`
|
|
31
|
+
: path;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export function ShareMenu({
|
|
35
|
+
post,
|
|
36
|
+
menuButton,
|
|
37
|
+
variant = 'outline',
|
|
38
|
+
className,
|
|
39
|
+
text,
|
|
40
|
+
}: ShareMenuProps) {
|
|
19
41
|
const t = useT();
|
|
42
|
+
const { success, error: toastError } = useToast();
|
|
20
43
|
const { openCreateConversation } = useCreateNewConversation();
|
|
21
|
-
|
|
22
|
-
const postUrl =
|
|
23
|
-
typeof window !== 'undefined'
|
|
24
|
-
? `${window.location.origin}/posts/${post.id}`
|
|
25
|
-
: `/posts/${post.id}`;
|
|
44
|
+
const postUrl = absolutePostUrl(post);
|
|
26
45
|
const { signedIn, isEvent, repost, eventIcsFile } = useShareMenu(
|
|
27
46
|
post,
|
|
28
47
|
postUrl,
|
|
29
48
|
);
|
|
49
|
+
// Feature-detect. Desktop browsers often have no Web Share API; copy stays
|
|
50
|
+
// in the menu either way.
|
|
51
|
+
const canSystemShare =
|
|
52
|
+
typeof navigator !== 'undefined' && typeof navigator.share === 'function';
|
|
30
53
|
|
|
31
54
|
const downloadEventIcs = () => {
|
|
32
55
|
const file = eventIcsFile();
|
|
@@ -42,11 +65,34 @@ export function ShareMenu({ post, menuButton }: ShareMenuProps) {
|
|
|
42
65
|
URL.revokeObjectURL(href);
|
|
43
66
|
};
|
|
44
67
|
|
|
68
|
+
const copyLink = async () => {
|
|
69
|
+
try {
|
|
70
|
+
await navigator.clipboard.writeText(postUrl);
|
|
71
|
+
success(t('posts.shareMenu.linkCopied', { defaultValue: 'Link copied' }));
|
|
72
|
+
} catch {
|
|
73
|
+
toastError(
|
|
74
|
+
t('posts.shareMenu.copyFailed', {
|
|
75
|
+
defaultValue: "Couldn't copy the link",
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const systemShare = async () => {
|
|
82
|
+
try {
|
|
83
|
+
await navigator.share({ url: postUrl });
|
|
84
|
+
} catch (err) {
|
|
85
|
+
if (err instanceof DOMException && err.name === 'AbortError') return;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
45
89
|
return (
|
|
46
90
|
<PopupMenu
|
|
47
91
|
menuButton={menuButton ?? <Share className="size-4" />}
|
|
48
92
|
title={t('posts.shareMenu.title', { defaultValue: 'Share' })}
|
|
49
|
-
variant=
|
|
93
|
+
variant={variant === 'unstyled' ? undefined : variant}
|
|
94
|
+
className={className}
|
|
95
|
+
text={text}
|
|
50
96
|
>
|
|
51
97
|
{signedIn ? (
|
|
52
98
|
<>
|
|
@@ -93,11 +139,23 @@ export function ShareMenu({ post, menuButton }: ShareMenuProps) {
|
|
|
93
139
|
action={downloadEventIcs}
|
|
94
140
|
/>
|
|
95
141
|
) : null}
|
|
142
|
+
{canSystemShare ? (
|
|
143
|
+
<PopupMenuButton
|
|
144
|
+
title={t('posts.shareMenu.systemShare', {
|
|
145
|
+
defaultValue: 'Share via…',
|
|
146
|
+
})}
|
|
147
|
+
text={t('posts.shareMenu.systemShare', {
|
|
148
|
+
defaultValue: 'Share via…',
|
|
149
|
+
})}
|
|
150
|
+
icon={Share}
|
|
151
|
+
action={() => void systemShare()}
|
|
152
|
+
/>
|
|
153
|
+
) : null}
|
|
96
154
|
<PopupMenuButton
|
|
97
155
|
title={t('posts.shareMenu.copyLink', { defaultValue: 'Copy link' })}
|
|
98
156
|
text={t('posts.shareMenu.copyLink', { defaultValue: 'Copy link' })}
|
|
99
157
|
icon={Copy}
|
|
100
|
-
action={() => void
|
|
158
|
+
action={() => void copyLink()}
|
|
101
159
|
/>
|
|
102
160
|
</PopupMenu>
|
|
103
161
|
);
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
import {
|
|
8
8
|
EVENT_HEADER_ASPECT_RATIO,
|
|
9
9
|
parseEventMaxAttendeesInput,
|
|
10
|
+
parseEventWaitlistOfferMinutesInput,
|
|
10
11
|
utcIsoToZonedDateTime,
|
|
11
12
|
zonedDateTimeToUtcIso,
|
|
12
13
|
} from '@openpeepshq/common/lib';
|
|
@@ -422,6 +423,31 @@ export const EventForm = ({
|
|
|
422
423
|
) : null}
|
|
423
424
|
</div>
|
|
424
425
|
</Label>
|
|
426
|
+
{event.maxAttendees != null ? (
|
|
427
|
+
<Label
|
|
428
|
+
title={t('events.form.waitlistOfferMinutes', {
|
|
429
|
+
defaultValue: 'Waitlist response window (minutes)',
|
|
430
|
+
})}
|
|
431
|
+
description={t('events.form.waitlistOfferMinutesDescription', {
|
|
432
|
+
defaultValue:
|
|
433
|
+
'How long the next person on the waitlist has to claim a freed spot. Leave empty for 60 minutes.',
|
|
434
|
+
})}
|
|
435
|
+
>
|
|
436
|
+
<Input
|
|
437
|
+
type="number"
|
|
438
|
+
min={1}
|
|
439
|
+
max={10080}
|
|
440
|
+
value={event.waitlistOfferMinutes ?? ''}
|
|
441
|
+
onChange={(e) => {
|
|
442
|
+
patchEvent({
|
|
443
|
+
waitlistOfferMinutes: parseEventWaitlistOfferMinutesInput(
|
|
444
|
+
e.target.value,
|
|
445
|
+
),
|
|
446
|
+
});
|
|
447
|
+
}}
|
|
448
|
+
/>
|
|
449
|
+
</Label>
|
|
450
|
+
) : null}
|
|
425
451
|
</div>
|
|
426
452
|
|
|
427
453
|
{!isEdit ? (
|
|
@@ -37,8 +37,7 @@ export const VisibilitySelector = ({
|
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
const selectedGroup = useMemo(
|
|
40
|
-
() =>
|
|
41
|
-
me?.memberships?.find((m) => m.group.id === postData.groupId)?.group,
|
|
40
|
+
() => me?.memberships?.find((m) => m.group.id === postData.groupId)?.group,
|
|
42
41
|
[me?.memberships, postData.groupId],
|
|
43
42
|
);
|
|
44
43
|
|
|
@@ -34,7 +34,7 @@ export function FeedArticle({ post }: FeedArticleProps) {
|
|
|
34
34
|
/>
|
|
35
35
|
)}
|
|
36
36
|
<div className="prose-sm">
|
|
37
|
-
<h3>{article.title}</h3>
|
|
37
|
+
<h3 className="text-foreground">{article.title}</h3>
|
|
38
38
|
{minutes > 0 && (
|
|
39
39
|
<p className="text-muted-foreground text-xs">
|
|
40
40
|
{t('posts.article.minutesToRead', { count: minutes })}
|
|
@@ -29,8 +29,8 @@ export function FullArticle({ post }: FullArticleProps) {
|
|
|
29
29
|
alt={article.title ? `image for ${article.title}` : 'Article'}
|
|
30
30
|
/>
|
|
31
31
|
) : null}
|
|
32
|
-
<div className="prose mb-6">
|
|
33
|
-
<h1>{article.title}</h1>
|
|
32
|
+
<div className="prose dark:prose-invert mb-6">
|
|
33
|
+
<h1 className="text-foreground">{article.title}</h1>
|
|
34
34
|
{minutes > 0 && (
|
|
35
35
|
<p className="text-muted-foreground text-sm">
|
|
36
36
|
{t('posts.article.minutesToRead', { count: minutes })}
|
|
@@ -12,6 +12,7 @@ import { useServerInfo } from '../../../server-data';
|
|
|
12
12
|
import { usePostViewRef } from '../../../../lib/postViewCounter';
|
|
13
13
|
import { EventLocation } from '../../pieces/EventLocation';
|
|
14
14
|
import { ParticipantsCard } from '../../pieces/ParticipantsCard';
|
|
15
|
+
import { ShareMenu } from '../../pieces/ShareMenu';
|
|
15
16
|
import { ProfileEventRelationship } from './ProfileEventRelationship';
|
|
16
17
|
|
|
17
18
|
export interface CardEventProps {
|
|
@@ -78,20 +79,31 @@ export function CardEvent({ post, showEventDate = true }: CardEventProps) {
|
|
|
78
79
|
</div>
|
|
79
80
|
</a>
|
|
80
81
|
<div className="grid gap-y-4 p-4">
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
82
|
+
<div className="flex items-start gap-2">
|
|
83
|
+
<a
|
|
84
|
+
href={postLink}
|
|
85
|
+
className="block min-w-0 flex-1 text-inherit no-underline"
|
|
86
|
+
>
|
|
87
|
+
{showEventDate ? (
|
|
88
|
+
<p className="text-muted-foreground text-sm">
|
|
89
|
+
{formatEventTimespan(
|
|
90
|
+
event,
|
|
91
|
+
post.occurrenceStart,
|
|
92
|
+
post.occurrenceEnd,
|
|
93
|
+
)}
|
|
94
|
+
</p>
|
|
95
|
+
) : null}
|
|
96
|
+
<h3 className="text-xl font-semibold">
|
|
97
|
+
{truncateText(event.name, 100) || '-'}
|
|
98
|
+
</h3>
|
|
99
|
+
</a>
|
|
100
|
+
<ShareMenu
|
|
101
|
+
post={post}
|
|
102
|
+
variant="ghost"
|
|
103
|
+
className="shrink-0"
|
|
104
|
+
text={t('posts.footer.share', { defaultValue: 'Share' })}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
95
107
|
{event.recurrence ? (
|
|
96
108
|
<p className="text-muted-foreground text-sm">
|
|
97
109
|
{formatEventRecurrence(event.recurrence, t, event.start)}
|