( ref: ScopedThreadRef, update: (current: ThreadPreviewState) => ThreadPreviewState, )
| 92 | } |
| 93 | |
| 94 | function updateThreadPreviewState( |
| 95 | ref: ScopedThreadRef, |
| 96 | update: (current: ThreadPreviewState) => ThreadPreviewState, |
| 97 | ): void { |
| 98 | const threadKey = scopedThreadKey(ref); |
| 99 | const atom = previewStateAtom(threadKey); |
| 100 | let nextState = appAtomRegistry.get(atom); |
| 101 | const changed = appAtomRegistry.modify(atom, (current) => { |
| 102 | nextState = update(current); |
| 103 | return [nextState !== current, nextState]; |
| 104 | }); |
| 105 | if (!changed) return; |
| 106 | changedPreviewThreadKeys.add(threadKey); |
| 107 | syncActivePreviewThread(threadKey, nextState); |
| 108 | } |
| 109 | |
| 110 | const dedupeRecentUrls = (existing: string[], url: string): string[] => { |
| 111 | const next = [url, ...existing.filter((entry) => entry !== url)]; |
no test coverage detected