Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove local context #111

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 0 additions & 105 deletions src/context/SettingsContext.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion src/context/SimulationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const SimulationProvider = ({
unit: TimeUnit.Years,
});
const [simulationStatus, setSimulationStatus] = useState<SimulationStatus>(
SimulationStatus.LOADING, // waiting for the temperatures...
SimulationStatus.INITIAL_LOADING, // waiting for the temperatures...
);
const [simulationSpeedIdx, setSimulationSpeedIdx] = useState(0);

Expand Down Expand Up @@ -150,6 +150,7 @@ export const SimulationProvider = ({
type: 'load',
temperatureRows: temperatures.current,
});
setSimulationStatus(SimulationStatus.LOADING);
});
}, [csv, csv.measurementFrequency, csv.path, simulationDuration.value]);

Expand Down
3 changes: 3 additions & 0 deletions src/langs/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"INITIAL_LOADING": {
"LOADING_MESSAGE": "Loading House Insulation Simulator..."
},
"DATES": {
"YEARS_one": "{{count}} year",
"YEARS_other": "{{count}} years",
Expand Down
85 changes: 22 additions & 63 deletions src/modules/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@ import { CssBaseline, ThemeProvider, createTheme, styled } from '@mui/material';
import { grey, orange, pink } from '@mui/material/colors';
import { StyledEngineProvider } from '@mui/material/styles';

import {
GraaspContextDevTool,
WithLocalContext,
WithTokenContext,
} from '@graasp/apps-query-client';
import '@graasp/apps-query-client';

import i18nConfig from '@/config/i18n';
import {
QueryClientProvider,
ReactQueryDevtools,
hooks,
queryClient,
} from '@/config/queryClient';
import { defaultMockContext, mockMembers } from '@/mocks/db';
import Loader from '@/modules/common/Loader';
import { useObjectState } from '@/utils/hooks';

import ErrorBoundary from './ErrorBoundary';
import App from './main/App';
Expand Down Expand Up @@ -73,59 +65,26 @@ const RootDiv = styled('div')({
background: '#fafaff',
});

const Root: FC = () => {
const [mockContext, setMockContext] = useObjectState(defaultMockContext);

return (
<RootDiv>
{/* Used to define the order of injected properties between JSS and emotion */}
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<CssBaseline enableColorScheme />
<I18nextProvider i18n={i18nConfig}>
<ErrorBoundary>
<QueryClientProvider client={queryClient}>
<ToastContainer />
<WithLocalContext
defaultValue={mockContext}
LoadingComponent={<Loader />}
useGetLocalContext={hooks.useGetLocalContext}
useAutoResize={hooks.useAutoResize}
onError={() => {
console.error(
'An error occurred while fetching the context.',
);
}}
>
<WithTokenContext
LoadingComponent={<Loader />}
useAuthToken={hooks.useAuthToken}
onError={() => {
console.error(
'An error occurred while requesting the token.',
);
}}
>
<App />
{import.meta.env.DEV && (
<GraaspContextDevTool
members={mockMembers}
context={mockContext}
setContext={setMockContext}
/>
)}
</WithTokenContext>
</WithLocalContext>
{import.meta.env.DEV && (
<ReactQueryDevtools position="bottom-left" />
)}
</QueryClientProvider>
</ErrorBoundary>
</I18nextProvider>
</ThemeProvider>
</StyledEngineProvider>
</RootDiv>
);
};
const Root: FC = () => (
<RootDiv>
{/* Used to define the order of injected properties between JSS and emotion */}
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<CssBaseline enableColorScheme />
<I18nextProvider i18n={i18nConfig}>
<ErrorBoundary>
<QueryClientProvider client={queryClient}>
<ToastContainer />
<App />
{import.meta.env.DEV && (
<ReactQueryDevtools position="bottom-left" />
)}
</QueryClientProvider>
</ErrorBoundary>
</I18nextProvider>
</ThemeProvider>
</StyledEngineProvider>
</RootDiv>
);

export default Root;
40 changes: 0 additions & 40 deletions src/modules/main/AnalyticsView.tsx

This file was deleted.

26 changes: 1 addition & 25 deletions src/modules/main/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { useEffect } from 'react';

import { useLocalContext } from '@graasp/apps-query-client';
import { Context } from '@graasp/sdk';

import { SettingsProvider } from '@/context/SettingsContext';

import i18n, { DEFAULT_LANGUAGE } from '../../config/i18n';
import AnalyticsView from './AnalyticsView';
import BuilderView from './BuilderView';
import PlayerView from './PlayerView';

const App = (): JSX.Element => {
Expand All @@ -21,26 +16,7 @@ const App = (): JSX.Element => {
}
}, [context]);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const renderContent = (): JSX.Element => {
switch (context.context) {
case Context.Builder:
return <BuilderView />;

case Context.Analytics:
return <AnalyticsView />;

case Context.Player:
default:
return <PlayerView />;
}
};

return (
<SettingsProvider>
<PlayerView />
</SettingsProvider>
);
return <PlayerView />;
};

export default App;
Loading
Loading