Open-source and local-first Slack and Notion alternative that puts you in control of your data
TypeScript chatchat-applicationcrdteditorelectronknowledge-baselocal-firstnotionnotion-alternativerealtime-collaborationself-hostedslacksqliteteam-collaborationwikiyjs
Init boostrap async
Hakan Shehu9733ee522b8a
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.tsindex 1357a992..e82842f3 100644--- a/apps/desktop/src/main.ts+++ b/apps/desktop/src/main.ts@@ -23,8 +23,8 @@ if (started) {app.quit();}-const createWindow = async () => {- await bootstrapper.init();+const createWindow = () => {+ bootstrapper.init();// Create the browser window.const mainWindow = new BrowserWindow({@@ -107,6 +107,10 @@ app.on('activate', () => {// In this file you can include the rest of your app's specific main process// code. You can also put them in separate files and import them here.+ipcMain.handle('init', async () => {+ await bootstrapper.init();+});+ipcMain.handle('execute-mutation',async <T extends MutationInput>(diff --git a/apps/desktop/src/renderer/root.tsx b/apps/desktop/src/renderer/root.tsxindex 592f3b5f..60b95d38 100644--- a/apps/desktop/src/renderer/root.tsx+++ b/apps/desktop/src/renderer/root.tsx@@ -16,6 +16,8 @@ import { useEventBus } from '@/renderer/hooks/use-event-bus';import { Event } from '@/shared/types/events';import { AccountRedirect } from '@/renderer/components/accounts/account-redirect';import { Account } from '@/renderer/components/accounts/account';+import { DelayedComponent } from '@/renderer/components/ui/delayed-component';+import { AppLoading } from '@/renderer/app-loading';const router = createHashRouter([{@@ -56,6 +58,7 @@ const queryClient = new QueryClient();const Root = () => {const eventBus = useEventBus();+ const [initialized, setInitialized] = React.useState(false);React.useEffect(() => {const id = eventBus.subscribe((event: Event) => {@@ -93,11 +96,23 @@ const Root = () => {}});+ window.colanode.init().then(() => {+ setInitialized(true);+ });+return () => {eventBus.unsubscribe(id);};}, []);+ if (!initialized) {+ return (+ <DelayedComponent>+ <AppLoading />+ </DelayedComponent>+ );+ }+return (<QueryClientProvider client={queryClient}><DndProvider backend={HTML5Backend}>