@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.
Files changed (204) 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/groups/GroupHeader.js +2 -1
  5. package/dist/components/groups/GroupNotificationSettingsModal.d.ts +9 -0
  6. package/dist/components/groups/GroupNotificationSettingsModal.js +57 -0
  7. package/dist/components/groups/GroupShareMenu.js +30 -8
  8. package/dist/components/groups/index.d.ts +2 -0
  9. package/dist/components/groups/index.js +1 -0
  10. package/dist/components/jams/JamCapacityGate.js +1 -1
  11. package/dist/components/jams/JamConference.js +2 -0
  12. package/dist/components/jams/JamParticipantConference.js +2 -0
  13. package/dist/components/jams/JamRoom.js +2 -3
  14. package/dist/components/jams/LiveJamsSection.js +8 -2
  15. package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
  16. package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
  17. package/dist/components/jams/dropLateAudio.d.ts +22 -0
  18. package/dist/components/jams/dropLateAudio.js +115 -0
  19. package/dist/components/jams/index.d.ts +1 -0
  20. package/dist/components/jams/index.js +1 -0
  21. package/dist/components/notifications/TypedNotification.js +46 -4
  22. package/dist/components/post/Markdown.d.ts +2 -2
  23. package/dist/components/post/Markdown.js +1 -1
  24. package/dist/components/post/attachmentPreview.js +1 -1
  25. package/dist/components/post/pieces/Attachments.js +23 -17
  26. package/dist/components/post/pieces/EventRsvpButton.js +37 -7
  27. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  28. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  29. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  30. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  31. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  32. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  33. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  34. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  35. package/dist/components/post/pieces/PostActions.js +20 -12
  36. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  37. package/dist/components/post/pieces/ShareMenu.js +40 -7
  38. package/dist/components/post/post-form/EventForm.js +10 -2
  39. package/dist/components/post/types/Article.js +1 -1
  40. package/dist/components/post/types/article/FullArticle.js +1 -1
  41. package/dist/components/post/types/event/CardEvent.js +2 -1
  42. package/dist/components/post/types/event/FullEvent.js +21 -11
  43. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  44. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  45. package/dist/components/preview-link/PreviewLink.js +1 -1
  46. package/dist/components/preview-link/helpers.d.ts +5 -0
  47. package/dist/components/preview-link/helpers.js +27 -1
  48. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  49. package/dist/components/preview-link/local/WelcomePreview.js +6 -0
  50. package/dist/components/profile/Avatar.js +2 -2
  51. package/dist/components/profile/ProfileFromId.js +1 -1
  52. package/dist/components/server-data/context.d.ts +1 -0
  53. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  54. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  55. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  56. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  57. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  58. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  59. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  60. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  61. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  62. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  63. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  64. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  65. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  66. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  67. package/dist/hooks/events/useEventForm.d.ts +1 -0
  68. package/dist/hooks/events/useEventRsvp.d.ts +11 -2
  69. package/dist/hooks/events/useEventRsvp.js +46 -5
  70. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  71. package/dist/hooks/groups/useGroupNotificationLevel.d.ts +9 -0
  72. package/dist/hooks/groups/useGroupNotificationLevel.js +57 -0
  73. package/dist/hooks/groups/useNewGroup.js +22 -2
  74. package/dist/hooks/index.d.ts +6 -1
  75. package/dist/hooks/index.js +5 -1
  76. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  77. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  78. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  79. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  80. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  81. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  82. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  83. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  84. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  85. package/dist/hooks/posts/useResourceComposer.d.ts +93 -41
  86. package/dist/hooks/posts/useResourceComposer.js +4 -2
  87. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  88. package/dist/hooks/posts/useShareMenu.js +7 -0
  89. package/dist/hooks/resources/useResourceLibrary.d.ts +176 -78
  90. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  91. package/dist/hooks/useWelcomePreview.d.ts +13 -0
  92. package/dist/hooks/useWelcomePreview.js +39 -0
  93. package/dist/lib/groupFormErrors.d.ts +1 -0
  94. package/dist/lib/groupFormErrors.js +5 -2
  95. package/dist/lib/threadHelpers.js +1 -5
  96. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  97. package/dist/pages/admin/Diagnostics.js +1 -1
  98. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  99. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  100. package/dist/pages/admin/Invites.js +5 -3
  101. package/dist/pages/admin/Media.d.ts +1 -0
  102. package/dist/pages/admin/Media.js +135 -0
  103. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  104. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  105. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  106. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  107. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  108. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  109. package/dist/pages/admin/configurationSsoShared.d.ts +4 -0
  110. package/dist/pages/auth/Register.js +30 -8
  111. package/dist/pages/conversations/Show.js +11 -0
  112. package/dist/pages/groups/Show.js +22 -19
  113. package/dist/pages/index.d.ts +3 -0
  114. package/dist/pages/index.js +3 -0
  115. package/dist/pages/jams/Index.js +2 -4
  116. package/dist/pages/settings/PublicProfile.js +15 -3
  117. package/dist/pwa/sw.d.ts +0 -1
  118. package/dist/react-native.d.ts +2 -1
  119. package/dist/react-native.js +2 -1
  120. package/dist/stores/newPosts.d.ts +4 -2
  121. package/dist/stores/newPosts.js +6 -1
  122. package/package.json +11 -6
  123. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  124. package/src/components/configuration/ConfigurationList.tsx +6 -1
  125. package/src/components/form/LocationInput.tsx +7 -1
  126. package/src/components/groups/GroupHeader.tsx +2 -0
  127. package/src/components/groups/GroupNotificationSettingsModal.tsx +163 -0
  128. package/src/components/groups/GroupShareMenu.tsx +77 -12
  129. package/src/components/groups/index.ts +5 -0
  130. package/src/components/jams/JamCapacityGate.tsx +1 -1
  131. package/src/components/jams/JamConference.tsx +2 -0
  132. package/src/components/jams/JamParticipantConference.tsx +2 -0
  133. package/src/components/jams/JamRoom.tsx +2 -6
  134. package/src/components/jams/LiveJamsSection.tsx +16 -2
  135. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  136. package/src/components/jams/dropLateAudio.ts +153 -0
  137. package/src/components/jams/index.ts +1 -0
  138. package/src/components/notifications/TypedNotification.tsx +81 -9
  139. package/src/components/post/Markdown.tsx +8 -2
  140. package/src/components/post/attachmentPreview.ts +1 -3
  141. package/src/components/post/pieces/Attachments.tsx +93 -78
  142. package/src/components/post/pieces/EventRsvpButton.tsx +107 -7
  143. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  144. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  145. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  146. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  147. package/src/components/post/pieces/PostActions.tsx +73 -42
  148. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  149. package/src/components/post/post-form/EventForm.tsx +26 -0
  150. package/src/components/post/post-form/VisibilitySelector.tsx +1 -2
  151. package/src/components/post/types/Article.tsx +1 -1
  152. package/src/components/post/types/article/FullArticle.tsx +2 -2
  153. package/src/components/post/types/event/CardEvent.tsx +26 -14
  154. package/src/components/post/types/event/FullEvent.tsx +47 -29
  155. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  156. package/src/components/post/types/note/FullNote.tsx +1 -4
  157. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  158. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  159. package/src/components/preview-link/PreviewLink.tsx +2 -7
  160. package/src/components/preview-link/helpers.ts +32 -1
  161. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  162. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  163. package/src/components/preview-link/local/WelcomePreview.tsx +36 -0
  164. package/src/components/profile/Avatar.tsx +6 -2
  165. package/src/components/profile/ProfileFromId.tsx +1 -5
  166. package/src/components/resources/ResourceCard.tsx +0 -1
  167. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  168. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  169. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  170. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  171. package/src/css.d.ts +4 -0
  172. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  173. package/src/hooks/events/useEventRsvp.ts +51 -7
  174. package/src/hooks/groups/useGroupNotificationLevel.ts +57 -0
  175. package/src/hooks/groups/useNewGroup.ts +28 -3
  176. package/src/hooks/index.ts +9 -1
  177. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  178. package/src/hooks/posts/useResourceComposer.ts +8 -6
  179. package/src/hooks/posts/useShareMenu.ts +9 -0
  180. package/src/hooks/useWelcomePreview.ts +57 -0
  181. package/src/i18n/I18nProvider.tsx +1 -4
  182. package/src/lib/groupFormErrors.ts +9 -2
  183. package/src/lib/threadHelpers.ts +1 -5
  184. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  185. package/src/pages/admin/Diagnostics.tsx +4 -0
  186. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  187. package/src/pages/admin/Invites.tsx +23 -1
  188. package/src/pages/admin/Media.tsx +290 -0
  189. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  190. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  191. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  192. package/src/pages/auth/Register.tsx +33 -4
  193. package/src/pages/conversations/Show.tsx +11 -0
  194. package/src/pages/groups/Show.tsx +60 -53
  195. package/src/pages/index.ts +3 -0
  196. package/src/pages/jams/Index.tsx +2 -6
  197. package/src/pages/settings/PublicProfile.tsx +20 -2
  198. package/src/pwa/sw.ts +6 -3
  199. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  200. package/src/react-native.ts +2 -1
  201. package/src/stores/newPosts.ts +6 -1
  202. package/src/streaming.ts +3 -3
  203. package/dist/setupTests.d.ts +0 -1
  204. package/dist/setupTests.js +0 -5
