fix(fe): subscribe to capture-session store in components (was reading the store object)
`session.state` is a Svelte store; `$: state = session.state` bound the store object (not its value), so state.capture was undefined and cap.k threw on mount. Bind a local const to the store and use the $ prefix ($stateStore), and use get() in App.onPhotosReady. Verified in Chromium: hero -> batch -> sample uploads show thumbs.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import { get, writable } from 'svelte/store';
|
||||
import { apiFetch } from './lib/api';
|
||||
import type { SlabDraft, Photo, Taxonomy } from './lib/types';
|
||||
import { draft } from './lib/types';
|
||||
@@ -98,7 +98,7 @@
|
||||
const current = $slab;
|
||||
try {
|
||||
if (!current) {
|
||||
const s = captureSession.state;
|
||||
const s = get(captureSession.state);
|
||||
const results = s.capture.k === 'measure' ? s.capture.results : null;
|
||||
const d = results
|
||||
? draft({
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
export let session: CaptureSession;
|
||||
const dispatch = createEventDispatcher<{ continue: void }>();
|
||||
|
||||
$: state = session.state;
|
||||
const stateStore = session.state;
|
||||
$: state = $stateStore;
|
||||
$: items = session.lineup();
|
||||
$: measure = state.capture.k === 'measure' ? state.capture : null;
|
||||
$: results = measure?.results ?? null;
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
export let session: CaptureSession;
|
||||
const dispatch = createEventDispatcher<{ 'photos-ready': void }>();
|
||||
|
||||
$: state = session.state;
|
||||
const stateStore = session.state;
|
||||
$: state = $stateStore;
|
||||
$: cap = state.capture;
|
||||
$: kind = cap.k;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user