Spaces:
Running
Running
File size: 1,294 Bytes
c39ed26 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import { createRoot } from "react-dom/client";
import { App } from "./components/App/App";
import { historyDatabase } from "./modules/history";
import { addLogEntry } from "./modules/logEntries";
import { getSettings, listenToSettingsChanges } from "./modules/pubSub";
const settings = getSettings();
historyDatabase.on("ready", () => {
addLogEntry("History database initialized");
});
historyDatabase.on("close", () => {
addLogEntry("History database connection closed");
});
if (settings.enableHistory) {
try {
await historyDatabase.open().catch((error: Error) => {
addLogEntry(`Failed to open history database: ${error.message}`);
});
} catch (error) {
addLogEntry(
`History database initialization error: ${error instanceof Error ? error.message : "Unknown error"}`,
);
}
}
listenToSettingsChanges((newSettings) => {
if (newSettings.enableHistory && !historyDatabase.isOpen()) {
historyDatabase.open().catch((error: Error) => {
addLogEntry(`Failed to open history database: ${error.message}`);
});
} else if (!newSettings.enableHistory && historyDatabase.isOpen()) {
historyDatabase.close();
}
});
createRoot(document.body.appendChild(document.createElement("div"))).render(
<App />,
);
addLogEntry("App initialized");
|