@openpeepshq/react 0.11.0 → 0.12.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 (36) hide show
  1. package/dist/components/jams/JamLobby.js +16 -8
  2. package/dist/components/post/post-form/ComposeAttachments.d.ts +1 -3
  3. package/dist/components/post/post-form/ComposeAttachments.js +7 -19
  4. package/dist/components/post/post-form/ComposeAttachments.test.js +13 -22
  5. package/dist/components/post/post-form/EventForm.js +2 -2
  6. package/dist/components/post/post-form/ResourceForm.js +0 -2
  7. package/dist/components/resources/CategoryPathPicker.js +2 -1
  8. package/dist/components/resources/ResourceLibrary.js +5 -5
  9. package/dist/components/resources/ResourceLibrary.test.js +83 -1
  10. package/dist/components/server-data/context.d.ts +2 -0
  11. package/dist/contexts/openpeeps/hooks/other.d.ts +2 -0
  12. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -0
  13. package/dist/hooks/settings/useNotificationPreferences.js +7 -2
  14. package/dist/pages/admin/ApiKeys.js +14 -6
  15. package/dist/pages/admin/ConfigurationEmail.js +2 -2
  16. package/dist/pages/admin/ConfigurationSso.js +1 -1
  17. package/dist/pages/admin/community/CommunityTheme.js +1 -1
  18. package/dist/pages/admin/community/useCommunityConfig.d.ts +4 -0
  19. package/dist/pages/auth/RequestResetPassword.js +1 -1
  20. package/dist/pages/settings/NotificationPreferences.js +7 -3
  21. package/dist/pages/settings/NotificationPreferences.test.d.ts +1 -0
  22. package/dist/pages/settings/NotificationPreferences.test.js +119 -0
  23. package/package.json +3 -3
  24. package/src/components/jams/JamLobby.tsx +123 -102
  25. package/src/components/post/post-form/ComposeAttachments.tsx +4 -20
  26. package/src/components/post/post-form/EventForm.tsx +2 -2
  27. package/src/components/post/post-form/ResourceForm.tsx +2 -3
  28. package/src/components/resources/CategoryPathPicker.tsx +2 -1
  29. package/src/components/resources/ResourceLibrary.tsx +5 -5
  30. package/src/hooks/settings/useNotificationPreferences.ts +12 -1
  31. package/src/pages/admin/ApiKeys.tsx +20 -9
  32. package/src/pages/admin/ConfigurationEmail.tsx +2 -2
  33. package/src/pages/admin/ConfigurationSso.tsx +2 -1
  34. package/src/pages/admin/community/CommunityTheme.tsx +29 -0
  35. package/src/pages/auth/RequestResetPassword.tsx +1 -1
  36. package/src/pages/settings/NotificationPreferences.tsx +38 -12
@@ -103,7 +103,7 @@ export function NotificationPreferences() {
103
103
  const { client } = useOpenpeeps();
104
104
  const serverInfo = useServerInfo();
105
105
  const vapidKey = serverInfo.vapid.publicKey;
106
- const { me, types, settings, setTypeSettings, save, saving, status, clearStatus, } = useNotificationPreferences({
106
+ const { me, types, settings, setTypeSettings, save, saving, status, clearStatus, dirty, } = useNotificationPreferences({
107
107
  ensurePush: vapidKey
108
108
  ? async () => {
109
109
  await subscribePushNotifications({
@@ -122,7 +122,11 @@ export function NotificationPreferences() {
122
122
  defaultValue: 'Push settings',
123
123
  }) }), _jsx(PushSettingsPanel, {}), _jsx("h2", { className: "mb-2 text-lg font-medium", children: t('settings.notifications.description', {
124
124
  defaultValue: 'Choose how you want to be notified about activity.',
125
- }) }), types.map((nt) => (_jsx(NotificationSettingRow, { notificationType: nt, settings: settings.notifications?.[nt.type], onChange: (next) => setTypeSettings(nt.type, next) }, nt.type))), status ? (_jsx(Toast, { variant: status.type, onDismiss: clearStatus, children: status.message })) : null, _jsx("div", { className: "pt-3", children: _jsx(Button, { variant: "default", className: "w-full", action: save, disabled: saving, "data-testid": "settings-save-button", children: saving
125
+ }) }), types.map((nt) => (_jsx(NotificationSettingRow, { notificationType: nt, settings: settings.notifications?.[nt.type], onChange: (next) => setTypeSettings(nt.type, next) }, nt.type))), status ? (_jsx(Toast, { variant: status.type, onDismiss: clearStatus, children: status.message })) : null, dirty ? (_jsxs("div", { "data-testid": "settings-unsaved-bar", className: "border-border bg-surface sticky bottom-0 z-10 mt-4 flex items-center justify-between gap-4 rounded-t-lg border-t p-3 shadow-lg", children: [_jsx("p", { className: "text-sm font-medium", children: t('settings.notifications.unsavedChanges', {
126
+ defaultValue: 'You have unsaved changes.',
127
+ }) }), _jsx(Button, { variant: "default", action: save, disabled: saving, "data-testid": "settings-save-button", children: saving
128
+ ? t('common.submitting', { defaultValue: 'Submitting…' })
129
+ : t('common.submit', { defaultValue: 'Submit' }) })] })) : (_jsx("div", { className: "pt-3", children: _jsx(Button, { variant: "default", className: "w-full", action: save, disabled: saving, "data-testid": "settings-save-button", children: saving
126
130
  ? t('common.submitting', { defaultValue: 'Submitting…' })
127
- : t('common.submit', { defaultValue: 'Submit' }) }) })] }));
131
+ : t('common.submit', { defaultValue: 'Submit' }) }) }))] }));
128
132
  }
@@ -0,0 +1,119 @@
1
+ /** @vitest-environment jsdom */
2
+ import { act, createElement } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
+ const { hookState } = vi.hoisted(() => ({
6
+ hookState: {
7
+ dirty: false,
8
+ saving: false,
9
+ save: () => { },
10
+ },
11
+ }));
12
+ vi.mock('../../index', () => ({
13
+ useT: () => (key, opts) => {
14
+ const translations = {
15
+ 'common.submit': 'Submit',
16
+ 'common.submitting': 'Submitting…',
17
+ 'settings.notifications.unsavedChanges': 'You have unsaved changes.',
18
+ 'settings.notifications.description': 'Choose how you want to be notified about activity.',
19
+ 'settings.notifications.pushSettings': 'Push settings',
20
+ 'settings.notifications.serverPushDisabled': 'Push notifications are not configured on this server.',
21
+ };
22
+ return (translations[key] ?? key).replace(/\{\{(\w+)\}\}/g, (_match, name) => opts?.[name] ?? '');
23
+ },
24
+ useOpenpeeps: () => ({
25
+ client: {},
26
+ openpeepsApi: { testPushSubscriptionAction: () => vi.fn(async () => { }) },
27
+ }),
28
+ useSetPageHeader: () => undefined,
29
+ usePushSubscription: () => ({
30
+ isSubscribed: false,
31
+ isLoading: false,
32
+ hasServiceWorker: false,
33
+ isSupported: false,
34
+ subscribe: vi.fn(async () => null),
35
+ unsubscribe: vi.fn(async () => { }),
36
+ }),
37
+ getPushSubscription: vi.fn(),
38
+ isBraveBrowser: () => false,
39
+ subscribePushNotifications: vi.fn(async () => { }),
40
+ }));
41
+ vi.mock('../../components', () => ({
42
+ useServerInfo: () => ({ vapid: { publicKey: undefined } }),
43
+ }));
44
+ vi.mock('../../hooks', () => ({
45
+ useNotificationPreferences: () => ({
46
+ me: { id: 'me' },
47
+ types: [],
48
+ settings: { notifications: {} },
49
+ dirty: hookState.dirty,
50
+ saving: hookState.saving,
51
+ save: () => hookState.save(),
52
+ status: null,
53
+ setTypeSettings: () => { },
54
+ clearStatus: () => { },
55
+ }),
56
+ }));
57
+ vi.mock('@openpeepshq/react-ui', () => ({
58
+ Button: (props) => createElement('button', {
59
+ 'data-testid': props['data-testid'],
60
+ disabled: props.disabled,
61
+ onClick: typeof props.action === 'function'
62
+ ? () => {
63
+ props.action();
64
+ }
65
+ : undefined,
66
+ }, props.children),
67
+ Toast: (props) => createElement('div', null, props.children),
68
+ }));
69
+ import { NotificationPreferences } from './NotificationPreferences.js';
70
+ describe('NotificationPreferences', () => {
71
+ let root;
72
+ let container;
73
+ beforeEach(() => {
74
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true;
75
+ hookState.dirty = false;
76
+ hookState.saving = false;
77
+ hookState.save = vi.fn();
78
+ container = document.createElement('div');
79
+ document.body.appendChild(container);
80
+ root = createRoot(container);
81
+ });
82
+ afterEach(() => {
83
+ act(() => {
84
+ root?.unmount();
85
+ });
86
+ container?.remove();
87
+ root = undefined;
88
+ container = undefined;
89
+ });
90
+ const render = (element) => {
91
+ act(() => {
92
+ root?.render(element);
93
+ });
94
+ };
95
+ it('shows only the inline save button while there are no unsaved changes', () => {
96
+ render(createElement(NotificationPreferences));
97
+ expect(container?.querySelector('[data-testid=settings-unsaved-bar]')).toBeNull();
98
+ expect(container?.querySelectorAll('[data-testid=settings-save-button]')).toHaveLength(1);
99
+ });
100
+ it('shows the sticky unsaved bar with the single save button when dirty', () => {
101
+ hookState.dirty = true;
102
+ render(createElement(NotificationPreferences));
103
+ const bar = container?.querySelector('[data-testid=settings-unsaved-bar]');
104
+ expect(bar).not.toBeNull();
105
+ expect(bar?.textContent).toContain('You have unsaved changes.');
106
+ const buttons = container?.querySelectorAll('[data-testid=settings-save-button]');
107
+ expect(buttons).toHaveLength(1);
108
+ expect(bar?.querySelector('[data-testid=settings-save-button]')).not.toBeNull();
109
+ });
110
+ it('saves via the bar button when dirty', () => {
111
+ hookState.dirty = true;
112
+ render(createElement(NotificationPreferences));
113
+ const button = container?.querySelector('[data-testid=settings-unsaved-bar] [data-testid=settings-save-button]');
114
+ act(() => {
115
+ button.click();
116
+ });
117
+ expect(hookState.save).toHaveBeenCalledTimes(1);
118
+ });
119
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/react",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -38,7 +38,7 @@
38
38
  "emoji-picker-element": "^1.29.1",
39
39
  "heic2any": "^0.0.4",
40
40
  "i18next": "^24.2.3",
41
- "i18next-http-backend": "^3.0.6",
41
+ "i18next-http-backend": "^4.0.10",
42
42
  "js-base64": "^3.7.7",
43
43
  "livekit-client": "2.19.2",
44
44
  "lucide-react": "^0.469.0",
@@ -51,8 +51,8 @@
51
51
  "react-i18next": "^15.4.1",
52
52
  "simple-icons": "^16.31.0",
53
53
  "uuidv7": "^1.0.2",
54
- "@openpeepshq/common": "^0.6.1",
55
54
  "@openpeepshq/client": "^0.3.0",
55
+ "@openpeepshq/common": "^0.6.3",
56
56
  "@openpeepshq/greenscreen": "^0.2.1",
57
57
  "@openpeepshq/react-ui": "^0.5.1"
58
58
  },
@@ -15,10 +15,13 @@ import {
15
15
  } from '@livekit/components-react';
16
16
  import { type LocalVideoTrack, Track } from 'livekit-client';
17
17
  import { Blur, Button } from '@openpeepshq/react-ui';
18
+ import { getTheme } from '@openpeepshq/common';
18
19
  import { useNavigate } from '../../contexts/router';
19
20
  import { useT } from '../../i18n';
20
21
  import { useJamLobby } from '../../hooks/jams/useJamLobby';
21
22
  import type { JamJoinParams } from '../../hooks/jams/useJamRoom';
23
+ import { useCurrentProfileSettings } from '../layout/IdentityContext';
24
+ import { useServerInfo } from '../server-data/context';
22
25
  import { audioOutputSupported } from './constants';
23
26
  import { DeviceSelectorPill } from './JamDeviceSelectors';
24
27
  import { JamGuestForm } from './JamGuestForm';
@@ -53,6 +56,13 @@ export function JamLobby({ onJoin }: JamLobbyProps) {
53
56
 
54
57
  const [settings, updateSettings] = useJamLocalSettings();
55
58
 
59
+ const serverInfo = useServerInfo();
60
+ const profileSettings = useCurrentProfileSettings();
61
+ const lobbyBackground = getTheme(
62
+ serverInfo.communityConfig,
63
+ profileSettings,
64
+ ).jamLobbyBackground;
65
+
56
66
  const [audioEnabled, setAudioEnabled] = useState(true);
57
67
  const [videoEnabled, setVideoEnabled] = useState(false);
58
68
  const [audioDeviceId, setAudioDeviceId] = useState('');
@@ -139,114 +149,125 @@ export function JamLobby({ onJoin }: JamLobbyProps) {
139
149
  });
140
150
 
141
151
  return (
142
- <div className="mx-auto flex h-full w-full max-w-lg items-center justify-center p-4">
143
- <div className="bg-background w-full rounded-md border p-4">
144
- <div className="flex items-center justify-between border-b p-2">
145
- <h2 className="text-lg">
146
- {t('jams.lobby.readyTitle', { defaultValue: 'Ready to join' })}
147
- </h2>
148
- <button
149
- type="button"
150
- title={t('jams.exit.title', { defaultValue: 'Leave' })}
151
- className="bg-surface-2 flex size-8 items-center justify-center rounded-full"
152
- onClick={exitLobby}
153
- >
154
- <X className="size-4" />
155
- </button>
156
- </div>
157
-
158
- <div className="flex flex-col items-center p-5">
159
- <h2 className="my-1 text-center text-lg">
160
- {jamEvent.name ||
161
- t('jams.lobby.fallbackTitle', { defaultValue: 'Jam' })}
162
- </h2>
163
-
164
- <div className="relative size-64">
165
- <video
166
- ref={videoRef}
167
- autoPlay
168
- playsInline
169
- muted
170
- className={`size-64 rounded-xl object-cover ${showVideo ? '' : 'hidden'}`}
171
- />
172
- {!showVideo ? (
173
- <div className="bg-surface flex size-64 items-center justify-center rounded-xl">
174
- <p className="text-lg">
175
- {t('jams.lobby.cameraOff', { defaultValue: 'Camera is off' })}
176
- </p>
177
- </div>
178
- ) : null}
152
+ <div className="relative h-full w-full">
153
+ {lobbyBackground ? (
154
+ <img
155
+ src={lobbyBackground}
156
+ alt=""
157
+ className="absolute inset-0 h-full w-full object-cover"
158
+ />
159
+ ) : null}
160
+ <div className="relative mx-auto flex h-full w-full max-w-lg items-center justify-center p-4">
161
+ <div className="bg-background w-full rounded-md border p-4">
162
+ <div className="flex items-center justify-between border-b p-2">
163
+ <h2 className="text-lg">
164
+ {t('jams.lobby.readyTitle', { defaultValue: 'Ready to join' })}
165
+ </h2>
166
+ <button
167
+ type="button"
168
+ title={t('jams.exit.title', { defaultValue: 'Leave' })}
169
+ className="bg-surface-2 flex size-8 items-center justify-center rounded-full"
170
+ onClick={exitLobby}
171
+ >
172
+ <X className="size-4" />
173
+ </button>
179
174
  </div>
180
175
 
181
- <div className="mt-4 flex w-full items-center justify-center gap-x-4">
182
- <DeviceSelectorPill
183
- enabled={audioEnabled}
184
- onToggle={() => setAudioEnabled((on) => !on)}
185
- onIcon={Mic}
186
- offIcon={MicOff}
187
- deviceType="mic"
188
- devices={audioDevices}
189
- activeDeviceId={audioDeviceId}
190
- onDeviceChange={setAudioDeviceId}
191
- />
192
- {audioOutputSupported ? (
176
+ <div className="flex flex-col items-center p-5">
177
+ <h2 className="my-1 text-center text-lg">
178
+ {jamEvent.name ||
179
+ t('jams.lobby.fallbackTitle', { defaultValue: 'Jam' })}
180
+ </h2>
181
+
182
+ <div className="relative size-64">
183
+ <video
184
+ ref={videoRef}
185
+ autoPlay
186
+ playsInline
187
+ muted
188
+ className={`size-64 rounded-xl object-cover ${showVideo ? '' : 'hidden'}`}
189
+ />
190
+ {!showVideo ? (
191
+ <div className="bg-surface flex size-64 items-center justify-center rounded-xl">
192
+ <p className="text-lg">
193
+ {t('jams.lobby.cameraOff', {
194
+ defaultValue: 'Camera is off',
195
+ })}
196
+ </p>
197
+ </div>
198
+ ) : null}
199
+ </div>
200
+
201
+ <div className="mt-4 flex w-full items-center justify-center gap-x-4">
193
202
  <DeviceSelectorPill
194
- enabled={settings.speakerEnabled}
195
- onToggle={() =>
196
- updateSettings({ speakerEnabled: !settings.speakerEnabled })
197
- }
198
- onIcon={Volume2}
199
- offIcon={VolumeX}
200
- deviceType="speaker"
201
- devices={speakerDevices}
202
- activeDeviceId={settings.speakerDeviceId}
203
- onDeviceChange={(speakerDeviceId) =>
204
- updateSettings({ speakerDeviceId })
205
- }
203
+ enabled={audioEnabled}
204
+ onToggle={() => setAudioEnabled((on) => !on)}
205
+ onIcon={Mic}
206
+ offIcon={MicOff}
207
+ deviceType="mic"
208
+ devices={audioDevices}
209
+ activeDeviceId={audioDeviceId}
210
+ onDeviceChange={setAudioDeviceId}
206
211
  />
207
- ) : null}
208
- <DeviceSelectorPill
209
- enabled={videoEnabled}
210
- onToggle={() => setVideoEnabled((on) => !on)}
211
- onIcon={Video}
212
- offIcon={VideoOff}
213
- deviceType="camera"
214
- devices={videoDevices}
215
- activeDeviceId={videoDeviceId}
216
- onDeviceChange={setVideoDeviceId}
217
- />
218
- <JamToolbarButton
219
- title={
220
- settings.blur
221
- ? t('jams.blur.turnOff', { defaultValue: 'Turn off blur' })
222
- : t('jams.blur.blurBackground', {
223
- defaultValue: 'Blur background',
224
- })
225
- }
226
- tone={settings.blur ? 'active' : 'default'}
227
- action={() => updateSettings({ blur: !settings.blur })}
228
- >
229
- <Blur />
230
- </JamToolbarButton>
212
+ {audioOutputSupported ? (
213
+ <DeviceSelectorPill
214
+ enabled={settings.speakerEnabled}
215
+ onToggle={() =>
216
+ updateSettings({ speakerEnabled: !settings.speakerEnabled })
217
+ }
218
+ onIcon={Volume2}
219
+ offIcon={VolumeX}
220
+ deviceType="speaker"
221
+ devices={speakerDevices}
222
+ activeDeviceId={settings.speakerDeviceId}
223
+ onDeviceChange={(speakerDeviceId) =>
224
+ updateSettings({ speakerDeviceId })
225
+ }
226
+ />
227
+ ) : null}
228
+ <DeviceSelectorPill
229
+ enabled={videoEnabled}
230
+ onToggle={() => setVideoEnabled((on) => !on)}
231
+ onIcon={Video}
232
+ offIcon={VideoOff}
233
+ deviceType="camera"
234
+ devices={videoDevices}
235
+ activeDeviceId={videoDeviceId}
236
+ onDeviceChange={setVideoDeviceId}
237
+ />
238
+ <JamToolbarButton
239
+ title={
240
+ settings.blur
241
+ ? t('jams.blur.turnOff', { defaultValue: 'Turn off blur' })
242
+ : t('jams.blur.blurBackground', {
243
+ defaultValue: 'Blur background',
244
+ })
245
+ }
246
+ tone={settings.blur ? 'active' : 'default'}
247
+ action={() => updateSettings({ blur: !settings.blur })}
248
+ >
249
+ <Blur />
250
+ </JamToolbarButton>
251
+ </div>
231
252
  </div>
232
- </div>
233
253
 
234
- <div className="flex w-full flex-col items-center px-5 pb-4">
235
- <Button
236
- variant="default"
237
- title={t('jams.join.submit', { defaultValue: 'Join Jam' })}
238
- loading={submitting}
239
- action={handleJoin}
240
- >
241
- {jamActive
242
- ? t('jams.join.ctaJoin', { defaultValue: 'Join' })
243
- : t('jams.join.ctaStart', { defaultValue: 'Start' })}
244
- </Button>
245
- {error ? (
246
- <div role="alert" className="text-destructive mt-3 text-sm">
247
- {error}
248
- </div>
249
- ) : null}
254
+ <div className="flex w-full flex-col items-center px-5 pb-4">
255
+ <Button
256
+ variant="default"
257
+ title={t('jams.join.submit', { defaultValue: 'Join Jam' })}
258
+ loading={submitting}
259
+ action={handleJoin}
260
+ >
261
+ {jamActive
262
+ ? t('jams.join.ctaJoin', { defaultValue: 'Join' })
263
+ : t('jams.join.ctaStart', { defaultValue: 'Start' })}
264
+ </Button>
265
+ {error ? (
266
+ <div role="alert" className="text-destructive mt-3 text-sm">
267
+ {error}
268
+ </div>
269
+ ) : null}
270
+ </div>
250
271
  </div>
251
272
  </div>
252
273
  </div>
@@ -10,8 +10,6 @@ import { isBlobUrl, revokeBlobUrl } from '../attachmentPreview';
10
10
  export interface ComposeAttachmentsProps {
11
11
  attachments: MediaAttachmentData[];
12
12
  onChange: (attachments: MediaAttachmentData[]) => void;
13
- /** Image picker may select several files at once (resource galleries). */
14
- multipleImages?: boolean;
15
13
  /** Audio picker may select several files at once (default: yes). */
16
14
  multipleAudio?: boolean;
17
15
  }
@@ -65,7 +63,6 @@ export interface ComposeAttachmentsApi {
65
63
  export function useComposeAttachments({
66
64
  attachments,
67
65
  onChange,
68
- multipleImages = false,
69
66
  multipleAudio = true,
70
67
  }: ComposeAttachmentsProps): ComposeAttachmentsApi {
71
68
  const imageInputRef = useRef<HTMLInputElement>(null);
@@ -138,20 +135,6 @@ export function useComposeAttachments({
138
135
  enqueueFile(processed);
139
136
  };
140
137
 
141
- // A single pick keeps the crop/alt-text flow; a bulk pick is enqueued
142
- // directly, since per-file cropping isn't practical for a gallery batch.
143
- const handleImageFilesSelected = async (files: File[]) => {
144
- const first = files[0];
145
- if (!first) return;
146
- if (files.length === 1) {
147
- await handleImageSelected(first);
148
- return;
149
- }
150
- for (const file of files) {
151
- enqueueFile(await convertToWebpIfHeic(file));
152
- }
153
- };
154
-
155
138
  const onUploaded = (key: string, attachment: MediaAttachment) =>
156
139
  setItems((prev) =>
157
140
  prev.map((i) => {
@@ -226,11 +209,12 @@ export function useComposeAttachments({
226
209
  ref={imageInputRef}
227
210
  type="file"
228
211
  accept="image/*,video/*,.mkv"
229
- multiple={multipleImages}
230
212
  className="hidden"
231
213
  onChange={(e) => {
232
- const files = e.target.files;
233
- if (files?.length) void handleImageFilesSelected(Array.from(files));
214
+ // Single pick only, so the crop/alt-text dialog can be shown for
215
+ // every image (see #1789).
216
+ const file = e.target.files?.[0];
217
+ if (file) void handleImageSelected(file);
234
218
  e.target.value = '';
235
219
  }}
236
220
  />
@@ -139,7 +139,7 @@ export const EventForm = ({
139
139
  </h2>
140
140
 
141
141
  <Label
142
- title={t('events.form.startDate', { defaultValue: 'Start Date' })}
142
+ title={t('events.startDate', { defaultValue: 'Start Date' })}
143
143
  htmlFor="event-start"
144
144
  >
145
145
  <Input
@@ -168,7 +168,7 @@ export const EventForm = ({
168
168
  {showEndDate ? (
169
169
  <>
170
170
  <Label
171
- title={t('events.form.endDate', { defaultValue: 'End Date' })}
171
+ title={t('events.endDate', { defaultValue: 'End Date' })}
172
172
  htmlFor="event-end"
173
173
  >
174
174
  <Input
@@ -48,8 +48,6 @@ export const ResourceForm = ({
48
48
  const attachments = useComposeAttachments({
49
49
  attachments: resource.attachments ?? [],
50
50
  onChange: (next) => patchResource({ attachments: next }),
51
- // Only galleries take more than one file; other kinds pick one at a time.
52
- multipleImages: resource.resourceKind === 'gallery',
53
51
  multipleAudio: false,
54
52
  });
55
53
 
@@ -224,7 +222,8 @@ export const ResourceForm = ({
224
222
  </Label>
225
223
  ) : (
226
224
  <div className="space-y-2">
227
- {/* Only galleries take more than one file; other kinds pick once. */}
225
+ {/* Every image pick is single-file so the crop/alt-text dialog
226
+ shows for every image; galleries stay open for further picks (#1789). */}
228
227
  {resource.resourceKind === 'gallery' ||
229
228
  (resource.attachments ?? []).length === 0 ? (
230
229
  <Button
@@ -1,6 +1,7 @@
1
1
  import { useState } from 'react';
2
2
  import type { CategoryNode } from '@openpeepshq/common/lib';
3
3
  import { Button, Input } from '@openpeepshq/react-ui';
4
+ import { categoryPathKey } from '@openpeepshq/common/lib';
4
5
  import { useT } from '../../i18n';
5
6
 
6
7
  export interface CategoryPathPickerProps {
@@ -24,7 +25,7 @@ const NodeList = ({
24
25
  selected.length === node.path.length &&
25
26
  node.path.every((segment, index) => selected[index] === segment);
26
27
  return (
27
- <li key={node.path.join('/')} className="py-0.5">
28
+ <li key={categoryPathKey(node.path)} className="py-0.5">
28
29
  <button
29
30
  type="button"
30
31
  className={`text-sm ${active ? 'text-foreground font-semibold' : 'text-muted-foreground hover:text-foreground'}`}
@@ -6,7 +6,7 @@ import {
6
6
  ChevronRight,
7
7
  } from 'lucide-react';
8
8
  import type { ResourceKind } from '@openpeepshq/common/types';
9
- import { RESOURCE_KINDS } from '@openpeepshq/common/lib';
9
+ import { RESOURCE_KINDS, categoryPathKey } from '@openpeepshq/common/lib';
10
10
  import { Button, Input, LoadingSpinner } from '@openpeepshq/react-ui';
11
11
  import { useEffect, useMemo, useRef, useState } from 'react';
12
12
  import { useT } from '../../i18n';
@@ -48,10 +48,10 @@ const Tree = ({
48
48
  }) => (
49
49
  <ul className="space-y-1">
50
50
  {nodes.map((node) => {
51
- const nodeKey = node.path.join('/');
51
+ const nodeKey = categoryPathKey(node.path);
52
52
  const nodeCount = counts.get(nodeKey) ?? 0;
53
53
  const isExpanded = expanded.has(nodeKey);
54
- const isSelected = selected.join('/') === nodeKey;
54
+ const isSelected = categoryPathKey(selected) === nodeKey;
55
55
  const hasChildren = node.children.length > 0;
56
56
  return (
57
57
  <li key={nodeKey}>
@@ -179,11 +179,11 @@ export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
179
179
  if (!path?.length) continue;
180
180
  rootCount++;
181
181
  for (let i = 1; i <= path.length; i++) {
182
- const key = path.slice(0, i).join('/');
182
+ const key = categoryPathKey(path.slice(0, i));
183
183
  counts.set(key, (counts.get(key) ?? 0) + 1);
184
184
  }
185
185
  }
186
- counts.set('', rootCount);
186
+ counts.set(categoryPathKey([]), rootCount);
187
187
  return counts;
188
188
  }, [library.posts]);
189
189
 
@@ -1,5 +1,6 @@
1
- import { useEffect, useState } from 'react';
1
+ import { useEffect, useMemo, useState } from 'react';
2
2
  import {
3
+ deepEqual,
3
4
  deepSet,
4
5
  type ProfileNotificationSettings,
5
6
  type ProfileSettings,
@@ -40,6 +41,15 @@ export const useNotificationPreferences = ({
40
41
  if (settingsQuery.data) setSettings(settingsQuery.data);
41
42
  }, [settingsQuery.data]);
42
43
 
44
+ // Unsaved local edits. Clears once the post-save refetch lands the
45
+ // server copy; stays set when a save fails.
46
+ const dirty = useMemo(
47
+ () =>
48
+ !!settingsQuery.data &&
49
+ !deepEqual(settings.notifications, settingsQuery.data.notifications),
50
+ [settings, settingsQuery.data],
51
+ );
52
+
43
53
  const setTypeSettings = (type: string, next: ProfileNotificationSettings) => {
44
54
  setSettings((current) => {
45
55
  const copy = { ...current };
@@ -93,6 +103,7 @@ export const useNotificationPreferences = ({
93
103
  me,
94
104
  types: notificationTypesQuery.data ?? [],
95
105
  settings,
106
+ dirty,
96
107
  setTypeSettings,
97
108
  save,
98
109
  saving,