feat: wire App + main with persist + hooks
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
30
src/main.tsx
30
src/main.tsx
@@ -1,9 +1,29 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import App from "./App";
|
||||
import "./index.css";
|
||||
import { hydrateFromDisk, startPersistSubscription, flushPendingPersistSync } from "./lib/persist";
|
||||
import { fetchHotkeyStatus } from "./lib/hotkey";
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
);
|
||||
async function bootstrap(): Promise<void> {
|
||||
await hydrateFromDisk();
|
||||
startPersistSubscription();
|
||||
// Pull the hotkey registration result. Pull-style avoids the
|
||||
// listener-not-yet-registered race that an event-based approach would have.
|
||||
void fetchHotkeyStatus();
|
||||
|
||||
// beforeunload handlers must be synchronous; we use a sync flush helper
|
||||
// that issues the write. The async save will race with window destruction
|
||||
// — whichever wins is fine, the write either lands or we retry next session.
|
||||
window.addEventListener("beforeunload", () => {
|
||||
flushPendingPersistSync();
|
||||
});
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
}
|
||||
|
||||
void bootstrap();
|
||||
|
||||
Reference in New Issue
Block a user