mirror of
https://github.com/OFFIS-ESC/constellation-analyzer
synced 2026-01-27 07:43:41 +00:00
fix: remove unused variable
This commit is contained in:
parent
0bd9a94337
commit
79bfd525dd
1 changed files with 257 additions and 243 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { create } from 'zustand';
|
import { create } from "zustand";
|
||||||
import type { ConstellationDocument } from './persistence/types';
|
import type { ConstellationDocument } from "./persistence/types";
|
||||||
import { useGraphStore } from './graphStore';
|
import { useGraphStore } from "./graphStore";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* History Store - Per-Document Undo/Redo System
|
* History Store - Per-Document Undo/Redo System
|
||||||
|
|
@ -32,7 +32,10 @@ interface HistoryStore {
|
||||||
|
|
||||||
interface HistoryActions {
|
interface HistoryActions {
|
||||||
// Initialize history for a document
|
// 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
|
// Push a new action onto the document's history stack
|
||||||
pushAction: (documentId: string, action: HistoryAction) => void;
|
pushAction: (documentId: string, action: HistoryAction) => void;
|
||||||
|
|
@ -70,11 +73,12 @@ interface HistoryActions {
|
||||||
|
|
||||||
const MAX_HISTORY_SIZE = 50;
|
const MAX_HISTORY_SIZE = 50;
|
||||||
|
|
||||||
export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get) => ({
|
export const useHistoryStore = create<HistoryStore & HistoryActions>(
|
||||||
|
(set, get) => ({
|
||||||
histories: new Map(),
|
histories: new Map(),
|
||||||
maxHistorySize: MAX_HISTORY_SIZE,
|
maxHistorySize: MAX_HISTORY_SIZE,
|
||||||
|
|
||||||
initializeHistory: (documentId: string, _initialState: ConstellationDocument) => {
|
initializeHistory: (documentId: string) => {
|
||||||
set((state) => {
|
set((state) => {
|
||||||
const newHistories = new Map(state.histories);
|
const newHistories = new Map(state.histories);
|
||||||
|
|
||||||
|
|
@ -100,7 +104,7 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('📝 pushAction:', {
|
console.log("📝 pushAction:", {
|
||||||
description: action.description,
|
description: action.description,
|
||||||
actionStateNodes: action.documentState.graph.nodes.length,
|
actionStateNodes: action.documentState.graph.nodes.length,
|
||||||
actionStateEdges: action.documentState.graph.edges.length,
|
actionStateEdges: action.documentState.graph.edges.length,
|
||||||
|
|
@ -129,11 +133,15 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
|
||||||
redoStack: newRedoStack,
|
redoStack: newRedoStack,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('📝 after push:', {
|
console.log("📝 after push:", {
|
||||||
description: action.description,
|
description: action.description,
|
||||||
newUndoStackSize: newUndoStack.length,
|
newUndoStackSize: newUndoStack.length,
|
||||||
topOfStackNodes: newUndoStack[newUndoStack.length - 1]?.documentState.graph.nodes.length,
|
topOfStackNodes:
|
||||||
topOfStackEdges: newUndoStack[newUndoStack.length - 1]?.documentState.graph.edges.length,
|
newUndoStack[newUndoStack.length - 1]?.documentState.graph.nodes
|
||||||
|
.length,
|
||||||
|
topOfStackEdges:
|
||||||
|
newUndoStack[newUndoStack.length - 1]?.documentState.graph.edges
|
||||||
|
.length,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { histories: newHistories };
|
return { histories: newHistories };
|
||||||
|
|
@ -148,8 +156,9 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('⏪ undo:', {
|
console.log("⏪ undo:", {
|
||||||
description: history.undoStack[history.undoStack.length - 1].description,
|
description:
|
||||||
|
history.undoStack[history.undoStack.length - 1].description,
|
||||||
undoStackSize: history.undoStack.length,
|
undoStackSize: history.undoStack.length,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -172,7 +181,7 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
},
|
},
|
||||||
version: '1.0' as const,
|
version: "1.0" as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newRedoStack = [...history.redoStack];
|
const newRedoStack = [...history.redoStack];
|
||||||
|
|
@ -183,9 +192,11 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Restore the previous state (deep copy)
|
// 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,
|
restoredStateNodes: restoredState.graph.nodes.length,
|
||||||
restoredStateEdges: restoredState.graph.edges.length,
|
restoredStateEdges: restoredState.graph.edges.length,
|
||||||
undoStackSize: newUndoStack.length,
|
undoStackSize: newUndoStack.length,
|
||||||
|
|
@ -229,7 +240,7 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
},
|
},
|
||||||
version: '1.0' as const,
|
version: "1.0" as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newUndoStack = [...history.undoStack];
|
const newUndoStack = [...history.undoStack];
|
||||||
|
|
@ -245,7 +256,9 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the future state (deep copy)
|
// 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, {
|
newHistories.set(documentId, {
|
||||||
undoStack: newUndoStack,
|
undoStack: newUndoStack,
|
||||||
|
|
@ -330,4 +343,5 @@ export const useHistoryStore = create<HistoryStore & HistoryActions>((set, get)
|
||||||
redoCount: history.redoStack.length,
|
redoCount: history.redoStack.length,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue