| author | |
| committer | |
| log | 43700b83e73fca3af7b63769876c409b5c6f5a3f |
| tree | 870ed159eabc11d0f22ee69c649292f47221c9e0 |
| parent | 160e337a5c521bcaae94b386d22226f32242fdd0 |
| signature | Signed by PGP key B5690EEEBB952194 |
2 files changed, 2 insertions(+), 15 deletions(-)
apps/web/src/previewStateStore.test.ts+2-2| ... | ... | @@ -19,10 +19,10 @@ import { |
| 19 | 19 | reconcilePreviewServerSessions, |
| 20 | 20 | rememberPreviewUrl, |
| 21 | 21 | resetPreviewStateForTests, |
| 22 | subscribeThreadPreviewState, | |
| 23 | 22 | setActivePreviewTab, |
| 24 | 23 | updatePreviewServerSnapshot, |
| 25 | 24 | } from "./previewStateStore"; |
| 25 | import { appAtomRegistry } from "./rpc/atomRegistry"; | |
| 26 | 26 | |
| 27 | 27 | const environmentId = "env-1" as EnvironmentId; |
| 28 | 28 | const ref = scopeThreadRef(environmentId, ThreadId.make("thread-1")); |
| ... | ... | @@ -352,7 +352,7 @@ describe("previewStateStore (single-tab)", () => { |
| 352 | 352 | }, |
| 353 | 353 | }; |
| 354 | 354 | let updateCount = 0; |
| 355 | const unsubscribe = subscribeThreadPreviewState(ref, () => { | |
| 355 | const unsubscribe = appAtomRegistry.subscribe(previewStateAtom(scopedThreadKey(ref)), () => { | |
| 356 | 356 | updateCount += 1; |
| 357 | 357 | }); |
| 358 | 358 |
apps/web/src/previewStateStore.ts-13| ... | ... | @@ -173,19 +173,6 @@ export function readThreadPreviewState(ref: ScopedThreadRef): ThreadPreviewState |
| 173 | 173 | return appAtomRegistry.get(previewStateAtom(scopedThreadKey(ref))); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | export function subscribeThreadPreviewState( | |
| 177 | ref: ScopedThreadRef, | |
| 178 | listener: (state: ThreadPreviewState, previous: ThreadPreviewState) => void, | |
| 179 | ): () => void { | |
| 180 | const atom = previewStateAtom(scopedThreadKey(ref)); | |
| 181 | let previous = appAtomRegistry.get(atom); | |
| 182 | return appAtomRegistry.subscribe(atom, (state) => { | |
| 183 | const prior = previous; | |
| 184 | previous = state; | |
| 185 | listener(state, prior); | |
| 186 | }); | |
| 187 | } | |
| 188 | ||
| 189 | 176 | export function applyPreviewServerEvent(ref: ScopedThreadRef, event: PreviewEvent): void { |
| 190 | 177 | updateThreadPreviewState(ref, (current) => { |
| 191 | 178 | if (current.serverEpoch !== null && event.serverEpoch !== current.serverEpoch) return current; |