Skip to content

Commit 87ffbc2

Browse files
Merge pull request #1410 from p-delorme/fix-camera-init
Handles legacy camera size (strings)
2 parents 3cb22ad + 0e16f7c commit 87ffbc2

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

apps/desktop/src/routes/camera.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,20 @@ function NativeCameraPreviewPage(props: { disconnected: Accessor<boolean> }) {
9696
});
9797

9898
createEffect(() => {
99+
// Support for legacy size strings.
100+
let currentSize = state.size as number | string;
101+
if (typeof currentSize !== "number" || Number.isNaN(currentSize)) {
102+
currentSize =
103+
currentSize === "lg" ? CAMERA_PRESET_LARGE : CAMERA_DEFAULT_SIZE;
104+
setState("size", currentSize);
105+
return;
106+
}
107+
99108
const clampedSize = Math.max(
100109
CAMERA_MIN_SIZE,
101-
Math.min(CAMERA_MAX_SIZE, state.size),
110+
Math.min(CAMERA_MAX_SIZE, currentSize),
102111
);
103-
if (clampedSize !== state.size) {
112+
if (clampedSize !== currentSize) {
104113
setState("size", clampedSize);
105114
}
106115
commands.setCameraPreviewState(state);
@@ -285,6 +294,17 @@ function LegacyCameraPreviewPage(props: { disconnected: Accessor<boolean> }) {
285294
{ name: "cameraWindowState" },
286295
);
287296

297+
createEffect(() => {
298+
// Support for legacy size strings.
299+
const currentSize = state.size as number | string;
300+
if (typeof currentSize !== "number" || Number.isNaN(currentSize)) {
301+
setState(
302+
"size",
303+
currentSize === "lg" ? CAMERA_PRESET_LARGE : CAMERA_DEFAULT_SIZE,
304+
);
305+
}
306+
});
307+
288308
const [isResizing, setIsResizing] = createSignal(false);
289309
const [resizeStart, setResizeStart] = createSignal({
290310
size: 0,

0 commit comments

Comments
 (0)