Skip to content

Commit bec3be1

Browse files
committed
refactor(collaboration,mobile): delete readerless createPresenceUpdater and requestBackgroundSync
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgUhKx1XHzkoikGjRB4
1 parent 125ad06 commit bec3be1

3 files changed

Lines changed: 11 additions & 50 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/collaboration': patch
3+
'@object-ui/mobile': patch
4+
---
5+
6+
refactor(collaboration,mobile): delete the module-local `createPresenceUpdater` and `requestBackgroundSync` helpers that nothing reads
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
Neither name is exported from its package entry (the single `.` export), so no host can import them; the compiled `usePresence.js` and `serviceWorkerSource.js` simply stop carrying the two dead function bodies. Behaviour of every exported name is unchanged.

‎ui/packages/collaboration/src/usePresence.ts‎

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -205,41 +205,3 @@ export function usePresence(
205205
currentUser,
206206
};
207207
}
208-
209-
/**
210-
* Update remote user presence. Call this when receiving presence data
211-
* from other users via the realtime channel.
212-
*
213-
* @returns A function to update or remove a remote user from the presence set.
214-
*/
215-
export function createPresenceUpdater(): {
216-
updateUser: (user: PresenceUser) => void;
217-
removeUser: (userId: string) => void;
218-
getUsers: () => PresenceUser[];
219-
onUsersChange: (callback: (users: Map<string, PresenceUser>) => void) => () => void;
220-
} {
221-
const users = new Map<string, PresenceUser>();
222-
const listeners = new Set<(users: Map<string, PresenceUser>) => void>();
223-
224-
const notify = () => {
225-
listeners.forEach(cb => cb(new Map(users)));
226-
};
227-
228-
return {
229-
updateUser(user: PresenceUser) {
230-
users.set(user.userId, user);
231-
notify();
232-
},
233-
removeUser(userId: string) {
234-
users.delete(userId);
235-
notify();
236-
},
237-
getUsers() {
238-
return Array.from(users.values());
239-
},
240-
onUsersChange(callback: (users: Map<string, PresenceUser>) => void) {
241-
listeners.add(callback);
242-
return () => { listeners.delete(callback); };
243-
},
244-
};
245-
}

‎ui/packages/mobile/src/serviceWorkerSource.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,3 @@ self.addEventListener('sync', (event) => {
9595
});
9696
`;
9797
}
98-
99-
/**
100-
* Request a one-shot background sync. The page should call this after
101-
* enqueuing offline work so the browser will wake the SW when the
102-
* connection returns. Returns false if Background Sync is unsupported.
103-
*/
104-
export async function requestBackgroundSync(tag = 'objectui-offline-queue'): Promise<boolean> {
105-
if (typeof navigator === 'undefined') return false;
106-
const reg: any = await (navigator as any).serviceWorker?.ready;
107-
if (!reg || !reg.sync) return false;
108-
try { await reg.sync.register(tag); return true; } catch { return false; }
109-
}

0 commit comments

Comments
 (0)