mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
Merge pull request #243 from simoleo89/fix/camera-bugs
fix(camera): delete-index reset & full-roll discard
This commit is contained in:
@@ -14,7 +14,7 @@ export const CameraWidgetView: FC<{}> = props =>
|
|||||||
{
|
{
|
||||||
const [ mode, setMode ] = useState<number>(MODE_NONE);
|
const [ mode, setMode ] = useState<number>(MODE_NONE);
|
||||||
const [ base64Url, setSavedPictureUrl ] = useState<string>(null);
|
const [ base64Url, setSavedPictureUrl ] = useState<string>(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) =>
|
const processAction = (type: string) =>
|
||||||
@@ -28,14 +28,11 @@ export const CameraWidgetView: FC<{}> = props =>
|
|||||||
setMode(MODE_EDITOR);
|
setMode(MODE_EDITOR);
|
||||||
return;
|
return;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
setCameraRoll(prevValue =>
|
setCameraRoll(prevValue => prevValue.filter((_, index) => (index !== selectedPictureIndex)));
|
||||||
{
|
// Without this the index keeps pointing at the slot the deleted
|
||||||
const clone = [ ...prevValue ];
|
// photo vacated (now a different picture, or past the end) — move
|
||||||
|
// the selection back one so the preview stays in sync.
|
||||||
clone.splice(selectedPictureIndex, 1);
|
if(setSelectedPictureIndex) setSelectedPictureIndex(prev => (prev > 0 ? (prev - 1) : 0));
|
||||||
|
|
||||||
return clone;
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
case 'editor_cancel':
|
case 'editor_cancel':
|
||||||
setMode(MODE_CAPTURE);
|
setMode(MODE_CAPTURE);
|
||||||
|
|||||||
@@ -46,9 +46,11 @@ export const CameraWidgetCaptureView: FC<CameraWidgetCaptureViewProps> = props =
|
|||||||
|
|
||||||
if(clone.length >= CAMERA_ROLL_LIMIT)
|
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'));
|
simpleAlert(LocalizeText('camera.full.body'));
|
||||||
|
|
||||||
clone.pop();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaySound(SoundNames.CAMERA_SHUTTER);
|
PlaySound(SoundNames.CAMERA_SHUTTER);
|
||||||
|
|||||||
Reference in New Issue
Block a user