fix: pr review - remove unneeded useState and useEffect in SessionEmojiPanel

This commit is contained in:
William Grant 2022-10-14 16:18:55 +11:00
parent be21f29875
commit 172510d11b

View file

@ -1,4 +1,4 @@
import React, { forwardRef, useEffect, useState } from 'react';
import React, { forwardRef } from 'react';
import classNames from 'classnames';
import styled from 'styled-components';
// @ts-ignore
@ -103,31 +103,29 @@ export const SessionEmojiPanel = forwardRef<HTMLDivElement, Props>((props: Props
const theme = useSelector(getTheme);
const isDarkMode = useSelector(isDarkTheme);
const [panelBackgroundRGB, setPanelBackgroundRGB] = useState('');
const [panelTextRGB, setPanelTextRGB] = useState('');
let panelBackgroundRGB = hexColorToRGB(THEMES.CLASSIC_DARK.COLOR1);
let panelTextRGB = hexColorToRGB(THEMES.CLASSIC_DARK.COLOR6);
useEffect(() => {
switch (theme) {
case 'ocean-dark':
setPanelBackgroundRGB(hexColorToRGB(THEMES.OCEAN_DARK.COLOR1));
// tslint:disable: no-non-null-assertion
setPanelTextRGB(hexColorToRGB(THEMES.OCEAN_DARK.COLOR7!));
break;
case 'ocean-light':
// tslint:disable: no-non-null-assertion
setPanelBackgroundRGB(hexColorToRGB(THEMES.OCEAN_LIGHT.COLOR7!));
setPanelTextRGB(hexColorToRGB(THEMES.OCEAN_LIGHT.COLOR1));
break;
case 'classic-light':
setPanelBackgroundRGB(hexColorToRGB(THEMES.CLASSIC_LIGHT.COLOR6));
setPanelTextRGB(hexColorToRGB(THEMES.CLASSIC_LIGHT.COLOR0));
break;
case 'classic-dark':
default:
setPanelBackgroundRGB(hexColorToRGB(THEMES.CLASSIC_DARK.COLOR1));
setPanelTextRGB(hexColorToRGB(THEMES.CLASSIC_DARK.COLOR6));
}
}, [theme]);
switch (theme) {
case 'ocean-dark':
panelBackgroundRGB = hexColorToRGB(THEMES.OCEAN_DARK.COLOR1);
// tslint:disable: no-non-null-assertion
panelTextRGB = hexColorToRGB(THEMES.OCEAN_DARK.COLOR7!);
break;
case 'ocean-light':
// tslint:disable: no-non-null-assertion
panelBackgroundRGB = hexColorToRGB(THEMES.OCEAN_LIGHT.COLOR7!);
panelTextRGB = hexColorToRGB(THEMES.OCEAN_LIGHT.COLOR1);
break;
case 'classic-light':
panelBackgroundRGB = hexColorToRGB(THEMES.CLASSIC_LIGHT.COLOR6);
panelTextRGB = hexColorToRGB(THEMES.CLASSIC_LIGHT.COLOR0);
break;
case 'classic-dark':
default:
panelBackgroundRGB = hexColorToRGB(THEMES.CLASSIC_DARK.COLOR1);
panelTextRGB = hexColorToRGB(THEMES.CLASSIC_DARK.COLOR6);
}
return (
<StyledEmojiPanel