refactor: remove unused unsubscribe function from journalStream

This commit is contained in:
hypercross 2026-07-13 00:54:20 +08:00
parent 960e310208
commit c9c977bee1
2 changed files with 3 additions and 6 deletions

View File

@ -60,7 +60,7 @@ export type { SessionManifest } from "../../workers/journal.worker";
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let _workerAPI: Comlink.Remote<JournalWorkerAPI> | null = null; let _workerAPI: Comlink.Remote<JournalWorkerAPI> | null = null;
let _unsubscribe: (() => void) | null = null;
function getWorkerAPI(): Comlink.Remote<JournalWorkerAPI> { function getWorkerAPI(): Comlink.Remote<JournalWorkerAPI> {
if (!_workerAPI) { if (!_workerAPI) {
@ -226,7 +226,7 @@ async function ensureSubscribed(): Promise<void> {
_subscribed = true; _subscribed = true;
const api = getWorkerAPI(); const api = getWorkerAPI();
_unsubscribe = await api.subscribe( await api.subscribe(
Comlink.proxy((patch: WorkerPatch) => { Comlink.proxy((patch: WorkerPatch) => {
handlePatch(patch); handlePatch(patch);
}), }),

View File

@ -496,7 +496,7 @@ const api = {
}, },
/** Register a callback for state patches. Sends full state immediately. */ /** Register a callback for state patches. Sends full state immediately. */
subscribe(callback: Comlink.ProxyOrClone<PatchCallback>): () => void { subscribe(callback: Comlink.ProxyOrClone<PatchCallback>): void {
const cb = callback as PatchCallback; const cb = callback as PatchCallback;
subscribers.add(cb); subscribers.add(cb);
// Send initial full state // Send initial full state
@ -513,9 +513,6 @@ const api = {
} catch { } catch {
// ignore // ignore
} }
return () => {
subscribers.delete(cb);
};
}, },
}; };