@@ -52,100 +52,100 @@ export function Compare(_: Record<string, never>): React.JSX.Element {
5252 ( comparison . result . to . length || comparison . result . from . length ) ;
5353
5454 useMessageFromExtension < ToCompareViewMessage > ( ( msg ) => {
55- switch ( msg . t ) {
56- case "setComparisonQueryInfo" :
57- setQueryInfo ( msg ) ;
58- break ;
59- case "setComparisons" :
60- setComparison ( msg ) ;
61- break ;
62- case "streamingComparisonSetup" :
63- setComparison ( null ) ;
64- streamingComparisonRef . current = msg ;
65- break ;
66- case "streamingComparisonAddResults" : {
67- const prev = streamingComparisonRef . current ;
68- if ( prev === null ) {
69- console . warn (
70- 'Received "streamingComparisonAddResults" before "streamingComparisonSetup"' ,
71- ) ;
72- break ;
73- }
55+ switch ( msg . t ) {
56+ case "setComparisonQueryInfo" :
57+ setQueryInfo ( msg ) ;
58+ break ;
59+ case "setComparisons" :
60+ setComparison ( msg ) ;
61+ break ;
62+ case "streamingComparisonSetup" :
63+ setComparison ( null ) ;
64+ streamingComparisonRef . current = msg ;
65+ break ;
66+ case "streamingComparisonAddResults" : {
67+ const prev = streamingComparisonRef . current ;
68+ if ( prev === null ) {
69+ console . warn (
70+ 'Received "streamingComparisonAddResults" before "streamingComparisonSetup"' ,
71+ ) ;
72+ break ;
73+ }
7474
75- if ( prev . id !== msg . id ) {
76- console . warn (
77- 'Received "streamingComparisonAddResults" with different id, ignoring' ,
78- ) ;
79- break ;
80- }
75+ if ( prev . id !== msg . id ) {
76+ console . warn (
77+ 'Received "streamingComparisonAddResults" with different id, ignoring' ,
78+ ) ;
79+ break ;
80+ }
8181
82- let result : QueryCompareResult ;
83- switch ( prev . result . kind ) {
84- case "raw" :
85- if ( msg . result . kind !== "raw" ) {
86- throw new Error (
87- "Streaming comparison: expected raw results, got interpreted results" ,
88- ) ;
89- }
90-
91- result = {
92- ...prev . result ,
93- from : [ ...prev . result . from , ...msg . result . from ] ,
94- to : [ ...prev . result . to , ...msg . result . to ] ,
95- } ;
96- break ;
97- case "interpreted" :
98- if ( msg . result . kind !== "interpreted" ) {
99- throw new Error (
100- "Streaming comparison: expected interpreted results, got raw results" ,
101- ) ;
102- }
103-
104- result = {
105- ...prev . result ,
106- from : [ ...prev . result . from , ...msg . result . from ] ,
107- to : [ ...prev . result . to , ...msg . result . to ] ,
108- } ;
109- break ;
110- default :
111- throw new Error ( "Unexpected comparison result kind" ) ;
82+ let result : QueryCompareResult ;
83+ switch ( prev . result . kind ) {
84+ case "raw" :
85+ if ( msg . result . kind !== "raw" ) {
86+ throw new Error (
87+ "Streaming comparison: expected raw results, got interpreted results" ,
88+ ) ;
11289 }
11390
114- streamingComparisonRef . current = {
115- ...prev ,
116- result,
91+ result = {
92+ ...prev . result ,
93+ from : [ ...prev . result . from , ...msg . result . from ] ,
94+ to : [ ...prev . result . to , ...msg . result . to ] ,
11795 } ;
118-
11996 break ;
120- }
121- case "streamingComparisonComplete" :
122- if ( streamingComparisonRef . current === null ) {
123- console . warn (
124- 'Received "streamingComparisonComplete" before "streamingComparisonSetup"' ,
97+ case "interpreted" :
98+ if ( msg . result . kind !== "interpreted" ) {
99+ throw new Error (
100+ "Streaming comparison: expected interpreted results, got raw results" ,
125101 ) ;
126- setComparison ( null ) ;
127- break ;
128102 }
129103
130- if ( streamingComparisonRef . current . id !== msg . id ) {
131- console . warn (
132- 'Received "streamingComparisonComplete" with different id, ignoring' ,
133- ) ;
134- break ;
135- }
136-
137- setComparison ( {
138- ...streamingComparisonRef . current ,
139- t : "setComparisons" ,
140- } ) ;
141- streamingComparisonRef . current = null ;
142- break ;
143- case "setUserSettings" :
144- setUserSettings ( msg . userSettings ) ;
104+ result = {
105+ ...prev . result ,
106+ from : [ ...prev . result . from , ...msg . result . from ] ,
107+ to : [ ...prev . result . to , ...msg . result . to ] ,
108+ } ;
145109 break ;
146110 default :
147- assertNever ( msg ) ;
111+ throw new Error ( "Unexpected comparison result kind" ) ;
148112 }
113+
114+ streamingComparisonRef . current = {
115+ ...prev ,
116+ result,
117+ } ;
118+
119+ break ;
120+ }
121+ case "streamingComparisonComplete" :
122+ if ( streamingComparisonRef . current === null ) {
123+ console . warn (
124+ 'Received "streamingComparisonComplete" before "streamingComparisonSetup"' ,
125+ ) ;
126+ setComparison ( null ) ;
127+ break ;
128+ }
129+
130+ if ( streamingComparisonRef . current . id !== msg . id ) {
131+ console . warn (
132+ 'Received "streamingComparisonComplete" with different id, ignoring' ,
133+ ) ;
134+ break ;
135+ }
136+
137+ setComparison ( {
138+ ...streamingComparisonRef . current ,
139+ t : "setComparisons" ,
140+ } ) ;
141+ streamingComparisonRef . current = null ;
142+ break ;
143+ case "setUserSettings" :
144+ setUserSettings ( msg . userSettings ) ;
145+ break ;
146+ default :
147+ assertNever ( msg ) ;
148+ }
149149 } , [ ] ) ;
150150
151151 if ( ! queryInfo || ! comparison ) {
0 commit comments