Skip to content

Commit c6cfdf1

Browse files
os-zhuangclaude
andauthored
feat(react)!: trim dead device/preference delegates from useClientNotifications (objectstack#3612 companion) (#2862)
registerDevice / getPreferences / updatePreferences delegated to @objectstack/client methods deleted in objectstack#3612 — the /notifications/devices and /notifications/preferences server routes they targeted were never built, so every call already errored at runtime. The hook keeps fetchNotifications and markAsRead (dispatcher-served and route-ledgered). No in-repo consumer destructured the removed functions. Claude-Session: https://claude.ai/code/session_01LX9ut3MK3KykE11S9bJmv5 Co-authored-by: Claude <noreply@anthropic.com>
1 parent dfd3705 commit c6cfdf1

2 files changed

Lines changed: 21 additions & 65 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@object-ui/react": minor
3+
---
4+
5+
feat(react)!: trim the dead device/preference delegates from
6+
`useClientNotifications` (objectstack#3612 companion)
7+
8+
`registerDevice`, `getPreferences`, and `updatePreferences` delegated to
9+
`@objectstack/client` methods that were deleted in objectstack#3612 — the
10+
`/notifications/devices` and `/notifications/preferences` server routes they
11+
targeted were never built, so every call already surfaced an error at
12+
runtime. The hook keeps `fetchNotifications` and `markAsRead` (both
13+
dispatcher-served and route-ledgered). Breaking only for code destructuring
14+
the removed functions from the hook result; nothing in this repo did.

packages/react/src/hooks/useClientNotifications.ts

Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
* `sys_inbox_message` materialization and the `sys_notification_receipt`
1919
* read-state spine (the re-modeled `sys_notification` L2 event carries no
2020
* recipient/read columns). This hook only needs to call the SDK with its
21-
* current signatures: `list(options)`, `markRead(ids[])`, `markAllRead()`,
22-
* and `registerDevice(request)`.
21+
* current signatures: `list(options)`, `markRead(ids[])`, `markAllRead()`.
22+
*
23+
* The former registerDevice/getPreferences/updatePreferences delegates were
24+
* removed (objectstack#3612): the SDK deleted those methods because the
25+
* /notifications/devices and /notifications/preferences server routes were
26+
* never built — every call was a guaranteed error. They return when the
27+
* server side exists.
2328
*/
2429

2530
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
@@ -43,12 +48,6 @@ export interface UseClientNotificationsOptions {
4348
export interface UseClientNotificationsResult {
4449
/** Fetch notifications from server */
4550
fetchNotifications: () => Promise<void>;
46-
/** Register device for push notifications */
47-
registerDevice: (token: string, platform: string) => Promise<void>;
48-
/** Get notification preferences */
49-
getPreferences: () => Promise<any>;
50-
/** Update notification preferences */
51-
updatePreferences: (prefs: any) => Promise<void>;
5251
/** Mark a notification as read on the server */
5352
markAsRead: (id: string) => Promise<void>;
5453
/** Loading state */
@@ -159,60 +158,6 @@ export function useClientNotifications(
159158
}
160159
}, [client, notify]);
161160

162-
/* ---- registerDevice ---- */
163-
164-
const registerDevice = useCallback(
165-
async (token: string, platform: string) => {
166-
if (!client?.notifications) return;
167-
setError(null);
168-
try {
169-
// ADR-0030 / @objectstack/client v7+: registerDevice takes a single
170-
// RegisterDeviceRequest object (`{ token, platform }`), not positional
171-
// args. `platform` is the device platform enum.
172-
await client.notifications.registerDevice({
173-
token,
174-
platform: platform as 'ios' | 'android' | 'web',
175-
});
176-
} catch (err) {
177-
const wrapped = err instanceof Error ? err : new Error('Failed to register device');
178-
setError(wrapped);
179-
throw wrapped;
180-
}
181-
},
182-
[client],
183-
);
184-
185-
/* ---- getPreferences ---- */
186-
187-
const getPreferences = useCallback(async () => {
188-
if (!client?.notifications) return null;
189-
setError(null);
190-
try {
191-
return await client.notifications.getPreferences();
192-
} catch (err) {
193-
const wrapped = err instanceof Error ? err : new Error('Failed to get preferences');
194-
setError(wrapped);
195-
throw wrapped;
196-
}
197-
}, [client]);
198-
199-
/* ---- updatePreferences ---- */
200-
201-
const updatePreferences = useCallback(
202-
async (prefs: any) => {
203-
if (!client?.notifications) return;
204-
setError(null);
205-
try {
206-
await client.notifications.updatePreferences(prefs);
207-
} catch (err) {
208-
const wrapped = err instanceof Error ? err : new Error('Failed to update preferences');
209-
setError(wrapped);
210-
throw wrapped;
211-
}
212-
},
213-
[client],
214-
);
215-
216161
/* ---- markAsRead (server + local) ---- */
217162

218163
const markAsRead = useCallback(
@@ -259,9 +204,6 @@ export function useClientNotifications(
259204

260205
return {
261206
fetchNotifications,
262-
registerDevice,
263-
getPreferences,
264-
updatePreferences,
265207
markAsRead,
266208
loading,
267209
error,

0 commit comments

Comments
 (0)