fix: remove unused variable

This commit is contained in:
Jan-Henrik Bruhn 2025-10-10 11:35:57 +02:00
parent 0bd9a94337
commit 79bfd525dd

View file

@ -1,6 +1,6 @@
import { create } from 'zustand';
import type { ConstellationDocument } from './persistence/types';
import { useGraphStore } from './graphStore';
import { create } from "zustand";
import type { ConstellationDocument } from "./persistence/types";
import { useGraphStore } from "./graphStore";
/**
* History Store - Per-Document Undo/Redo System
@ -32,7 +32,10 @@ interface HistoryStore {
interface HistoryActions {
// Initialize history for a document
initializeHistory: (documentId: string, initialState: ConstellationDocument) => void;
initializeHistory: (
documentId: string,
initialState: ConstellationDocument,
) => void;
// Push a new action onto the document's history stack
pushAction: (documentId: string, action: HistoryAction) => void;
@ -70,11 +73,12 @@ interface HistoryActions {
const MAX_HISTORY_SIZE = 50;
export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get) => ({
export const useHistoryStore = create<HistoryStore & HistoryActions>(
(set, get) => ({
histories: new Map(),
maxHistorySize: MAX_HISTORY_SIZE,
initializeHistory: (documentId: string, _initialState: ConstellationDocument) => {
initializeHistory: (documentId: string) => {
set((state) => {
const newHistories = new Map(state.histories);
@ -100,7 +104,7 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
return {};
}
console.log('📝 pushAction:', {
console.log("📝 pushAction:", {
description: action.description,
actionStateNodes: action.documentState.graph.nodes.length,
actionStateEdges: action.documentState.graph.edges.length,
@ -129,11 +133,15 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
redoStack: newRedoStack,
});
console.log('📝 after push:', {
console.log("📝 after push:", {
description: action.description,
newUndoStackSize: newUndoStack.length,
topOfStackNodes: newUndoStack[newUndoStack.length - 1]?.documentState.graph.nodes.length,
topOfStackEdges: newUndoStack[newUndoStack.length - 1]?.documentState.graph.edges.length,
topOfStackNodes:
newUndoStack[newUndoStack.length - 1]?.documentState.graph.nodes
.length,
topOfStackEdges:
newUndoStack[newUndoStack.length - 1]?.documentState.graph.edges
.length,
});
return { histories: newHistories };
@ -148,8 +156,9 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
return null;
}
console.log('⏪ undo:', {
description: history.undoStack[history.undoStack.length - 1].description,
console.log("⏪ undo:", {
description:
history.undoStack[history.undoStack.length - 1].description,
undoStackSize: history.undoStack.length,
});
@ -172,7 +181,7 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
version: '1.0' as const,
version: "1.0" as const,
};
const newRedoStack = [...history.redoStack];
@ -183,9 +192,11 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
});
// Restore the previous state (deep copy)
const restoredState = JSON.parse(JSON.stringify(lastAction.documentState));
const restoredState = JSON.parse(
JSON.stringify(lastAction.documentState),
);
console.log('⏪ after undo:', {
console.log("⏪ after undo:", {
restoredStateNodes: restoredState.graph.nodes.length,
restoredStateEdges: restoredState.graph.edges.length,
undoStackSize: newUndoStack.length,
@ -229,7 +240,7 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
version: '1.0' as const,
version: "1.0" as const,
};
const newUndoStack = [...history.undoStack];
@ -245,7 +256,9 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
}
// Restore the future state (deep copy)
const restoredState = JSON.parse(JSON.stringify(lastAction.documentState));
const restoredState = JSON.parse(
JSON.stringify(lastAction.documentState),
);
newHistories.set(documentId, {
undoStack: newUndoStack,
@ -330,4 +343,5 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
redoCount: history.redoStack.length,
};
},
}));
}),
);