@openpeepshq/react 0.9.23 → 0.11.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 (272) hide show
  1. package/dist/components/RelationCapabilitiesEditor.js +3 -3
  2. package/dist/components/RoleCapabilityMatrix.js +2 -2
  3. package/dist/components/accounts/SignUpLoginModal.js +1 -1
  4. package/dist/components/configuration/ConfigurationList.js +2 -2
  5. package/dist/components/conversations/ConversationMessageBubble.js +8 -1
  6. package/dist/components/conversations/CreateNewConversation.js +34 -17
  7. package/dist/components/form/ImageEditModal.js +2 -2
  8. package/dist/components/groups/ChangeGroupRolesModal.js +1 -1
  9. package/dist/components/groups/ConfirmGroupExitModal.js +1 -1
  10. package/dist/components/groups/ConfirmMemberRemovalModal.js +1 -1
  11. package/dist/components/groups/DeleteGroupModal.js +1 -1
  12. package/dist/components/groups/GroupForm.js +2 -2
  13. package/dist/components/groups/GroupNotificationSettingsModal.js +2 -2
  14. package/dist/components/jams/JamCallParticipant.js +4 -3
  15. package/dist/components/jams/JamGuestForm.js +1 -1
  16. package/dist/components/jams/jamEventActions.d.ts +10 -0
  17. package/dist/components/jams/jamEventActions.js +13 -0
  18. package/dist/components/navigation/ContentHeader.js +1 -1
  19. package/dist/components/navigation/FooterMobile.js +1 -1
  20. package/dist/components/navigation/SideBar.js +3 -3
  21. package/dist/components/post/FullPostLayout.js +1 -1
  22. package/dist/components/post/index.d.ts +1 -0
  23. package/dist/components/post/index.js +1 -0
  24. package/dist/components/post/pieces/EventRsvpList.js +1 -1
  25. package/dist/components/post/pieces/EventRsvpScopeDialog.js +2 -2
  26. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +1 -1
  27. package/dist/components/post/pieces/GalleryModal.js +1 -1
  28. package/dist/components/post/pieces/modals/DeletePostModal.js +2 -2
  29. package/dist/components/post/post-form/ComposeAttachments.d.ts +2 -0
  30. package/dist/components/post/post-form/ComposeAttachments.js +8 -0
  31. package/dist/components/post/post-form/DescriptionEditModal.js +1 -1
  32. package/dist/components/post/post-form/EditPostModal.js +2 -2
  33. package/dist/components/post/post-form/EventForm.js +4 -26
  34. package/dist/components/post/post-form/PostAudienceSelector.js +2 -2
  35. package/dist/components/post/post-form/ReplyModal.js +1 -1
  36. package/dist/components/post/types/event/FullEvent.js +3 -3
  37. package/dist/components/post/types/resource/FullResource.js +2 -1
  38. package/dist/components/preview-link/RemotePreviewLink.js +32 -4
  39. package/dist/components/preview-link/RemotePreviewLink.test.d.ts +1 -0
  40. package/dist/components/preview-link/RemotePreviewLink.test.js +118 -0
  41. package/dist/components/profile/ProfileActivitySummary.js +4 -4
  42. package/dist/components/profile/ProfileBadge.js +1 -1
  43. package/dist/components/profile/ProfilePageAction.js +1 -1
  44. package/dist/components/profile/ProfilePostsAndReplies.js +1 -1
  45. package/dist/components/profile/ProfileSelector.js +1 -1
  46. package/dist/components/profile/ReportProfileOrPostModal.js +4 -2
  47. package/dist/components/resources/CategoryPathPicker.js +1 -1
  48. package/dist/components/resources/ResourceCard.js +5 -3
  49. package/dist/components/resources/ResourceLibrary.js +61 -8
  50. package/dist/components/resources/ResourceLibrary.test.d.ts +1 -0
  51. package/dist/components/resources/ResourceLibrary.test.js +122 -0
  52. package/dist/components/server-data/context.d.ts +25 -16
  53. package/dist/contexts/openpeeps/hooks/admin.d.ts +2 -2
  54. package/dist/contexts/openpeeps/hooks/auth.d.ts +1 -1
  55. package/dist/contexts/openpeeps/hooks/other.d.ts +1 -0
  56. package/dist/contexts/router/index.d.ts +8 -0
  57. package/dist/contexts/router/index.js +27 -2
  58. package/dist/hooks/conversations/dmMessage.d.ts +15 -0
  59. package/dist/hooks/conversations/dmMessage.js +12 -0
  60. package/dist/hooks/conversations/useCreateConversation.d.ts +40 -0
  61. package/dist/hooks/conversations/useCreateConversation.js +6 -0
  62. package/dist/hooks/events/useEventForm.d.ts +3 -0
  63. package/dist/hooks/events/useEventForm.js +31 -2
  64. package/dist/hooks/events/useEventForm.test.d.ts +1 -0
  65. package/dist/hooks/events/useEventForm.test.js +107 -0
  66. package/dist/hooks/index.d.ts +3 -1
  67. package/dist/hooks/index.js +3 -1
  68. package/dist/hooks/posts/useFeedPostActions.js +4 -15
  69. package/dist/hooks/posts/usePostReactionToggle.d.ts +14 -0
  70. package/dist/hooks/posts/usePostReactionToggle.js +46 -0
  71. package/dist/hooks/resources/useResourceLibrary.d.ts +8 -1
  72. package/dist/hooks/resources/useResourceLibrary.js +5 -5
  73. package/dist/hooks/settings/useAccessTokens.d.ts +3 -3
  74. package/dist/hooks/settings/useAccessTokens.js +1 -0
  75. package/dist/lib/downloadUrl.d.ts +6 -0
  76. package/dist/lib/downloadUrl.js +6 -0
  77. package/dist/navigation/menuItems.js +4 -4
  78. package/dist/pages/Explore.js +1 -1
  79. package/dist/pages/admin/ApiKeys.js +3 -3
  80. package/dist/pages/admin/ConfigEditor.js +1 -1
  81. package/dist/pages/admin/ConfigurationCommunityFeed.js +2 -2
  82. package/dist/pages/admin/ConfigurationCommunityLanguage.js +2 -2
  83. package/dist/pages/admin/ConfigurationCommunityTimezone.js +2 -2
  84. package/dist/pages/admin/ConfigurationEmail.js +2 -2
  85. package/dist/pages/admin/ConfigurationI18n.js +1 -1
  86. package/dist/pages/admin/ConfigurationSso.js +1 -1
  87. package/dist/pages/admin/ConfigurationSsoNew.js +1 -1
  88. package/dist/pages/admin/Dashboard.js +1 -1
  89. package/dist/pages/admin/Db.js +4 -4
  90. package/dist/pages/admin/DiagnosticsEmail.js +3 -3
  91. package/dist/pages/admin/DiagnosticsJob.js +2 -2
  92. package/dist/pages/admin/DiagnosticsLivekit.js +1 -1
  93. package/dist/pages/admin/DiagnosticsLogs.js +2 -2
  94. package/dist/pages/admin/DiagnosticsPerformance.js +1 -1
  95. package/dist/pages/admin/GroupMembers.js +5 -5
  96. package/dist/pages/admin/Groups.js +2 -2
  97. package/dist/pages/admin/Invites.js +3 -3
  98. package/dist/pages/admin/Media.js +2 -2
  99. package/dist/pages/admin/MemberDetail.js +7 -7
  100. package/dist/pages/admin/Members.js +2 -2
  101. package/dist/pages/admin/analytics/AnalyticsLayout.js +3 -1
  102. package/dist/pages/admin/analytics/Content.js +1 -1
  103. package/dist/pages/admin/analytics/Engagement.js +1 -1
  104. package/dist/pages/admin/analytics/Groups.js +1 -1
  105. package/dist/pages/admin/analytics/ReportSettings.js +1 -1
  106. package/dist/pages/admin/community/CommunityAccess.js +1 -1
  107. package/dist/pages/admin/community/CommunityFavicons.js +1 -1
  108. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +2 -2
  109. package/dist/pages/admin/community/CommunityInfo.js +1 -1
  110. package/dist/pages/admin/community/CommunityLinks.js +7 -3
  111. package/dist/pages/admin/community/CommunityMarkdownPage.js +1 -1
  112. package/dist/pages/admin/community/CommunityProfileFields.js +2 -2
  113. package/dist/pages/admin/community/CommunityRoles.js +7 -7
  114. package/dist/pages/admin/community/CommunityTheme.js +3 -2
  115. package/dist/pages/admin/community/ThemeColorPreview.d.ts +8 -0
  116. package/dist/pages/admin/community/ThemeColorPreview.js +46 -0
  117. package/dist/pages/admin/community/ThemeColorPreview.test.d.ts +1 -0
  118. package/dist/pages/admin/community/ThemeColorPreview.test.js +49 -0
  119. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  120. package/dist/pages/admin/components/AdminGroupCard.js +1 -1
  121. package/dist/pages/admin/components/EditInviteLinkModal.js +1 -1
  122. package/dist/pages/admin/components/InviteWithEmailModal.js +2 -2
  123. package/dist/pages/admin/components/InviteWithLinkModal.js +3 -3
  124. package/dist/pages/admin/components/ProfileRowActions.js +4 -4
  125. package/dist/pages/admin/components/RestoreBackupModal.js +2 -2
  126. package/dist/pages/admin/components/RestoreTestBackupModal.js +1 -1
  127. package/dist/pages/auth/Login.js +1 -1
  128. package/dist/pages/auth/Register.js +3 -3
  129. package/dist/pages/auth/RequestResetPassword.js +1 -1
  130. package/dist/pages/conversations/Info.js +1 -1
  131. package/dist/pages/conversations/Show.js +45 -15
  132. package/dist/pages/events/Index.js +1 -1
  133. package/dist/pages/feeds/Bookmarks.js +1 -1
  134. package/dist/pages/groups/EditInfo.js +1 -1
  135. package/dist/pages/groups/EditRoles.js +1 -1
  136. package/dist/pages/groups/Index.js +1 -1
  137. package/dist/pages/groups/Members.js +2 -2
  138. package/dist/pages/groups/New.js +1 -1
  139. package/dist/pages/groups/Show.js +2 -2
  140. package/dist/pages/settings/AccessTokens.js +4 -4
  141. package/dist/pages/settings/Account.js +1 -1
  142. package/dist/pages/settings/Feed.js +1 -1
  143. package/dist/pages/settings/Language.js +1 -1
  144. package/dist/pages/settings/PublicProfile.js +3 -3
  145. package/dist/pages/settings/PushEnabledDevices.js +1 -1
  146. package/dist/pages/settings/Theme.js +1 -1
  147. package/dist/pages/settings/Timezone.js +1 -1
  148. package/dist/react-native.d.ts +1 -1
  149. package/dist/react-native.js +1 -1
  150. package/package.json +9 -9
  151. package/src/components/RelationCapabilitiesEditor.tsx +3 -3
  152. package/src/components/RoleCapabilityMatrix.tsx +2 -2
  153. package/src/components/accounts/SignUpLoginModal.tsx +1 -1
  154. package/src/components/configuration/ConfigurationList.tsx +2 -2
  155. package/src/components/conversations/ConversationMessageBubble.tsx +24 -0
  156. package/src/components/conversations/CreateNewConversation.tsx +114 -78
  157. package/src/components/form/ImageEditModal.tsx +2 -2
  158. package/src/components/groups/ChangeGroupRolesModal.tsx +1 -1
  159. package/src/components/groups/ConfirmGroupExitModal.tsx +1 -1
  160. package/src/components/groups/ConfirmMemberRemovalModal.tsx +2 -2
  161. package/src/components/groups/DeleteGroupModal.tsx +2 -2
  162. package/src/components/groups/GroupForm.tsx +2 -2
  163. package/src/components/groups/GroupNotificationSettingsModal.tsx +2 -2
  164. package/src/components/jams/JamCallParticipant.tsx +4 -3
  165. package/src/components/jams/JamGuestForm.tsx +1 -1
  166. package/src/components/jams/jamEventActions.ts +21 -0
  167. package/src/components/navigation/ContentHeader.tsx +3 -3
  168. package/src/components/navigation/FooterMobile.tsx +1 -1
  169. package/src/components/navigation/SideBar.tsx +19 -5
  170. package/src/components/post/FullPostLayout.tsx +1 -1
  171. package/src/components/post/index.ts +1 -0
  172. package/src/components/post/pieces/EventRsvpList.tsx +1 -1
  173. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +2 -2
  174. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +1 -1
  175. package/src/components/post/pieces/GalleryModal.tsx +1 -1
  176. package/src/components/post/pieces/modals/DeletePostModal.tsx +2 -2
  177. package/src/components/post/post-form/ComposeAttachments.tsx +10 -0
  178. package/src/components/post/post-form/DescriptionEditModal.tsx +1 -1
  179. package/src/components/post/post-form/EditPostModal.tsx +2 -2
  180. package/src/components/post/post-form/EventForm.tsx +8 -26
  181. package/src/components/post/post-form/PostAudienceSelector.tsx +2 -2
  182. package/src/components/post/post-form/ReplyModal.tsx +1 -1
  183. package/src/components/post/types/event/FullEvent.tsx +3 -3
  184. package/src/components/post/types/resource/FullResource.tsx +2 -1
  185. package/src/components/preview-link/RemotePreviewLink.tsx +92 -25
  186. package/src/components/profile/ProfileActivitySummary.tsx +4 -4
  187. package/src/components/profile/ProfileBadge.tsx +1 -1
  188. package/src/components/profile/ProfilePageAction.tsx +1 -1
  189. package/src/components/profile/ProfilePostsAndReplies.tsx +2 -2
  190. package/src/components/profile/ProfileSelector.tsx +1 -1
  191. package/src/components/profile/ReportProfileOrPostModal.tsx +4 -2
  192. package/src/components/resources/CategoryPathPicker.tsx +1 -1
  193. package/src/components/resources/ResourceCard.tsx +5 -3
  194. package/src/components/resources/ResourceLibrary.tsx +79 -4
  195. package/src/contexts/router/index.tsx +40 -1
  196. package/src/hooks/conversations/dmMessage.ts +26 -0
  197. package/src/hooks/conversations/useCreateConversation.ts +7 -0
  198. package/src/hooks/events/useEventForm.ts +32 -1
  199. package/src/hooks/index.ts +10 -1
  200. package/src/hooks/posts/useFeedPostActions.ts +4 -18
  201. package/src/hooks/posts/usePostReactionToggle.ts +60 -0
  202. package/src/hooks/resources/useResourceLibrary.ts +20 -5
  203. package/src/hooks/settings/useAccessTokens.ts +1 -0
  204. package/src/lib/downloadUrl.ts +7 -0
  205. package/src/navigation/menuItems.ts +4 -4
  206. package/src/pages/Explore.tsx +4 -4
  207. package/src/pages/admin/ApiKeys.tsx +4 -4
  208. package/src/pages/admin/ConfigEditor.tsx +1 -1
  209. package/src/pages/admin/ConfigurationCommunityFeed.tsx +2 -2
  210. package/src/pages/admin/ConfigurationCommunityLanguage.tsx +2 -2
  211. package/src/pages/admin/ConfigurationCommunityTimezone.tsx +2 -2
  212. package/src/pages/admin/ConfigurationEmail.tsx +2 -2
  213. package/src/pages/admin/ConfigurationI18n.tsx +1 -1
  214. package/src/pages/admin/ConfigurationSso.tsx +1 -1
  215. package/src/pages/admin/ConfigurationSsoNew.tsx +1 -1
  216. package/src/pages/admin/Dashboard.tsx +1 -1
  217. package/src/pages/admin/Db.tsx +6 -6
  218. package/src/pages/admin/DiagnosticsEmail.tsx +5 -5
  219. package/src/pages/admin/DiagnosticsJob.tsx +2 -2
  220. package/src/pages/admin/DiagnosticsLivekit.tsx +3 -3
  221. package/src/pages/admin/DiagnosticsLogs.tsx +4 -4
  222. package/src/pages/admin/DiagnosticsPerformance.tsx +1 -1
  223. package/src/pages/admin/GroupMembers.tsx +6 -6
  224. package/src/pages/admin/Groups.tsx +2 -2
  225. package/src/pages/admin/Invites.tsx +4 -4
  226. package/src/pages/admin/Media.tsx +2 -2
  227. package/src/pages/admin/MemberDetail.tsx +7 -7
  228. package/src/pages/admin/Members.tsx +2 -2
  229. package/src/pages/admin/analytics/AnalyticsLayout.tsx +5 -1
  230. package/src/pages/admin/analytics/Content.tsx +1 -1
  231. package/src/pages/admin/analytics/Engagement.tsx +1 -1
  232. package/src/pages/admin/analytics/Groups.tsx +1 -1
  233. package/src/pages/admin/analytics/ReportSettings.tsx +1 -1
  234. package/src/pages/admin/community/CommunityAccess.tsx +1 -1
  235. package/src/pages/admin/community/CommunityFavicons.tsx +1 -1
  236. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +2 -2
  237. package/src/pages/admin/community/CommunityInfo.tsx +1 -1
  238. package/src/pages/admin/community/CommunityLinks.tsx +30 -1
  239. package/src/pages/admin/community/CommunityMarkdownPage.tsx +1 -1
  240. package/src/pages/admin/community/CommunityProfileFields.tsx +5 -5
  241. package/src/pages/admin/community/CommunityRoles.tsx +9 -9
  242. package/src/pages/admin/community/CommunityTheme.tsx +26 -23
  243. package/src/pages/admin/community/ThemeColorPreview.tsx +141 -0
  244. package/src/pages/admin/components/AdminGroupCard.tsx +2 -2
  245. package/src/pages/admin/components/EditInviteLinkModal.tsx +2 -2
  246. package/src/pages/admin/components/InviteWithEmailModal.tsx +2 -2
  247. package/src/pages/admin/components/InviteWithLinkModal.tsx +3 -3
  248. package/src/pages/admin/components/ProfileRowActions.tsx +6 -6
  249. package/src/pages/admin/components/RestoreBackupModal.tsx +2 -2
  250. package/src/pages/admin/components/RestoreTestBackupModal.tsx +1 -1
  251. package/src/pages/auth/Login.tsx +1 -1
  252. package/src/pages/auth/Register.tsx +3 -3
  253. package/src/pages/auth/RequestResetPassword.tsx +1 -1
  254. package/src/pages/conversations/Info.tsx +1 -1
  255. package/src/pages/conversations/Show.tsx +94 -33
  256. package/src/pages/events/Index.tsx +1 -1
  257. package/src/pages/feeds/Bookmarks.tsx +3 -1
  258. package/src/pages/groups/EditInfo.tsx +1 -1
  259. package/src/pages/groups/EditRoles.tsx +1 -1
  260. package/src/pages/groups/Index.tsx +1 -1
  261. package/src/pages/groups/Members.tsx +2 -2
  262. package/src/pages/groups/New.tsx +1 -1
  263. package/src/pages/groups/Show.tsx +4 -4
  264. package/src/pages/settings/AccessTokens.tsx +4 -4
  265. package/src/pages/settings/Account.tsx +1 -1
  266. package/src/pages/settings/Feed.tsx +1 -1
  267. package/src/pages/settings/Language.tsx +1 -1
  268. package/src/pages/settings/PublicProfile.tsx +3 -3
  269. package/src/pages/settings/PushEnabledDevices.tsx +3 -6
  270. package/src/pages/settings/Theme.tsx +1 -1
  271. package/src/pages/settings/Timezone.tsx +1 -1
  272. package/src/react-native.ts +1 -0
