feat: small, random changes

This commit is contained in:
trafficlunar 2025-10-08 17:31:31 +01:00
parent 9b0cdfdc9b
commit a27f529276
10 changed files with 24 additions and 20 deletions

View file

@ -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 = () => {