mirror of
				https://github.com/excalidraw/excalidraw.git
				synced 2025-10-31 02:44:50 +01:00 
			
		
		
		
	Fix undoOnce (#332)
I just pasted @enzoferey's implementation and it fixed the bug reported by @dwelle Fixes #307
This commit is contained in:
		 Christopher Chedeau
					Christopher Chedeau
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							dd2a7eb597
						
					
				
				
					commit
					44657efe71
				
			| @@ -51,15 +51,15 @@ class SceneHistory { | ||||
|     return null; | ||||
|   } | ||||
|  | ||||
|   undoOnce(elements: readonly ExcalidrawElement[]) { | ||||
|     const currentEntry = this.generateCurrentEntry(elements); | ||||
|     let entryToRestore = this.stateHistory.pop(); | ||||
|  | ||||
|     // If nothing was changed since last, take the previous one | ||||
|     if (currentEntry === entryToRestore) { | ||||
|       entryToRestore = this.stateHistory.pop(); | ||||
|   undoOnce() { | ||||
|     if (this.stateHistory.length === 0) { | ||||
|       return null; | ||||
|     } | ||||
|     if (entryToRestore !== undefined) { | ||||
|  | ||||
|     const currentEntry = this.stateHistory.pop(); | ||||
|     const entryToRestore = this.stateHistory[this.stateHistory.length - 1]; | ||||
|  | ||||
|     if (currentEntry !== undefined) { | ||||
|       this.redoStack.push(currentEntry); | ||||
|       return this.restoreEntry(entryToRestore); | ||||
|     } | ||||
|   | ||||
| @@ -256,7 +256,7 @@ export class App extends React.Component<{}, AppState> { | ||||
|         } | ||||
|       } else { | ||||
|         // undo action | ||||
|         const data = history.undoOnce(elements); | ||||
|         const data = history.undoOnce(); | ||||
|         if (data !== null) { | ||||
|           elements = data; | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user