Skip to content

Commit c1fad00

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
fix(undo): Include customColors in visual stack
1 parent db6d011 commit c1fad00

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/App.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ function App() {
197197
showLigands,
198198
showIons,
199199
showSurface,
200-
customBackgroundColor: customBackgroundColor || ''
201-
}), [representation, coloring, colorPalette, showLigands, showIons, showSurface, customBackgroundColor]);
200+
customBackgroundColor: customBackgroundColor || '',
201+
customColors
202+
}), [representation, coloring, colorPalette, showLigands, showIons, showSurface, customBackgroundColor, customColors]);
202203

203204
const handleVisualStateChange = useCallback((newState: VisualState) => {
204205
setRepresentation(newState.representation);
@@ -208,6 +209,7 @@ function App() {
208209
setShowIons(newState.showIons);
209210
setShowSurface(newState.showSurface);
210211
setCustomBackgroundColor(newState.customBackgroundColor || null);
212+
setCustomColors(newState.customColors);
211213
}, []);
212214

213215
const { undo, redo, canUndo, canRedo } = useVisualStack({

src/hooks/useVisualStack.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect, useCallback, useRef } from 'react';
2-
import type { RepresentationType, ColoringType, ColorPalette } from '../types';
2+
import type { RepresentationType, ColoringType, ColorPalette, CustomColorRule } from '../types';
33

44
export interface VisualState {
55
representation: RepresentationType;
@@ -9,6 +9,7 @@ export interface VisualState {
99
showIons: boolean;
1010
showSurface: boolean;
1111
customBackgroundColor: string;
12+
customColors: CustomColorRule[];
1213
}
1314

1415
interface UseVisualStackProps {
@@ -53,7 +54,8 @@ export function useVisualStack({ state, onChange, resetTrigger }: UseVisualStack
5354
prev.showLigands !== state.showLigands ||
5455
prev.showIons !== state.showIons ||
5556
prev.showSurface !== state.showSurface ||
56-
prev.customBackgroundColor !== state.customBackgroundColor;
57+
prev.customBackgroundColor !== state.customBackgroundColor ||
58+
prev.customColors !== state.customColors;
5759

5860
if (hasChanged) {
5961
setPast(prevPast => {

0 commit comments

Comments
 (0)