|
@@ -18,8 +18,6 @@ import {
|
|
|
exportAsPNG,
|
|
|
restoreFromLocalStorage,
|
|
|
saveToLocalStorage,
|
|
|
- restoreFromURL,
|
|
|
- saveToURL,
|
|
|
hasBackground,
|
|
|
hasStroke,
|
|
|
getElementAtPosition,
|
|
@@ -122,8 +120,7 @@ class App extends React.Component<{}, AppState> {
|
|
|
document.addEventListener("keydown", this.onKeyDown, false);
|
|
|
window.addEventListener("resize", this.onResize, false);
|
|
|
|
|
|
- const savedState =
|
|
|
- restoreFromURL(elements) || restoreFromLocalStorage(elements);
|
|
|
+ const savedState = restoreFromLocalStorage(elements);
|
|
|
if (savedState) {
|
|
|
this.setState(savedState);
|
|
|
}
|
|
@@ -951,11 +948,6 @@ class App extends React.Component<{}, AppState> {
|
|
|
}));
|
|
|
};
|
|
|
|
|
|
- private saveDebounced = debounce(() => {
|
|
|
- saveToLocalStorage(elements, this.state);
|
|
|
- saveToURL(elements, this.state);
|
|
|
- }, 300);
|
|
|
-
|
|
|
private addElementsFromPaste = (paste: string, x?: number, y?: number) => {
|
|
|
let parsedElements;
|
|
|
try {
|
|
@@ -995,7 +987,7 @@ class App extends React.Component<{}, AppState> {
|
|
|
scrollY: this.state.scrollY,
|
|
|
viewBackgroundColor: this.state.viewBackgroundColor
|
|
|
});
|
|
|
- this.saveDebounced();
|
|
|
+ saveToLocalStorage(elements, this.state);
|
|
|
if (history.isRecording()) {
|
|
|
history.pushEntry(history.generateCurrentEntry(elements));
|
|
|
history.clearRedoStack();
|
|
@@ -1004,14 +996,6 @@ class App extends React.Component<{}, AppState> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function debounce<T extends any[]>(fn: (...args: T) => void, timeout: number) {
|
|
|
- let handle = 0;
|
|
|
- return (...args: T) => {
|
|
|
- clearTimeout(handle);
|
|
|
- handle = window.setTimeout(() => fn(...args), timeout);
|
|
|
- };
|
|
|
-}
|
|
|
-
|
|
|
const rootElement = document.getElementById("root");
|
|
|
ReactDOM.render(<App />, rootElement);
|
|
|
const canvas = document.getElementById("canvas") as HTMLCanvasElement;
|