1- import React , { useState } from 'react' ;
1+ import React , { useState , useContext } from 'react' ;
22import './App.css' ;
33import Desktop from './components/Desktop/Desktop.jsx' ;
4- import DesktopAppsList from './lists/DesktopAppsList .jsx' ;
5- import { AppsProvider } from './services/AppsContext/AppsContext .jsx' ;
4+ import { AppsContext , AppsProvider } from './services/AppsContext/AppsContext .jsx' ;
5+ import Dock from './components/Dock/Dock .jsx' ;
66
7- function App ( ) {
7+ // Move the logic that uses the context into a component that is rendered inside the provider
8+ function AppContent ( ) {
9+ const { apps } = useContext ( AppsContext ) ;
810 const [ openApps , setOpenApps ] = useState ( [ ] ) ;
911
1012 const handleOpenApp = ( appId ) => {
11- const appConfig = DesktopAppsList . find ( ( app ) => app . id === appId ) ;
13+ const appConfig = apps . find ( ( app ) => app . id === appId ) ;
1214
1315 // If the app configuration has a link, open it in a new tab and do not add to openApps.
1416 if ( appConfig ?. link ) {
@@ -27,13 +29,13 @@ function App() {
2729 } ;
2830
2931 return (
30- < AppsProvider >
32+ < >
33+ < Dock />
3134 < div className = "App" >
3235 < Desktop onOpenApp = { handleOpenApp } />
3336 { openApps . map ( ( appId ) => {
34- const appConfig = DesktopAppsList . find ( ( app ) => app . id === appId ) ;
37+ const appConfig = apps . find ( ( app ) => app . id === appId ) ;
3538 const AppComponent = appConfig ?. component ;
36-
3739 return (
3840 AppComponent && (
3941 < AppComponent
@@ -44,7 +46,18 @@ function App() {
4446 ) ;
4547 } ) }
4648 </ div >
47- </ AppsProvider >
49+ < div className = "version" >
50+ v0.2.2 alpha
51+ </ div >
52+ </ >
53+ ) ;
54+ }
55+
56+ function App ( ) {
57+ return (
58+ < AppsProvider >
59+ < AppContent />
60+ </ AppsProvider >
4861 ) ;
4962}
5063
0 commit comments