Skip to content

Commit

Permalink
Merge pull request #213 from boostcamp-2020/feature/fixRedo
Browse files Browse the repository at this point in the history
refactor : 불필요 코드 제거
  • Loading branch information
LeeSuKyeong authored Dec 20, 2020
2 parents fd921d5 + 51262eb commit e02d277
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
15 changes: 1 addition & 14 deletions src/components/LeftSection/ResizingArea/MathSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DictionaryContent } from '@src/components/Common/DictionaryContent';
import { LatexSymbolContent } from '@src/components/Common/LatexSymbolContent';
import mathSection from '@src/constants/mathSection';
import { changeAlertMode } from '@src/store/modules/alert';
import symbolList from '@src/constants/symbolList';
import * as StyledComponent from './style';
import LatexContentList from './ButtonList';

Expand Down Expand Up @@ -37,20 +38,6 @@ const MathSectionContainer = () => {
}
};

const symbolList = [
'arrow',
'inequality',
'notoperator',
'figure',
'specialsymbol',
'unit',
'misc',
'division',
'plus',
'minus',
'multiple',
'greece',
];
const isSymbol = symbolList.includes(name);

const [list, setList] = useState([]);
Expand Down
22 changes: 11 additions & 11 deletions src/components/MainSection/Tab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { RootState } from '@src/store/modules';
import { changeTab, addTab, updateTab } from '@src/store/modules/tab';
import { change, loadHistory } from '@src/store/modules/mathQuill';
import { loadHistory } from '@src/store/modules/mathQuill';
import { changeFontColor } from '@src/store/modules/fontColorDropdown';
import { changeFontSize } from '@src/store/modules/fontSizeDropdown';
import { changeFontAlign } from '@src/store/modules/fontAlign';
Expand Down Expand Up @@ -38,7 +38,7 @@ const Tab = () => {
let newStoreData: TabData[];

useInterval(() => {
storedData = JSON.parse(window.localStorage.getItem('tab'));
storedData = JSON.parse(window.localStorage.getItem('tab-data'));
newStoreData = storedData.map((data: TabData) => {
if (data.id === selectedTabId) {
return {
Expand All @@ -54,11 +54,11 @@ const Tab = () => {
}
return data;
});
window.localStorage.setItem('tab', JSON.stringify(newStoreData));
window.localStorage.setItem('tab-data', JSON.stringify(newStoreData));
}, 10000);

const handleChangeTab = (tabId: number) => {
storedData = JSON.parse(window.localStorage.getItem('tab'));
storedData = JSON.parse(window.localStorage.getItem('tab-data'));
const selectedTabData = storedData.filter(
(tab: TabData) => tab.id === tabId
)[0];
Expand Down Expand Up @@ -92,11 +92,11 @@ const Tab = () => {
nextLaTex: selectedTabData.nextLaTex,
})
);
window.localStorage.setItem('tab', JSON.stringify(newStoreData));
window.localStorage.setItem('tab-data', JSON.stringify(newStoreData));
};

const handleAddTab = () => {
storedData = JSON.parse(window.localStorage.getItem('tab'));
storedData = JSON.parse(window.localStorage.getItem('tab-data'));

newStoreData = storedData.concat({
id: lastId + 1,
Expand All @@ -110,12 +110,12 @@ const Tab = () => {
nextLaTex: [],
});

window.localStorage.setItem('tab', JSON.stringify(newStoreData));
window.localStorage.setItem('tab-data', JSON.stringify(newStoreData));
dispatch(addTab());
};

const handleDeleteTab = (tabId: number) => {
storedData = JSON.parse(window.localStorage.getItem('tab'));
storedData = JSON.parse(window.localStorage.getItem('tab-data'));
let nextTabInfo: TabData;

if (storedData.length === 1) {
Expand Down Expand Up @@ -145,7 +145,7 @@ const Tab = () => {
});

dispatch(updateTab(newStoreData));
window.localStorage.setItem('tab', JSON.stringify(newStoreData));
window.localStorage.setItem('tab-data', JSON.stringify(newStoreData));
}
};

Expand All @@ -167,7 +167,7 @@ const Tab = () => {
list.push(<PlusTab key={0} handleAddTab={handleAddTab} />);

useEffect(() => {
storedData = JSON.parse(window.localStorage.getItem('tab'));
storedData = JSON.parse(window.localStorage.getItem('tab-data'));
if (storedData !== null) {
dispatch(changeTab(storedData[0].id));
dispatch(updateTab(storedData));
Expand All @@ -183,7 +183,7 @@ const Tab = () => {
})
);
} else {
window.localStorage.setItem('tab', JSON.stringify(tabList));
window.localStorage.setItem('tab-data', JSON.stringify(tabList));
}
}, []);

Expand Down
2 changes: 1 addition & 1 deletion src/components/MainSection/Tab/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const SmallTab = styled.li`
border-radius: 0 0 10px 10px;
width: 2.5rem;
height: 1.3rem;
padding: 0.3rem;0 10px 10px;
padding: 0.3rem;
list-style: none;
background-color: ${colors.lightGrey};
color: ${colors.black};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/localstorage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const getLastId = () => {
const storedData = JSON.parse(window.localStorage.getItem('tab'));
const storedData = JSON.parse(window.localStorage.getItem('tab-data'));
if (storedData) {
return storedData[storedData.length - 1].id;
}
Expand Down

0 comments on commit e02d277

Please sign in to comment.