Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
pkolt committed Jan 24, 2024
1 parent 9323ac4 commit b4d1e02
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/components/PixelEditor/BitmapView/index.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.container {
cursor: pointer;
}
cursor: pointer;
}
25 changes: 14 additions & 11 deletions src/components/PixelEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@ export const PixelEditor = ({ bitmapEntity, onChange }: PixelEditorProps): JSX.E
const [bitmap, setBitmap] = useState(Bitmap.fromArray(bitmapEntity.width, bitmapEntity.height, bitmapEntity.data));
const isEmptyBitmap = useMemo(() => bitmap.isEmpty(), [bitmap]);

const handleChangeBitmap = useCallback((value: Bitmap) => {
setBitmap(value);
const handleChangeBitmap = useCallback(
(value: Bitmap) => {
setBitmap(value);

// Reset previous timer
if (refAutoSaveTimeout.current) {
clearTimeout(refAutoSaveTimeout.current);
refAutoSaveTimeout.current = null;
}
// Reset previous timer
if (refAutoSaveTimeout.current) {
clearTimeout(refAutoSaveTimeout.current);
refAutoSaveTimeout.current = null;
}

refAutoSaveTimeout.current = setTimeout(() => {
onChange(bitmap.toJSON());
}, AUTO_SAVE_TIMEOUT_MS);
}, [bitmap, onChange]);
refAutoSaveTimeout.current = setTimeout(() => {
onChange(bitmap.toJSON());
}, AUTO_SAVE_TIMEOUT_MS);
},
[bitmap, onChange],
);

const resetBitmap = useCallback(() => {
bitmap.reset();
Expand Down
2 changes: 1 addition & 1 deletion src/store/bitmaps/useBitmapsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useBitmapStore = create<BitmapsState>()(
// ...
}
return persistedState as BitmapsState;
}
},
},
),
);

0 comments on commit b4d1e02

Please sign in to comment.