Skip to content

Commit

Permalink
refactor: Move providers to App's parent component
Browse files Browse the repository at this point in the history
Move history & config providers to `main` allowing the App component to
consume the context values (eg: to show current query as window title)
  • Loading branch information
Melvin-Abraham committed Apr 18, 2023
1 parent 007ea2b commit dd964fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
22 changes: 8 additions & 14 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import TitleBar from 'components/TitleBar/TitleBar';
import ResponseViewlet from 'components/ResponseViewlet/ResponseViewlet';
import SuggestionsViewlet, { Suggestions } from 'components/SuggestionsViewlet/SuggestionsViewlet';
import QueryBar from 'components/QueryBar/QueryBar';
import { AssistantHistoryProvider } from 'renderer/contexts/assistantHistory';
import { AssistantConfigProvider } from 'renderer/contexts/config';
import useHistory from 'renderer/hooks/useHistory';
import './App.scss';

Expand All @@ -19,18 +17,14 @@ function App() {
];

return (
<AssistantConfigProvider>
<AssistantHistoryProvider>
<div className="App">
<AssistantContainer>
<TitleBar query={currentHistoryItem?.query} />
<ResponseViewlet />
<SuggestionsViewlet suggestions={suggestions} />
<QueryBar />
</AssistantContainer>
</div>
</AssistantHistoryProvider>
</AssistantConfigProvider>
<div className="App">
<AssistantContainer>
<TitleBar query={currentHistoryItem?.query} />
<ResponseViewlet />
<SuggestionsViewlet suggestions={suggestions} />
<QueryBar />
</AssistantContainer>
</div>
);
}

Expand Down
10 changes: 8 additions & 2 deletions src/renderer/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React from 'react';
import ReactDOM from 'react-dom';
import gassist from 'gassist';
import { audioPlayer } from 'lib/audio/audioPlayer';
import './index.scss';
import { AssistantHistoryProvider } from 'renderer/contexts/assistantHistory';
import { AssistantConfigProvider } from 'renderer/contexts/config';
import App from './App';
import './index.scss';

// Set default Sink ID for audio player
audioPlayer.setDeviceId('default');
Expand Down Expand Up @@ -46,7 +48,11 @@ gassist.assistant.onScreenData((data, format) => {

const rootRenderElement = (
<React.StrictMode>
<App />
<AssistantConfigProvider>
<AssistantHistoryProvider>
<App />
</AssistantHistoryProvider>
</AssistantConfigProvider>
</React.StrictMode>
);

Expand Down

0 comments on commit dd964fa

Please sign in to comment.