@@ -1,6 +1,6 @@
1
1
  import type { PublicPost } from '@openpeepshq/common/types';
2
2
  import type { ExpandedOccurrence } from '@openpeepshq/common/lib';
3
- export type RsvpChoice = 'yes' | 'tentative' | 'no';
3
+ export type RsvpChoice = 'yes' | 'tentative' | 'no' | 'waitlist';
4
4
  export type RsvpScopeChoice = {
5
5
  kind: 'this';
6
6
  recurrenceId: string;
@@ -22,7 +22,7 @@ export declare const useEventRsvp: ({ post, recurrenceId, lockToOccurrence, onSu
22
22
  profile: import("@openpeepshq/common").ProfileWithMeta | undefined;
23
23
  myEvent: boolean;
24
24
  myRsvp: {
25
- response: "no" | "yes" | "tentative" | "removed";
25
+ response: "no" | "yes" | "tentative" | "removed" | "waitlist";
26
26
  profile: {
27
27
  id: string;
28
28
  type: "local" | "guest" | "federated";
@@ -83,6 +83,8 @@ export declare const useEventRsvp: ({ post, recurrenceId, lockToOccurrence, onSu
83
83
  };
84
84
  createdAt: string;
85
85
  recurrenceId?: string | undefined;
86
+ waitlistJoinedAt?: string | undefined;
87
+ offerExpiresAt?: string | undefined;
86
88
  } | undefined;
87
89
  canRsvp: boolean;
88
90
  rsvpClosed: boolean;
@@ -91,10 +93,17 @@ export declare const useEventRsvp: ({ post, recurrenceId, lockToOccurrence, onSu
91
93
  occurrences: ExpandedOccurrence[];
92
94
  capacityEvent: boolean;
93
95
  full: boolean;
96
+ onWaitlist: boolean;
97
+ offerExpiresAt: string | undefined;
94
98
  error: string | null;
95
99
  pending: RsvpChoice | null;
96
100
  setPending: import("react").Dispatch<import("react").SetStateAction<RsvpChoice | null>>;
101
+ confirmingWaitlist: boolean;
102
+ setConfirmingWaitlist: import("react").Dispatch<import("react").SetStateAction<boolean>>;
97
103
  submitting: boolean;
98
104
  requestRespond: (response: RsvpChoice) => void;
105
+ requestJoinWaitlist: () => void;
106
+ confirmJoinWaitlist: () => Promise<boolean>;
107
+ claimSpot: () => void;
99
108
  confirmScope: (scope: RsvpScopeChoice) => Promise<boolean>;
100
109
  };
@@ -1,5 +1,5 @@
1
1
  import { useMemo, useState } from 'react';
2
- import { checkPostCapabilities, countYesRsvps, defaultRsvpRecurrenceId, displayRsvpForProfile, eventRsvpOpen, isCapacityEvent, isRecurringEvent, listRsvpOccurrences, recurringEventHasOpenOccurrence, } from '@openpeepshq/common/lib';
2
+ import { canClaimYesRsvp, checkPostCapabilities, defaultRsvpRecurrenceId, displayRsvpForProfile, eventRsvpOpen, isCapacityEvent, isRecurringEvent, listRsvpOccurrences, offerStillOpen, seriesHasClaimableOccurrence, } from '@openpeepshq/common/lib';
3
3
  import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
4
4
  import { useT } from '../../i18n/context.js';
5
5
  import { apiErrorMessage } from '../../lib/apiErrorMessage.js';
@@ -14,6 +14,7 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
14
14
  const rsvpToEvent = openpeepsApi.rsvpToEventAction({ id: post.id });
15
15
  const [error, setError] = useState(null);
16
16
  const [pending, setPending] = useState(null);
17
+ const [confirmingWaitlist, setConfirmingWaitlist] = useState(false);
17
18
  const [submitting, setSubmitting] = useState(false);
18
19
  const eventData = post.data?.type === 'event' ? post.data : undefined;
19
20
  const recurring = eventData ? isRecurringEvent(eventData) : false;
@@ -27,13 +28,17 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
27
28
  ? defaultRsvpRecurrenceId(eventData, queriedOccurrenceClosed ? undefined : recurrenceId)
28
29
  : undefined;
29
30
  const occurrences = eventData && recurring ? listRsvpOccurrences(eventData) : [];
30
- const capacityRecurrenceId = lockToOccurrence ? recurrenceId : defaultId;
31
+ const capacityRecurrenceId = recurring
32
+ ? lockToOccurrence
33
+ ? recurrenceId
34
+ : defaultId
35
+ : undefined;
31
36
  const capacityEvent = eventData ? isCapacityEvent(eventData) : false;
32
37
  const atCapacity = capacityEvent &&
33
- eventData?.maxAttendees !== undefined &&
38
+ !!profile &&
34
39
  (recurring && !lockToOccurrence
35
- ? !recurringEventHasOpenOccurrence(post, profile?.id)
36
- : countYesRsvps(post, capacityRecurrenceId) >= eventData.maxAttendees);
40
+ ? !seriesHasClaimableOccurrence(post, profile.id)
41
+ : !canClaimYesRsvp(post, profile.id, capacityRecurrenceId));
37
42
  const myEvent = post.profile?.id === profile?.id;
38
43
  const myRsvp = useMemo(() => profile
39
44
  ? displayRsvpForProfile(post, profile.id, {
@@ -44,6 +49,8 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
44
49
  const canRsvp = useMemo(() => checkPostCapabilities(authData, ['core-posts-rsvp'], post, capabilities)
45
50
  .success, [authData, post, capabilities]);
46
51
  const full = atCapacity && myRsvp?.response !== 'yes';
52
+ const onWaitlist = myRsvp?.response === 'waitlist';
53
+ const offerExpiresAt = onWaitlist && offerStillOpen(myRsvp) ? myRsvp.offerExpiresAt : undefined;
47
54
  const writeRsvp = async (response, recurrenceIds) => {
48
55
  setError(null);
49
56
  setSubmitting(true);
@@ -69,6 +76,33 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
69
76
  setSubmitting(false);
70
77
  }
71
78
  };
79
+ const requestJoinWaitlist = () => {
80
+ if (rsvpClosed)
81
+ return;
82
+ if (!recurring || lockToOccurrence) {
83
+ setError(null);
84
+ setConfirmingWaitlist(true);
85
+ return;
86
+ }
87
+ setError(null);
88
+ setPending('waitlist');
89
+ };
90
+ const confirmJoinWaitlist = async () => {
91
+ try {
92
+ await writeRsvp('waitlist', recurrenceId ? [recurrenceId] : undefined);
93
+ setConfirmingWaitlist(false);
94
+ return true;
95
+ }
96
+ catch {
97
+ return false;
98
+ }
99
+ };
100
+ const claimSpot = () => {
101
+ const id = recurring
102
+ ? (myRsvp?.recurrenceId ?? (lockToOccurrence ? recurrenceId : defaultId))
103
+ : undefined;
104
+ writeRsvp('yes', id ? [id] : undefined).catch(() => undefined);
105
+ };
72
106
  const requestRespond = (response) => {
73
107
  if (rsvpClosed)
74
108
  return;
@@ -110,11 +144,18 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
110
144
  occurrences,
111
145
  capacityEvent,
112
146
  full,
147
+ onWaitlist,
148
+ offerExpiresAt,
113
149
  error,
114
150
  pending,
115
151
  setPending,
152
+ confirmingWaitlist,
153
+ setConfirmingWaitlist,
116
154
  submitting,
117
155
  requestRespond,
156
+ requestJoinWaitlist,
157
+ confirmJoinWaitlist,
158
+ claimSpot,
118
159
  confirmScope,
119
160
  };
120
161
  };