| ... | @@ -17,11 +17,10 @@ export interface ThreadSearchResultsState { | ... | @@ -17,11 +17,10 @@ export interface ThreadSearchResultsState { |
| 17 | readonly isLoading: boolean; | 17 | readonly isLoading: boolean; |
| 18 | } | 18 | } |
| 19 | | 19 | |
| 20 | const ThreadSearchKey = Schema.Tuple([ | 20 | const ThreadSearchKey = Schema.fromJsonString( |
| 21 | Schema.Array(EnvironmentId), | 21 | Schema.Tuple([Schema.Array(EnvironmentId), OrchestrationSearchThreadsInput.fields.query]), |
| 22 | OrchestrationSearchThreadsInput.fields.query, | 22 | ); |
| 23 | ]); | 23 | const decodeThreadSearchKey = Schema.decodeUnknownOption(ThreadSearchKey); |
| 24 | const decodeThreadSearchKey = Schema.decodeUnknownSync(ThreadSearchKey); | | |
| 25 | | 24 | |
| 26 | export function makeThreadSearchKey( | 25 | export function makeThreadSearchKey( |
| 27 | environmentIds: ReadonlyArray<EnvironmentId>, | 26 | environmentIds: ReadonlyArray<EnvironmentId>, |
| ... | @@ -34,7 +33,7 @@ export function makeThreadSearchKey( | ... | @@ -34,7 +33,7 @@ export function makeThreadSearchKey( |
| 34 | } | 33 | } |
| 35 | | 34 | |
| 36 | function parseThreadSearchKey(key: string) { | 35 | function parseThreadSearchKey(key: string) { |
| 37 | return decodeThreadSearchKey(JSON.parse(key)); | 36 | return decodeThreadSearchKey(key); |
| 38 | } | 37 | } |
| 39 | | 38 | |
| 40 | export function threadSearchMatchKey( | 39 | export function threadSearchMatchKey( |
| ... | @@ -44,9 +43,9 @@ export function threadSearchMatchKey( | ... | @@ -44,9 +43,9 @@ export function threadSearchMatchKey( |
| 44 | } | 43 | } |
| 45 | | 44 | |
| 46 | /** | 45 | /** |
| 47 | * Combines one search query atom per environment. Failed and disconnected | 46 | * Combines one search query atom per environment. Invalid search keys, failed |
| 48 | * environments contribute no content matches, preserving local title search | 47 | * requests, and disconnected environments contribute no content matches, |
| 49 | * as the compatibility fallback. | 48 | * preserving local title search as the compatibility fallback. |
| 50 | */ | 49 | */ |
| 51 | export function createThreadSearchResultsAtomFamily<E>(options: { | 50 | export function createThreadSearchResultsAtomFamily<E>(options: { |
| 52 | readonly getSearchAtom: ( | 51 | readonly getSearchAtom: ( |
| ... | @@ -57,7 +56,12 @@ export function createThreadSearchResultsAtomFamily<E>(options: { | ... | @@ -57,7 +56,12 @@ export function createThreadSearchResultsAtomFamily<E>(options: { |
| 57 | }) { | 56 | }) { |
| 58 | return Atom.family((key: string) => | 57 | return Atom.family((key: string) => |
| 59 | Atom.make((get): ThreadSearchResultsState => { | 58 | Atom.make((get): ThreadSearchResultsState => { |
| 60 | const [environmentIds, query] = parseThreadSearchKey(key); | 59 | const parsedKey = parseThreadSearchKey(key); |
| | 60 | if (Option.isNone(parsedKey)) { |
| | 61 | return { matches: [], isLoading: false }; |
| | 62 | } |
| | 63 | |
| | 64 | const [environmentIds, query] = parsedKey.value; |
| 61 | const matches: EnvironmentThreadSearchMatch[] = []; | 65 | const matches: EnvironmentThreadSearchMatch[] = []; |
| 62 | let isLoading = false; | 66 | let isLoading = false; |
| 63 | | 67 | |