mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-08-12 12:29:42 +00:00
feat: small, random changes
This commit is contained in:
parent
9b0cdfdc9b
commit
a27f529276
10 changed files with 24 additions and 20 deletions
|
|
@ -27,16 +27,17 @@ export const HistoryProvider = ({ children }: Props) => {
|
|||
const MAX_HISTORY = 20;
|
||||
|
||||
const addHistory = (name: string, apply: () => void, revert: () => void) => {
|
||||
const newHistory = history.slice(0, currentIndex + 1);
|
||||
newHistory.push({ name, apply, revert });
|
||||
setHistory((prev) => {
|
||||
const newHistory = prev.slice(0, currentIndex + 1);
|
||||
newHistory.push({ name, apply, revert });
|
||||
|
||||
if (newHistory.length > MAX_HISTORY) {
|
||||
newHistory.shift();
|
||||
}
|
||||
|
||||
if (newHistory.length > MAX_HISTORY) {
|
||||
newHistory.shift();
|
||||
} else {
|
||||
setCurrentIndex(newHistory.length - 1);
|
||||
}
|
||||
|
||||
setHistory(newHistory);
|
||||
return newHistory;
|
||||
});
|
||||
};
|
||||
|
||||
const undo = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue