Implement webworker for save operation + Limit the history size (#29)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
- Implement webworker for save operation - Limit the history size Reviewed-on: https://git.siklos-chaneru.duckdns.org/Siklos/svg-layout-designer-react/pulls/29
This commit is contained in:
parent
5b20e4f2dc
commit
7ff411b988
6 changed files with 64 additions and 18 deletions
|
@ -10,6 +10,7 @@ import { onKeyDown } from './Shortcuts';
|
|||
import { OnPropertyChange, OnPropertiesSubmit } from './PropertiesOperations';
|
||||
import EditorEvents from '../../Events/EditorEvents';
|
||||
import { IEditorState } from '../../Interfaces/IEditorState';
|
||||
import { MAX_HISTORY } from '../../utils/default';
|
||||
|
||||
interface IEditorProps {
|
||||
configuration: IConfiguration
|
||||
|
@ -17,7 +18,12 @@ interface IEditorProps {
|
|||
historyCurrentStep: number
|
||||
}
|
||||
|
||||
export const getCurrentHistory = (history: IHistoryState[], historyCurrentStep: number): IHistoryState[] => history.slice(0, historyCurrentStep + 1);
|
||||
export const getCurrentHistory = (history: IHistoryState[], historyCurrentStep: number): IHistoryState[] =>
|
||||
history.slice(
|
||||
Math.max(0, history.length - MAX_HISTORY), // change this to 0 for unlimited (not recommanded because of overflow)
|
||||
historyCurrentStep + 1
|
||||
);
|
||||
|
||||
export const getCurrentHistoryState = (history: IHistoryState[], historyCurrentStep: number): IHistoryState => history[historyCurrentStep];
|
||||
|
||||
const Editor: React.FunctionComponent<IEditorProps> = (props) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue