cleaner resets with resetHead

This commit is contained in:
Abi Raja 2024-08-22 13:32:12 -04:00
parent 8e8f0b4b64
commit 089f4302d2
2 changed files with 10 additions and 5 deletions

View File

@ -42,6 +42,7 @@ function App() {
appendCommitCode, appendCommitCode,
setCommitCode, setCommitCode,
resetCommits, resetCommits,
resetHead,
// Outputs // Outputs
appendExecutionConsole, appendExecutionConsole,
@ -116,6 +117,7 @@ function App() {
resetExecutionConsoles(); resetExecutionConsoles();
resetCommits(); resetCommits();
resetHead();
// Inputs // Inputs
setInputMode("image"); setInputMode("image");

View File

@ -17,8 +17,8 @@ interface ProjectStore {
addCommit: (commit: Commit) => void; addCommit: (commit: Commit) => void;
removeCommit: (hash: CommitHash) => void; removeCommit: (hash: CommitHash) => void;
resetCommits: () => void;
setHead: (hash: CommitHash) => void;
appendCommitCode: ( appendCommitCode: (
hash: CommitHash, hash: CommitHash,
numVariant: number, numVariant: number,
@ -26,7 +26,9 @@ interface ProjectStore {
) => void; ) => void;
setCommitCode: (hash: CommitHash, numVariant: number, code: string) => void; setCommitCode: (hash: CommitHash, numVariant: number, code: string) => void;
updateSelectedVariantIndex: (hash: CommitHash, index: number) => void; updateSelectedVariantIndex: (hash: CommitHash, index: number) => void;
resetCommits: () => void;
setHead: (hash: CommitHash) => void;
resetHead: () => void;
executionConsoles: { [key: number]: string[] }; executionConsoles: { [key: number]: string[] };
appendExecutionConsole: (variantIndex: number, line: string) => void; appendExecutionConsole: (variantIndex: number, line: string) => void;
@ -58,8 +60,8 @@ export const useProjectStore = create<ProjectStore>((set) => ({
return { commits: newCommits }; return { commits: newCommits };
}); });
}, },
resetCommits: () => set({ commits: {} }),
setHead: (hash: CommitHash) => set({ head: hash }),
appendCommitCode: (hash: CommitHash, numVariant: number, code: string) => appendCommitCode: (hash: CommitHash, numVariant: number, code: string) =>
set((state) => ({ set((state) => ({
commits: { commits: {
@ -96,8 +98,9 @@ export const useProjectStore = create<ProjectStore>((set) => ({
}, },
}, },
})), })),
resetCommits: () => set({ commits: {}, head: null }),
// TODO: Reset heads setHead: (hash: CommitHash) => set({ head: hash }),
resetHead: () => set({ head: null }),
executionConsoles: {}, executionConsoles: {},
appendExecutionConsole: (variantIndex: number, line: string) => appendExecutionConsole: (variantIndex: number, line: string) =>