@@ -0,0 +1,122 @@
1
+ /** @vitest-environment jsdom */
2
+ import { act, createElement, useReducer, } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import { ResourceLibrary } from './ResourceLibrary.js';
6
+ import { RouterProvider } from '../../contexts/router/index.js';
7
+ vi.mock('../../i18n', () => ({
8
+ useT: () => (key, opts) => opts?.defaultValue ?? key,
9
+ }));
10
+ vi.mock('../../contexts/openpeeps', () => ({
11
+ useOpenpeeps: () => ({
12
+ openpeepsApi: {
13
+ usePostsByType: () => ({ data: { pages: [[]] }, isPending: false }),
14
+ useCurrentProfileBookmarkedIds: () => ({ data: [] }),
15
+ },
16
+ }),
17
+ }));
18
+ vi.mock('../../hooks/useResolvedFeedFormat', () => ({
19
+ useFeedListParams: () => ({ format: 'linear' }),
20
+ }));
21
+ vi.mock('./ResourceCard', () => ({
22
+ ResourceCard: () => null,
23
+ }));
24
+ /**
25
+ * RouterAdapter backed by a mutable URL, mimicking the real adapters:
26
+ * `setSearchParams` rewrites only the query, keeping pathname and hash.
27
+ */
28
+ const Harness = ({ location, children, }) => {
29
+ const [, bump] = useReducer((x) => x + 1, 0);
30
+ const url = new URL(location.url, 'http://localhost');
31
+ const adapter = {
32
+ pathname: url.pathname,
33
+ searchParams: new URLSearchParams(url.search),
34
+ setSearchParams: (next, opts) => {
35
+ const resolved = typeof next === 'function'
36
+ ? next(new URLSearchParams(url.search))
37
+ : next;
38
+ const query = resolved.toString();
39
+ location.url =
40
+ 'http://localhost' +
41
+ url.pathname +
42
+ (query ? `?${query}` : '') +
43
+ url.hash;
44
+ if (opts?.replace)
45
+ location.replaceWrites += 1;
46
+ else
47
+ location.pushWrites += 1;
48
+ bump();
49
+ },
50
+ navigate: () => { },
51
+ hrefOf: () => '#',
52
+ match: () => null,
53
+ back: () => { },
54
+ };
55
+ return createElement(RouterProvider, { adapter }, children);
56
+ };
57
+ describe('ResourceLibrary URL filters', () => {
58
+ let root;
59
+ let container;
60
+ const render = (ui) => {
61
+ const el = document.createElement('div');
62
+ document.body.appendChild(el);
63
+ container = el;
64
+ root = createRoot(el);
65
+ act(() => {
66
+ root?.render(ui);
67
+ });
68
+ return el;
69
+ };
70
+ beforeEach(() => {
71
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true;
72
+ vi.useFakeTimers();
73
+ });
74
+ afterEach(() => {
75
+ act(() => {
76
+ root?.unmount();
77
+ });
78
+ container?.remove();
79
+ root = undefined;
80
+ container = undefined;
81
+ vi.useRealTimers();
82
+ });
83
+ it('keeps the tab hash and unrelated params when a filter changes', async () => {
84
+ const location = {
85
+ url: 'http://localhost/groups/@x?category=Docs#resources',
86
+ replaceWrites: 0,
87
+ pushWrites: 0,
88
+ };
89
+ const container = render(createElement(Harness, { location }, createElement(ResourceLibrary, { groupId: 'g1' })));
90
+ const fileButton = [...container.querySelectorAll('button')].find((button) => button.textContent === 'file');
91
+ expect(fileButton).toBeTruthy();
92
+ await act(async () => {
93
+ fileButton?.click();
94
+ });
95
+ // The URL write-back is debounced.
96
+ await act(async () => {
97
+ vi.advanceTimersByTime(300);
98
+ });
99
+ // The hash (the group Resources tab) and ?category= survive the filter
100
+ // change, and the write is a replace, not a new history entry.
101
+ expect(location.url).toBe('http://localhost/groups/@x?category=Docs&kind=file#resources');
102
+ expect(location.replaceWrites).toBe(1);
103
+ expect(location.pushWrites).toBe(0);
104
+ });
105
+ it('hydrates filters from the URL on mount', async () => {
106
+ const location = {
107
+ url: 'http://localhost/groups/@x?q=notes#resources',
108
+ replaceWrites: 0,
109
+ pushWrites: 0,
110
+ };
111
+ const container = render(createElement(Harness, { location }, createElement(ResourceLibrary, { groupId: 'g1' })));
112
+ const search = container.querySelector('[data-testid="resources-search"]');
113
+ expect(search?.value).toBe('notes');
114
+ // After the write-back window the state matches the URL, so a mount is
115
+ // a no-op and must not rewrite it.
116
+ await act(async () => {
117
+ vi.advanceTimersByTime(300);
118
+ });
119
+ expect(location.url).toBe('http://localhost/groups/@x?q=notes#resources');
120
+ expect(location.replaceWrites).toBe(0);
121
+ });
122
+ });
@@ -56,6 +56,7 @@ export declare const useServerInfo: () => {
56
56
  contactEmail?: string | undefined;
57
57
  privacyPolicy?: string | undefined;
58
58
  termsAndConditions?: string | undefined;
59
+ bugReportUrl?: string | undefined;
59
60
  };
60
61
  content: {
61
62
  aboutPage?: string | undefined;
@@ -129,20 +130,28 @@ export declare const useServerInfo: () => {
129
130
  } | undefined;
130
131
  };
131
132
  export declare const useCapabilities: () => {
132
- post: Record<string, {
133
- add: string[];
134
- remove: string[];
135
- }>;
136
- profile: Record<string, {
137
- add: string[];
138
- remove: string[];
139
- }>;
140
- report: Record<string, {
141
- add: string[];
142
- remove: string[];
143
- }>;
144
- accessToken: Record<string, {
145
- add: string[];
146
- remove: string[];
147
- }>;
133
+ post: {
134
+ [x: string]: {
135
+ add: string[];
136
+ remove: string[];
137
+ };
138
+ };
139
+ profile: {
140
+ [x: string]: {
141
+ add: string[];
142
+ remove: string[];
143
+ };
144
+ };
145
+ report: {
146
+ [x: string]: {
147
+ add: string[];
148
+ remove: string[];
149
+ };
150
+ };
151
+ accessToken: {
152
+ [x: string]: {
153
+ add: string[];
154
+ remove: string[];
155
+ };
156
+ };
148
157
  };
@@ -11425,7 +11425,7 @@ declare const adminPeopleContent: (client: OpenpeepsClientInstance) => {
11425
11425
  guestData?: {
11426
11426
  email?: string | undefined;
11427
11427
  resource?: {
11428
- type: "profiles" | "notifications" | "groups" | "jams" | "posts" | "self" | "*" | "db" | "reports" | "webhooks" | "analytics" | "render";
11428
+ type: "profiles" | "notifications" | "groups" | "jams" | "posts" | "self" | "*" | "db" | "reports" | "webhooks" | "conversations" | "analytics" | "render";
11429
11429
  id?: string | undefined;
11430
11430
  } | undefined;
11431
11431
  } | undefined;
@@ -11567,7 +11567,7 @@ declare const adminDiagnostics: (client: OpenpeepsClientInstance) => {
11567
11567
  description?: string | undefined;
11568
11568
  scopes?: {
11569
11569
  resource: {
11570
- type: "profiles" | "notifications" | "groups" | "jams" | "posts" | "self" | "*" | "db" | "reports" | "webhooks" | "analytics" | "render";
11570
+ type: "profiles" | "notifications" | "groups" | "jams" | "posts" | "self" | "*" | "db" | "reports" | "webhooks" | "conversations" | "analytics" | "render";
11571
11571
  id?: string | undefined;
11572
11572
  };
11573
11573
  scopeLevel?: "read" | "admin" | "write" | undefined;
@@ -39,7 +39,7 @@ export declare const authHooks: (client: OpenpeepsClient, setCurrentProfile: (pr
39
39
  displayName: string;
40
40
  email: string;
41
41
  resource: {
42
- type: "self" | "jams" | "profiles" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "db" | "analytics" | "render" | "*";
42
+ type: "self" | "jams" | "profiles" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "conversations" | "db" | "analytics" | "render" | "*";
43
43
  id?: string | undefined;
44
44
  };
45
45
  }) => Promise<{
@@ -89,6 +89,7 @@ export declare const otherHooks: (client: OpenpeepsClient) => {
89
89
  contactEmail?: string | undefined;
90
90
  privacyPolicy?: string | undefined;
91
91
  termsAndConditions?: string | undefined;
92
+ bugReportUrl?: string | undefined;
92
93
  };
93
94
  content: {
94
95
  aboutPage?: string | undefined;
@@ -3,6 +3,14 @@ import type { Navigator, NavTarget } from '../../navigation';
3
3
  export interface RouterAdapter {
4
4
  pathname: string;
5
5
  searchParams: URLSearchParams;
6
+ /**
7
+ * Replace the query string, keeping the pathname and hash. `next` is the
8
+ * full new params or a function of the current ones; pass
9
+ * `{ replace: true }` to avoid adding a history entry.
10
+ */
11
+ setSearchParams: (next: URLSearchParams | ((prev: URLSearchParams) => URLSearchParams), opts?: {
12
+ replace?: boolean;
13
+ }) => void;
6
14
  /** Navigate to an abstract target (preferred) or a raw path string. */
7
15
  navigate: (target: NavTarget | string) => void;
8
16
  hrefOf: (target: NavTarget) => string;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext, useEffect, useMemo, useState, } from 'react';
2
+ import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from 'react';
3
3
  const RouterContext = createContext(null);
4
4
  export const useRouter = () => {
5
5
  const ctx = useContext(RouterContext);
@@ -49,9 +49,34 @@ export function useBrowserRouter(navigator) {
49
49
  window.addEventListener('popstate', update);
50
50
  return () => window.removeEventListener('popstate', update);
51
51
  }, []);
52
+ const setSearchParams = useCallback((next, opts) => {
53
+ if (typeof window === 'undefined')
54
+ return;
55
+ const prev = new URLSearchParams(window.location.search);
56
+ const resolved = typeof next === 'function' ? next(prev) : next;
57
+ const query = resolved.toString();
58
+ const url = `${window.location.pathname}${query ? `?${query}` : ''}${window.location.hash}`;
59
+ // The URL bar is the source of truth here; skip no-op writes so the
60
+ // state (and any subscribers) only change when the query actually does.
61
+ if (url ===
62
+ `${window.location.pathname}${window.location.search}${window.location.hash}`) {
63
+ return;
64
+ }
65
+ if (opts?.replace) {
66
+ window.history.replaceState(window.history.state, '', url);
67
+ }
68
+ else {
69
+ window.history.pushState(window.history.state, '', url);
70
+ }
71
+ setState({
72
+ pathname: window.location.pathname,
73
+ searchParams: new URLSearchParams(window.location.search),
74
+ });
75
+ }, []);
52
76
  return useMemo(() => ({
53
77
  pathname: state.pathname,
54
78
  searchParams: state.searchParams,
79
+ setSearchParams,
55
80
  hrefOf: navigator.hrefOf,
56
81
  match: navigator.match,
57
82
  navigate: (target) => {
@@ -69,5 +94,5 @@ export function useBrowserRouter(navigator) {
69
94
  return;
70
95
  history.back();
71
96
  },
72
- }), [state, navigator]);
97
+ }), [state, navigator, setSearchParams]);
73
98
  }
@@ -0,0 +1,15 @@
1
+ import type { MediaAttachmentData } from '@openpeepshq/common/types';
2
+ /** DM messages are note posts, so their text carries the note budget. */
3
+ export declare const DM_MESSAGE_MAX_LENGTH = 500;
4
+ /** Client-side cap on attachments per DM message (applied on both platforms). */
5
+ export declare const DM_MAX_ATTACHMENTS = 4;
6
+ /**
7
+ * Send gate for DM messages: nothing in flight, no pending uploads, within
8
+ * the text budget, and something to send (text or attachments).
9
+ */
10
+ export declare const canSendDmMessage: ({ sending, uploadsPending, text, attachments, }: {
11
+ sending: boolean;
12
+ uploadsPending: boolean;
13
+ text: string;
14
+ attachments: MediaAttachmentData[];
15
+ }) => boolean;
@@ -0,0 +1,12 @@
1
+ /** DM messages are note posts, so their text carries the note budget. */
2
+ export const DM_MESSAGE_MAX_LENGTH = 500;
3
+ /** Client-side cap on attachments per DM message (applied on both platforms). */
4
+ export const DM_MAX_ATTACHMENTS = 4;
5
+ /**
6
+ * Send gate for DM messages: nothing in flight, no pending uploads, within
7
+ * the text budget, and something to send (text or attachments).
8
+ */
9
+ export const canSendDmMessage = ({ sending, uploadsPending, text, attachments, }) => !sending &&
10
+ !uploadsPending &&
11
+ text.length <= DM_MESSAGE_MAX_LENGTH &&
12
+ (text.trim().length > 0 || attachments.length > 0);
@@ -130,6 +130,46 @@ export declare const useCreateConversation: ({ profiles: initialProfiles, messag
130
130
  }[]>>;
131
131
  message: string;
132
132
  setMessage: import("react").Dispatch<import("react").SetStateAction<string>>;
133
+ attachments: {
134
+ type: string;
135
+ url: string;
136
+ previewUrl: string | null;
137
+ textUrl: null;
138
+ filename: string;
139
+ meta: {
140
+ usage?: string | undefined;
141
+ focus?: {
142
+ x: number;
143
+ y: number;
144
+ } | undefined;
145
+ mimetype?: string | undefined;
146
+ size?: number | undefined;
147
+ };
148
+ description?: string | undefined;
149
+ blurhash?: string | undefined;
150
+ status?: "processing" | "ready" | "failed" | undefined;
151
+ error?: string | undefined;
152
+ }[];
153
+ setAttachments: import("react").Dispatch<import("react").SetStateAction<{
154
+ type: string;
155
+ url: string;
156
+ previewUrl: string | null;
157
+ textUrl: null;
158
+ filename: string;
159
+ meta: {
160
+ usage?: string | undefined;
161
+ focus?: {
162
+ x: number;
163
+ y: number;
164
+ } | undefined;
165
+ mimetype?: string | undefined;
166
+ size?: number | undefined;
167
+ };
168
+ description?: string | undefined;
169
+ blurhash?: string | undefined;
170
+ status?: "processing" | "ready" | "failed" | undefined;
171
+ error?: string | undefined;
172
+ }[]>>;
133
173
  submitting: boolean;
134
174
  error: string | null;
135
175
  send: () => Promise<void>;
@@ -13,6 +13,7 @@ export const useCreateConversation = ({ profiles: initialProfiles = [], message:
13
13
  const [step, setStep] = useState(skipProfileSelection ? 2 : 1);
14
14
  const [selectedProfiles, setSelectedProfiles] = useState(initialProfiles);
15
15
  const [message, setMessage] = useState(initialMessage);
16
+ const [attachments, setAttachments] = useState([]);
16
17
  const [submitting, setSubmitting] = useState(false);
17
18
  const [error, setError] = useState(null);
18
19
  const send = async () => {
@@ -28,9 +29,12 @@ export const useCreateConversation = ({ profiles: initialProfiles = [], message:
28
29
  data: {
29
30
  type: 'note',
30
31
  content: message.trim(),
32
+ attachments: attachments.length ? attachments : undefined,
31
33
  },
32
34
  };
33
35
  const created = (await createPost(payload));
36
+ setMessage('');
37
+ setAttachments([]);
34
38
  onClose();
35
39
  navigate({ type: 'conversation', id: created.id });
36
40
  }
@@ -49,6 +53,8 @@ export const useCreateConversation = ({ profiles: initialProfiles = [], message:
49
53
  setSelectedProfiles,
50
54
  message,
51
55
  setMessage,
56
+ attachments,
57
+ setAttachments,
52
58
  submitting,
53
59
  error,
54
60
  send,
@@ -95,6 +95,9 @@ export declare const useEventForm: (postData: PostCreationData, onChange: (data:
95
95
  repeatFreq: RepeatFreq;
96
96
  repeatEnd: RepeatEnd;
97
97
  preview: import("@openpeepshq/common").ExpandedOccurrence[];
98
+ endBeforeStart: boolean;
99
+ changeStart: (start: string | undefined) => void;
100
+ changeEnd: (end: string | undefined) => void;
98
101
  patchEvent: (patch: Partial<Event>) => void;
99
102
  setEvent: (next: Event) => void;
100
103
  setAudience: (settings: AudienceSetting) => void;
@@ -1,5 +1,5 @@
1
1
  import { useState } from 'react';
2
- import { previewUpcomingOccurrences, reinterpretIsoInTimeZone, weekdayFromDate, withoutEventMaxAttendees, } from '@openpeepshq/common/lib';
2
+ import { isEndBeforeStart, previewUpcomingOccurrences, reinterpretIsoInTimeZone, weekdayFromDate, withoutEventMaxAttendees, } from '@openpeepshq/common/lib';
3
3
  import { useCurrentProfile } from '../../components/layout/IdentityContext.js';
4
4
  import { applyAudienceSetting } from '../../lib/audienceSetting.js';
5
5
  export const EVENT_WEEKDAYS = [
@@ -17,14 +17,40 @@ export const useEventForm = (postData, onChange) => {
17
17
  const event = postData.data;
18
18
  const eventTimeZone = event.timeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
19
19
  const [showEndDate, setShowEndDate] = useState(event.end !== undefined);
20
+ // Transient until the next successful patch; the persisted range itself is
21
+ // derived from start/end, which also covers events saved before the guard.
22
+ const [rejectedTimes, setRejectedTimes] = useState(false);
20
23
  const patchEvent = (patch) => {
21
24
  let next = { ...event, ...patch };
22
25
  if ('maxAttendees' in patch && patch.maxAttendees === undefined) {
23
26
  next = withoutEventMaxAttendees(next);
24
27
  }
28
+ setRejectedTimes(false);
29
+ onChange({ ...postData, data: next });
30
+ };
31
+ const changeStart = (start) => {
32
+ if (!start)
33
+ return;
34
+ // Moving the start past the end keeps the duration by shifting the end.
35
+ if (isEndBeforeStart(start, event.end) && event.start && event.end) {
36
+ const delta = new Date(start).getTime() - new Date(event.start).getTime();
37
+ const end = new Date(new Date(event.end).getTime() + delta);
38
+ patchEvent({ start, end: end.toISOString() });
39
+ return;
40
+ }
41
+ patchEvent({ start });
42
+ };
43
+ const changeEnd = (end) => {
44
+ if (isEndBeforeStart(event.start, end)) {
45
+ setRejectedTimes(true);
46
+ return;
47
+ }
48
+ patchEvent({ end });
49
+ };
50
+ const setEvent = (next) => {
51
+ setRejectedTimes(false);
25
52
  onChange({ ...postData, data: next });
26
53
  };
27
- const setEvent = (next) => onChange({ ...postData, data: next });
28
54
  const setAudience = (settings) => onChange(applyAudienceSetting(postData, settings, me));
29
55
  const setRecurrence = (recurrence) => patchEvent({ recurrence });
30
56
  const repeatFreq = event.recurrence?.freq ?? 'none';
@@ -139,6 +165,9 @@ export const useEventForm = (postData, onChange) => {
139
165
  repeatFreq,
140
166
  repeatEnd,
141
167
  preview,
168
+ endBeforeStart: rejectedTimes || isEndBeforeStart(event.start, event.end),
169
+ changeStart,
170
+ changeEnd,
142
171
  patchEvent,
143
172
  setEvent,
144
173
  setAudience,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,107 @@
1
+ /** @vitest-environment jsdom */
2
+ import { act, createElement, useState } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import { useEventForm } from './useEventForm.js';
6
+ vi.mock('../../components/layout/IdentityContext', () => ({
7
+ useCurrentProfile: () => undefined,
8
+ }));
9
+ const START = '2026-11-06T09:00:00.000Z';
10
+ const EARLIER = '2026-11-06T08:45:00.000Z';
11
+ const LATER = '2026-11-06T10:00:00.000Z';
12
+ const eventPostData = (data) => ({
13
+ visibility: 'public',
14
+ type: 'event',
15
+ data: { type: 'event', content: '', ...data },
16
+ });
17
+ let root;
18
+ let container;
19
+ let captured;
20
+ const renderForm = (initial) => {
21
+ container = document.createElement('div');
22
+ document.body.appendChild(container);
23
+ root = createRoot(container);
24
+ const Host = () => {
25
+ const [data, setData] = useState(initial);
26
+ captured = useEventForm(data, setData);
27
+ return null;
28
+ };
29
+ act(() => {
30
+ root?.render(createElement(Host));
31
+ });
32
+ };
33
+ describe('useEventForm end-before-start guard', () => {
34
+ beforeEach(() => {
35
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true;
36
+ });
37
+ afterEach(() => {
38
+ act(() => {
39
+ root?.unmount();
40
+ });
41
+ container?.remove();
42
+ root = undefined;
43
+ container = undefined;
44
+ captured = undefined;
45
+ });
46
+ it('accepts an end after the start', () => {
47
+ renderForm(eventPostData({ start: START }));
48
+ act(() => {
49
+ captured?.changeEnd(LATER);
50
+ });
51
+ expect(captured?.event.end).toBe(LATER);
52
+ expect(captured?.endBeforeStart).toBe(false);
53
+ });
54
+ it('rejects an end at or before the start', () => {
55
+ renderForm(eventPostData({ start: START, end: LATER }));
56
+ act(() => {
57
+ captured?.changeEnd(EARLIER);
58
+ });
59
+ expect(captured?.event.end).toBe(LATER);
60
+ expect(captured?.endBeforeStart).toBe(true);
61
+ });
62
+ it('shifts the end when the start moves to at or after the end', () => {
63
+ renderForm(eventPostData({ start: EARLIER, end: LATER }));
64
+ act(() => {
65
+ captured?.changeStart(START);
66
+ });
67
+ expect(captured?.event.start).toBe(START);
68
+ expect(captured?.event.end).toBe(LATER);
69
+ expect(captured?.endBeforeStart).toBe(false);
70
+ act(() => {
71
+ captured?.changeStart('2026-11-06T10:30:00.000Z');
72
+ });
73
+ // The start moved 1h30m, so the end moves with it (duration preserved).
74
+ expect(captured?.event.start).toBe('2026-11-06T10:30:00.000Z');
75
+ expect(captured?.event.end).toBe('2026-11-06T11:30:00.000Z');
76
+ expect(captured?.endBeforeStart).toBe(false);
77
+ });
78
+ it('does not leave a stale error when the end date is toggled off and on', () => {
79
+ renderForm(eventPostData({ start: START, end: LATER }));
80
+ act(() => {
81
+ captured?.changeEnd(EARLIER);
82
+ });
83
+ expect(captured?.endBeforeStart).toBe(true);
84
+ act(() => {
85
+ captured?.toggleEndDate(false);
86
+ });
87
+ expect(captured?.event.end).toBeUndefined();
88
+ expect(captured?.endBeforeStart).toBe(false);
89
+ act(() => {
90
+ captured?.toggleEndDate(true);
91
+ });
92
+ expect(captured?.event.end).toBe('2026-11-06T10:00:00.000Z');
93
+ expect(captured?.endBeforeStart).toBe(false);
94
+ });
95
+ it('clears the error once a change makes the range valid again', () => {
96
+ renderForm(eventPostData({ start: '2026-11-06T10:30:00.000Z', end: LATER }));
97
+ expect(captured?.endBeforeStart).toBe(true);
98
+ act(() => {
99
+ captured?.changeEnd('2026-11-06T11:00:00.000Z');
100
+ });
101
+ expect(captured?.endBeforeStart).toBe(false);
102
+ });
103
+ it('seeds the error when an existing event is already invalid', () => {
104
+ renderForm(eventPostData({ start: START, end: EARLIER }));
105
+ expect(captured?.endBeforeStart).toBe(true);
106
+ });
107
+ });
@@ -2,6 +2,7 @@ export { useJoinGroup } from './groups/useJoinGroup';
2
2
  export { useGroupNotificationLevel } from './groups/useGroupNotificationLevel';
3
3
  export { useCreateConversation } from './conversations/useCreateConversation';
4
4
  export type { UseCreateConversationArgs } from './conversations/useCreateConversation';
5
+ export { canSendDmMessage, DM_MAX_ATTACHMENTS, DM_MESSAGE_MAX_LENGTH, } from './conversations/dmMessage';
5
6
  export { useCanDiagnoseLivekit } from './jams/useCanDiagnoseLivekit';
6
7
  export { useLeaveCloseJam } from './jams/useLeaveCloseJam';
7
8
  export type { UseLeaveCloseJamArgs } from './jams/useLeaveCloseJam';
@@ -24,6 +25,7 @@ export type { UseJamRtmpStreamArgs } from './jams/useJamDetails';
24
25
  export { useJamParticipantMute, useJoinWaitingRoomToken, } from './jams/useJamParticipant';
25
26
  export type { UseJamParticipantMuteArgs } from './jams/useJamParticipant';
26
27
  export { useFeedPostActions } from './posts/useFeedPostActions';
28
+ export { usePostReactionToggle } from './posts/usePostReactionToggle';
27
29
  export { feedPostPresentation, useFeedPostPresentation, } from './posts/useFeedPostPresentation';
28
30
  export type { FeedPostPresentationOptions } from './posts/useFeedPostPresentation';
29
31
  export { ReplyOpenerProvider, useReplyOpener } from './posts/replyOpener';
@@ -51,7 +53,7 @@ export { useGroupTemplateSelection } from './groups/useGroupTemplateSelection';
51
53
  export type { UseGroupTemplateSelectionArgs } from './groups/useGroupTemplateSelection';
52
54
  export { useNewArticle, useEditArticle } from './posts/useArticleComposer';
53
55
  export { useNewResource, useEditResource } from './posts/useResourceComposer';
54
- export { useResourceLibrary } from './resources/useResourceLibrary';
56
+ export { useResourceLibrary, type ResourceLibraryInitialFilters, } from './resources/useResourceLibrary';
55
57
  export { useEventsCalendar, eventName as calendarEventName, dayNumber as calendarDayNumber, } from './events/useEventsCalendar';
56
58
  export type { EventsCalendarQuery } from './events/useEventsCalendar';
57
59
  export * from '../components/post/feed/events/eventCalendar';
@@ -1,6 +1,7 @@
1
1
  export { useJoinGroup } from './groups/useJoinGroup.js';
2
2
  export { useGroupNotificationLevel } from './groups/useGroupNotificationLevel.js';
3
3
  export { useCreateConversation } from './conversations/useCreateConversation.js';
4
+ export { canSendDmMessage, DM_MAX_ATTACHMENTS, DM_MESSAGE_MAX_LENGTH, } from './conversations/dmMessage.js';
4
5
  export { useCanDiagnoseLivekit } from './jams/useCanDiagnoseLivekit.js';
5
6
  export { useLeaveCloseJam } from './jams/useLeaveCloseJam.js';
6
7
  export { useCreateNewJamForm } from './jams/useCreateNewJamForm.js';
@@ -13,6 +14,7 @@ export { useJamStage } from './jams/useJamStage.js';
13
14
  export { useJamDetails, useJamRtmpStream } from './jams/useJamDetails.js';
14
15
  export { useJamParticipantMute, useJoinWaitingRoomToken, } from './jams/useJamParticipant.js';
15
16
  export { useFeedPostActions } from './posts/useFeedPostActions.js';
17
+ export { usePostReactionToggle } from './posts/usePostReactionToggle.js';
16
18
  export { feedPostPresentation, useFeedPostPresentation, } from './posts/useFeedPostPresentation.js';
17
19
  export { ReplyOpenerProvider, useReplyOpener } from './posts/replyOpener.js';
18
20
  export { useEventRsvp } from './events/useEventRsvp.js';
@@ -31,7 +33,7 @@ export { useNewGroup } from './groups/useNewGroup.js';
31
33
  export { useGroupTemplateSelection } from './groups/useGroupTemplateSelection.js';
32
34
  export { useNewArticle, useEditArticle } from './posts/useArticleComposer.js';
33
35
  export { useNewResource, useEditResource } from './posts/useResourceComposer.js';
34
- export { useResourceLibrary } from './resources/useResourceLibrary.js';
36
+ export { useResourceLibrary, } from './resources/useResourceLibrary.js';
35
37
  export { useEventsCalendar, eventName as calendarEventName, dayNumber as calendarDayNumber, } from './events/useEventsCalendar.js';
36
38
  export * from '../components/post/feed/events/eventCalendar.js';
37
39
  export { useCommunityInfoPages } from './community/useCommunityInfoPages.js';