(props: {
issue: Accessor<CameraPreviewIssue | null>;
})
| 224 | } |
| 225 | |
| 226 | function NativeCameraPreviewPage(props: { |
| 227 | issue: Accessor<CameraPreviewIssue | null>; |
| 228 | }) { |
| 229 | const isCameraOnlyMode = () => getCameraOnlyMode(); |
| 230 | |
| 231 | const [state, setState] = makePersisted( |
| 232 | createStore<CameraWindowState>(getDefaultCameraWindowState()), |
| 233 | { name: CAMERA_WINDOW_STATE_STORAGE_KEY }, |
| 234 | ); |
| 235 | |
| 236 | const centerCameraOnlyWindow = () => { |
| 237 | ignoreMoveFor(1500); |
| 238 | void commands.ignoreCameraWindowPosition(1500); |
| 239 | void centerCurrentWindow(); |
| 240 | setTimeout(() => { |
| 241 | void centerCurrentWindow(); |
| 242 | }, 120); |
| 243 | }; |
| 244 | |
| 245 | onMount(() => { |
| 246 | if (isCameraOnlyMode()) { |
| 247 | centerCameraOnlyWindow(); |
| 248 | } |
| 249 | |
| 250 | const handleVisibilityChange = () => { |
| 251 | if (!document.hidden) { |
| 252 | setTimeout(() => { |
| 253 | commands.refreshCameraFeed().catch(() => {}); |
| 254 | }, 500); |
| 255 | } |
| 256 | }; |
| 257 | document.addEventListener("visibilitychange", handleVisibilityChange); |
| 258 | onCleanup(() => |
| 259 | document.removeEventListener("visibilitychange", handleVisibilityChange), |
| 260 | ); |
| 261 | }); |
| 262 | |
| 263 | createEffect( |
| 264 | on( |
| 265 | () => isCameraOnlyMode(), |
| 266 | (isCameraOnly, wasCameraOnly) => { |
| 267 | if (isCameraOnly && !wasCameraOnly) { |
| 268 | centerCameraOnlyWindow(); |
| 269 | } |
| 270 | }, |
| 271 | ), |
| 272 | ); |
| 273 | |
| 274 | createEffect(() => { |
| 275 | let currentSize = state.size as number | string; |
| 276 | if (typeof currentSize !== "number" || Number.isNaN(currentSize)) { |
| 277 | currentSize = |
| 278 | currentSize === "lg" ? CAMERA_PRESET_LARGE : CAMERA_DEFAULT_SIZE; |
| 279 | setState("size", currentSize); |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | const clampedSize = Math.max( |
nothing calls this directly
no test coverage detected