Skip to content

Commit

Permalink
chore: don't store history if no diff
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Oct 18, 2023
1 parent 8d47fd7 commit c276b23
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/core/components/Puck/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const defaultAppState: AppState = {
ui: {
leftSideBarVisible: true,
arrayState: {},
itemSelector: null,
},
};

Expand Down
2 changes: 2 additions & 0 deletions packages/core/lib/use-puck-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const _recordHistory = ({
record: (params: any) => void;
dispatch: (action: PuckAction) => void;
}) => {
if (JSON.stringify(snapshot) === JSON.stringify(newSnapshot)) return;

record({
forward: () => {
dispatch({ type: "set", state: newSnapshot });
Expand Down
2 changes: 1 addition & 1 deletion packages/core/types/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export type ArrayState = { items: ItemWithId[]; openId: string };

export type UiState = {
leftSideBarVisible: boolean;
itemSelector?: ItemSelector | null;
itemSelector: ItemSelector | null;
arrayState: Record<string, ArrayState | undefined>;
};

Expand Down

0 comments on commit c276b23

Please sign in to comment.