Skip to content

Commit

Permalink
avoid null issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mapmeld committed Nov 11, 2024
1 parent 11ad326 commit 9cff4fb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/src/app/store/mapStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,20 @@ export const useMapStore = create(
),
{
diff: (pastState: Partial<MapStore>, currentState: Partial<MapStore>) => {
currentState.zoneAssignments.keys().forEach((geoid) => {
if (!currentState.zoneAssignments || !pastState.zoneAssignments) return pastState;
for (const geoid of currentState.zoneAssignments.keys()) {
if (!pastState.zoneAssignments.has(geoid)) {
pastState.zoneAssignments.set(geoid, null);
}
});
}
return pastState as Partial<MapStore>;
},
equality: (pastState, currentState) => {
return (pastState.zoneAssignments === currentState.zoneAssignments) &&
(pastState.zoneAssignments.size === currentState.zoneAssignments.size);
},
limit: 7,
// @ts-ignore: save only partial store
partialize: (state: Partial<MapStore>) => {
const { zoneAssignments } = state;
return { zoneAssignments } as Partial<MapStore>;
Expand Down

0 comments on commit 9cff4fb

Please sign in to comment.