MCPcopy
hub / github.com/CapSoftware/Cap / LegacyCameraPreviewPage

Function LegacyCameraPreviewPage

apps/desktop/src/routes/camera.tsx:356–797  ·  view source on GitHub ↗
(props: {
	issue: Accessor<CameraPreviewIssue | null>;
})

Source from the content-addressed store, hash-verified

354// Legacy stuff below
355
356function LegacyCameraPreviewPage(props: {
357 issue: Accessor<CameraPreviewIssue | null>;
358}) {
359 const isCameraOnlyMode = () => getCameraOnlyMode();
360
361 const [state, setState] = makePersisted(
362 createStore<CameraWindowState>(getDefaultCameraWindowState()),
363 { name: CAMERA_WINDOW_STATE_STORAGE_KEY },
364 );
365
366 const centerCameraOnlyWindow = () => {
367 ignoreMoveFor(1500);
368 void commands.ignoreCameraWindowPosition(1500);
369 void centerCurrentWindow();
370 setTimeout(() => {
371 void centerCurrentWindow();
372 }, 120);
373 };
374
375 onMount(() => {
376 if (isCameraOnlyMode()) {
377 centerCameraOnlyWindow();
378 }
379 });
380
381 createEffect(
382 on(
383 () => isCameraOnlyMode(),
384 (isCameraOnly, wasCameraOnly) => {
385 if (isCameraOnly && !wasCameraOnly) {
386 centerCameraOnlyWindow();
387 }
388 },
389 ),
390 );
391
392 createEffect(() => {
393 const currentSize = state.size as number | string;
394 if (typeof currentSize !== "number" || Number.isNaN(currentSize)) {
395 setState(
396 "size",
397 currentSize === "lg" ? CAMERA_PRESET_LARGE : CAMERA_DEFAULT_SIZE,
398 );
399 }
400 });
401
402 createEffect(() => {
403 commands.setCameraPreviewState({
404 size: state.size,
405 shape: state.shape,
406 mirrored: state.mirrored,
407 background_blur: normalizeBackgroundBlurMode(state.backgroundBlur),
408 });
409 });
410
411 const [hasPositioned, setHasPositioned] = createSignal(isCameraOnlyMode());
412
413 const [hasFrame, setHasFrame] = createSignal(false);

Callers

nothing calls this directly

Calls 15

cameraPreviewDimensionsFunction · 0.90
cameraBorderRadiusFunction · 0.90
createStoreFunction · 0.85
isCameraOnlyModeFunction · 0.85
centerCameraOnlyWindowFunction · 0.85
onFunction · 0.85
startSocketFunction · 0.85
stopSocketFunction · 0.85
ignoreMoveForFunction · 0.85

Tested by

no test coverage detected