Skip to content

Commit

Permalink
Fix graph view bug caused by layout change
Browse files Browse the repository at this point in the history
  • Loading branch information
selinali2010 committed Oct 9, 2023
1 parent 69a7107 commit d3095ba
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/utils/mockAquaProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const defaultAquaContext: IAquaContext = {
setGlobalError: (_newValue?: ErrorDescription) => {},
setIsEnabled: (_newValue: boolean) => {},
setAutoPreAmpOn: (_newValue: boolean) => {},
setGraphViewOn: (_newValue: boolean) => {},
setIsGraphViewOn: (_newValue: boolean) => {},
setPreAmp: (_newValue: number) => {},
dispatchFilter: (_action: FilterAction) => {},
setConfigFileName: (_filename: string) => {},
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import ConfirmationModal from './widgets/ConfirmationModal';
export const AppContent = () => {
const {
isLoading,
isGraphViewOn,
globalError,
configFileName,
performHealthCheck,
Expand Down Expand Up @@ -143,7 +144,7 @@ export const AppContent = () => {
handleClick={() => setShowSettingsModal(true)}
/>
</header>
<div className="app">
<div className={`app ${isGraphViewOn ? '' : 'minimized'}`}>
<SideBar />
<div className="middle-content">
<AutoEQ />
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/GraphViewSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface IGraphViewSwitchProps {
}

export default function GraphViewSwitch({ id }: IGraphViewSwitchProps) {
const { globalError, isGraphViewOn, setGlobalError, setGraphViewOn } =
const { globalError, isGraphViewOn, setGlobalError, setIsGraphViewOn } =
useAquaContext();

const handleToggle = useCallback(async () => {
Expand All @@ -42,18 +42,18 @@ export default function GraphViewSwitch({ id }: IGraphViewSwitchProps) {

// Reduce window size before allowing parametric components to fill space
await decreaseWindowSize();
setGraphViewOn(!isGraphViewOn);
setIsGraphViewOn(!isGraphViewOn);
} else {
await enableGraphView();

// Set parametric components to a fixed height before increasing window size
setGraphViewOn(!isGraphViewOn);
setIsGraphViewOn(!isGraphViewOn);
await increaseWindowSize();
}
} catch (e) {
setGlobalError(e as ErrorDescription);
}
}, [isGraphViewOn, setGlobalError, setGraphViewOn]);
}, [isGraphViewOn, setGlobalError, setIsGraphViewOn]);

return (
<Switch
Expand Down
12 changes: 3 additions & 9 deletions src/renderer/utils/AquaContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export interface IAquaContext extends IState {
setGlobalError: (newValue?: ErrorDescription) => void;
setIsEnabled: (newValue: boolean) => void;
setAutoPreAmpOn: (newValue: boolean) => void;
setGraphViewOn: (newValue: boolean) => void;
setIsGraphViewOn: (newValue: boolean) => void;
setPreAmp: (newValue: number) => void;
setConfigFileName: (newValue: string) => void;
dispatchFilter: FilterDispatch;
Expand Down Expand Up @@ -183,19 +183,13 @@ export const AquaProvider = ({ children }: IAquaProviderProps) => {

const [isLoading, setIsLoading] = useState<boolean>(true);

const setGraphViewOn = (newValue: boolean) => {
setIsGraphViewOn(newValue);
const root = document.getElementById('root');
root?.setAttribute('class', newValue ? '' : 'minimized');
};

const performHealthCheck = useCallback(async () => {
setIsLoading(true);
try {
const state = await getEqualizerState();
setIsEnabled(state.isEnabled);
setAutoPreAmpOn(state.isAutoPreAmpOn);
setGraphViewOn(state.isGraphViewOn);
setIsGraphViewOn(state.isGraphViewOn);
setPreAmp(state.preAmp);
dispatchFilter({ type: FilterActionEnum.INIT, filters: state.filters });
setGlobalError(undefined);
Expand Down Expand Up @@ -227,7 +221,7 @@ export const AquaProvider = ({ children }: IAquaProviderProps) => {
setGlobalError,
setIsEnabled,
setAutoPreAmpOn,
setGraphViewOn,
setIsGraphViewOn,
setPreAmp,
setConfigFileName,
dispatchFilter,
Expand Down

0 comments on commit d3095ba

Please sign in to comment.