diff --git a/src/components/camera/CameraWidgetView.tsx b/src/components/camera/CameraWidgetView.tsx index d4221e8..5df8c5e 100644 --- a/src/components/camera/CameraWidgetView.tsx +++ b/src/components/camera/CameraWidgetView.tsx @@ -14,7 +14,7 @@ export const CameraWidgetView: FC<{}> = props => { const [ mode, setMode ] = useState(MODE_NONE); const [ base64Url, setSavedPictureUrl ] = useState(null); - const { availableEffects = [], selectedPictureIndex = -1, cameraRoll = [], setCameraRoll = null, myLevel = 0, price = { credits: 0, duckets: 0, publishDucketPrice: 0 } } = useCamera(); + const { availableEffects = [], selectedPictureIndex = -1, setSelectedPictureIndex = null, cameraRoll = [], setCameraRoll = null, myLevel = 0, price = { credits: 0, duckets: 0, publishDucketPrice: 0 } } = useCamera(); const processAction = (type: string) => @@ -28,14 +28,11 @@ export const CameraWidgetView: FC<{}> = props => setMode(MODE_EDITOR); return; case 'delete': - setCameraRoll(prevValue => - { - const clone = [ ...prevValue ]; - - clone.splice(selectedPictureIndex, 1); - - return clone; - }); + setCameraRoll(prevValue => prevValue.filter((_, index) => (index !== selectedPictureIndex))); + // Without this the index keeps pointing at the slot the deleted + // photo vacated (now a different picture, or past the end) — move + // the selection back one so the preview stays in sync. + if(setSelectedPictureIndex) setSelectedPictureIndex(prev => (prev > 0 ? (prev - 1) : 0)); return; case 'editor_cancel': setMode(MODE_CAPTURE); diff --git a/src/components/camera/views/CameraWidgetCaptureView.tsx b/src/components/camera/views/CameraWidgetCaptureView.tsx index 45657e0..56b06aa 100644 --- a/src/components/camera/views/CameraWidgetCaptureView.tsx +++ b/src/components/camera/views/CameraWidgetCaptureView.tsx @@ -46,9 +46,11 @@ export const CameraWidgetCaptureView: FC = props = if(clone.length >= CAMERA_ROLL_LIMIT) { + // Roll is full — block the shot (the old code did clone.pop(), which + // discarded the NEWEST photo and pinned the roll at the limit forever). simpleAlert(LocalizeText('camera.full.body')); - clone.pop(); + return; } PlaySound(SoundNames.CAMERA_SHUTTER);