2121 * SOFTWARE.
2222 */
2323
24- import { useState } from 'react' ;
24+ import { useEffect , useState } from 'react' ;
2525import { Outlet } from 'react-router-dom' ;
2626
2727import KeyboardShortcutsDialog from '@/components/KeyboardShortcutsDialog' ;
@@ -30,12 +30,15 @@ import Sidebar from '@/components/Sidebar';
3030import StatusBar from '@/components/StatusBar' ;
3131import { ResizableHandle , ResizablePanel , ResizablePanelGroup } from '@/components/ui/resizable' ;
3232import WelcomeScreen from '@/components/WelcomeScreen' ;
33+ import useEnvironment from '@/hooks/useEnvironment' ;
34+ import { isDefaultPath } from '@/lib/utils' ;
3335import useConfigStore from '@/stores/useConfigStore' ;
3436
3537import { entities } from '../../wailsjs/go/models' ;
3638import { EventsOn } from '../../wailsjs/runtime/runtime' ;
3739
3840export default function Root ( ) {
41+ const { environment } = useEnvironment ( ) ;
3942 const scanRoot = useConfigStore ( ( state ) => state . scanRoot ) ;
4043 const [ showKeyboardShortcuts , setShowKeyboardShortcuts ] = useState ( false ) ;
4144 const [ scanModal , setScanModal ] = useState ( false ) ;
@@ -47,14 +50,21 @@ export default function Root() {
4750 setScanModal ( true ) ;
4851 } ;
4952
50- EventsOn ( entities . Action . ShowKeyboardShortcutsModal , ( ) => {
51- setShowKeyboardShortcuts ( true ) ;
52- } ) ;
53- EventsOn ( entities . Action . ScanWithOptions , ( ) => {
54- handleShowScanModal ( ) ;
55- } ) ;
53+ useEffect ( ( ) => {
54+ const unsubShowKeyboardShortcuts = EventsOn ( entities . Action . ShowKeyboardShortcutsModal , ( ) => {
55+ setShowKeyboardShortcuts ( true ) ;
56+ } ) ;
57+ const unsubScanWithOptions = EventsOn ( entities . Action . ScanWithOptions , ( ) => {
58+ handleShowScanModal ( ) ;
59+ } ) ;
5660
57- if ( scanRoot === '/' ) {
61+ return ( ) => {
62+ unsubShowKeyboardShortcuts ( ) ;
63+ unsubScanWithOptions ( ) ;
64+ } ;
65+ } , [ ] ) ;
66+
67+ if ( isDefaultPath ( scanRoot , environment ?. platform ) ) {
5868 return < WelcomeScreen /> ;
5969 }
6070
0 commit comments