-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Limit undo stack to latest 10 changes #963
Conversation
function handle (evt: MessageEvent): void { | ||
function handle (this: NeonCore, evt: MessageEvent): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding typing for this
keyword. This doesn't actually add a new argument for the function, it's just for TypeScript to type this
properly.
this.undoStacks.get(pageURI).push(currentMEI); | ||
|
||
// Add to undo stack: | ||
// Remove the bottommost MEI string on the stack | ||
// if the stack is > 10 strings | ||
const undoStack = this.undoStacks.get(pageURI); | ||
const len = undoStack.push(currentMEI); | ||
|
||
if (len > 10) | ||
this.undoStacks.set(pageURI, undoStack.slice(1)); | ||
|
||
// Clear redo stack: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new logic limiting undo stack to 10 strings
@@ -451,20 +461,18 @@ class NeonCore { | |||
* @returns If the action was undone. | |||
*/ | |||
undo (pageURI: string): Promise<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored undo
and redo
while fixing the undo stack because I realized that we weren't actually resolving the promise in some conditions. The code works functionally the same as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add notifications that explain undo/redo failures, then you can merge this PR.
Also make our console.error into a console.warn since undo/redo fails only when there is nothing on the stack (which isn't that big of a deal).
@@ -2,7 +2,6 @@ import * as Notification from './Notification'; | |||
import NeonView from '../NeonView'; | |||
import { convertStaffToSb } from './ConvertMei'; | |||
import { EditorAction } from '../Types'; | |||
import ZoomHandler from '../SingleView/Zoom'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use this import
No description provided.