feat: trigger welcome modal from electron

This commit is contained in:
Carlos Valente
2024-11-23 21:57:22 +01:00
committed by Carlos Valente
parent 22fe65c655
commit b4eabfae72
3 changed files with 29 additions and 7 deletions
@@ -1,6 +1,8 @@
import { useCallback, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { addDialog } from '../stores/dialogStore';
const isElectron = window.process?.type === 'renderer';
const ipcRenderer = isElectron ? window.require('electron').ipcRenderer : null;
@@ -24,6 +26,12 @@ export function useElectronListener() {
ipcRenderer.on('request-editor-location', (_event: unknown, location: string) => {
navigate(location, { relative: 'route' });
});
ipcRenderer.on('dialog', (_event: unknown, dialog: string) => {
if (dialog === 'welcome') {
addDialog('welcome');
}
});
}
// Clean the listener after the component is dismounted