Skip to content

Commit a8d314d

Browse files
monferaetpinard
authored andcommitted
Queue length limitation concept
(cherry picked from commit e07f91d)
1 parent d96e5e1 commit a8d314d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/lib/queue.js

+8
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function copyArgArray(gd, args) {
4545

4646
var queue = {};
4747

48+
var maxElementCount = 10;
49+
4850
// TODO: disable/enable undo and redo buttons appropriately
4951

5052
/**
@@ -87,6 +89,12 @@ queue.add = function(gd, undoFunc, undoArgs, redoFunc, redoArgs) {
8789
queueObj.redo.calls.push(redoFunc);
8890
queueObj.redo.args.push(redoArgs);
8991

92+
if(gd.undoQueue.queue.length > maxElementCount) {
93+
gd.undoQueue.queue.shift();
94+
gd.undoQueue.index--;
95+
}
96+
97+
console.log('QUEUE length: ', gd.undoQueue.queue.length)
9098
};
9199

92100
/**

0 commit comments

Comments
 (0)