@@ -42,23 +42,27 @@ export function CompositeEntitiesByKind<P, T>(
42
42
) ;
43
43
}
44
44
45
- Promise . all ( promises ) . then ( ( result ) => {
46
- const entitiesOptions = result [ 0 ] ?? OrderedSet ( [ ] ) ;
47
- const selectedEntitiesOptions = result [ 1 ] ?? OrderedSet ( [ ] ) ;
45
+ Promise . all ( promises )
46
+ . then ( ( result ) => {
47
+ const entitiesOptions = result [ 0 ] ?? OrderedSet ( [ ] ) ;
48
+ const selectedEntitiesOptions = result [ 1 ] ?? OrderedSet ( [ ] ) ;
48
49
49
- dispatch ( {
50
- type : 'UPDATE_SELECTED_ENTITIES_OPTIONS' ,
51
- selectedEntitiesOptions : selectedEntitiesOptions ,
52
- } ) ;
53
- dispatch ( {
54
- type : 'UPDATE_CONTEXUAL_ENTITIES_OPTIONS' ,
55
- contextualEntitiesOptions : entitiesOptions ,
56
- } ) ;
57
- dispatch ( {
58
- type : 'UPDATE_ENTITIES_OPTIONS' ,
59
- entitiesOptions : entitiesOptions ,
50
+ dispatch ( {
51
+ type : 'UPDATE_SELECTED_ENTITIES_OPTIONS' ,
52
+ selectedEntitiesOptions,
53
+ } ) ;
54
+ dispatch ( {
55
+ type : 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS' ,
56
+ contextualEntitiesOptions : entitiesOptions ,
57
+ } ) ;
58
+ dispatch ( {
59
+ type : 'UPDATE_ENTITIES_OPTIONS' ,
60
+ entitiesOptions,
61
+ } ) ;
62
+ } )
63
+ . catch ( ( error ) => {
64
+ console . warn ( `Composite Entities by Kind: ${ error } ` ) ;
60
65
} ) ;
61
- } ) ;
62
66
// eslint-disable-next-line react-hooks/exhaustive-deps
63
67
} , [ ] ) ;
64
68
@@ -118,19 +122,25 @@ export function CompositeEntitiesByKind<P, T>(
118
122
} ) ,
119
123
] ) ;
120
124
121
- Promise . all ( promises ) . then ( ( result ) => {
122
- const entitiesOptions = result [ 0 ] ?? OrderedSet ( [ ] ) ;
123
- const selectedEntitiesOptions = result [ 1 ] ?? OrderedSet ( [ ] ) ;
125
+ Promise . all ( promises )
126
+ . then ( ( result ) => {
127
+ const entitiesOptions = result [ 0 ] ?? OrderedSet ( [ ] ) ;
128
+ const selectedEntitiesOptions = result [ 1 ] ?? OrderedSet ( [ ] ) ;
124
129
125
- dispatch ( {
126
- type : 'UPDATE_SELECTED_ENTITIES_OPTIONS' ,
127
- selectedEntitiesOptions,
128
- } ) ;
129
- dispatch ( {
130
- type : 'UPDATE_ENTITIES_OPTIONS' ,
131
- entitiesOptions,
130
+ dispatch ( {
131
+ type : 'UPDATE_SELECTED_ENTITIES_OPTIONS' ,
132
+ selectedEntitiesOptions,
133
+ } ) ;
134
+ dispatch ( {
135
+ type : 'UPDATE_ENTITIES_OPTIONS' ,
136
+ entitiesOptions,
137
+ } ) ;
138
+ } )
139
+ . catch ( ( error ) => {
140
+ console . warn (
141
+ `Composite Entities by Kind - on Change Entities: ${ error } `
142
+ ) ;
132
143
} ) ;
133
- } ) ;
134
144
} ;
135
145
136
146
const onChangeKind = ( kind : T ) => {
@@ -145,7 +155,7 @@ export function CompositeEntitiesByKind<P, T>(
145
155
} )
146
156
. then ( ( result ) => {
147
157
dispatch ( {
148
- type : 'UPDATE_CONTEXUAL_ENTITIES_OPTIONS ' ,
158
+ type : 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS ' ,
149
159
contextualEntitiesOptions : result ,
150
160
} ) ;
151
161
dispatch ( {
@@ -156,6 +166,11 @@ export function CompositeEntitiesByKind<P, T>(
156
166
type : 'UPDATE_SELECTED_ENTITIES_OPTIONS' ,
157
167
selectedEntitiesOptions : entities ,
158
168
} ) ;
169
+ } )
170
+ . catch ( ( error ) => {
171
+ console . warn (
172
+ `Composite Entities by Kind - on Change Kind: ${ error } `
173
+ ) ;
159
174
} ) ;
160
175
} ;
161
176
@@ -177,30 +192,24 @@ export function CompositeEntitiesByKind<P, T>(
177
192
onChange : onChangeKind ,
178
193
} ;
179
194
180
- return (
181
- < >
182
- { props . children (
183
- entities ,
184
- kind ,
185
- // TODO Add debouncing to the `search` callback
186
- ( phrase : SearchPhrase ) => {
187
- const _phrase = extractPhrase ( phrase ) ;
188
-
189
- setSearchPhrase ( _phrase ) ;
190
-
191
- if ( _phrase === '' ) {
192
- dispatch ( {
193
- type : 'UPDATE_ENTITIES_OPTIONS' ,
194
- entitiesOptions : state . contexualEntitiesOptions ,
195
- } ) ;
196
- return ;
197
- }
198
-
199
- searchEntitiesByKind ( _phrase , entitiesAndKind . kind ) ;
200
- }
201
- ) }
202
- </ >
203
- ) ;
195
+ // TODO Add debouncing to the `search` callback
196
+ const search = ( phrase : SearchPhrase ) => {
197
+ const _phrase = extractPhrase ( phrase ) ;
198
+
199
+ setSearchPhrase ( _phrase ) ;
200
+
201
+ if ( _phrase === '' ) {
202
+ dispatch ( {
203
+ type : 'UPDATE_ENTITIES_OPTIONS' ,
204
+ entitiesOptions : state . contexualEntitiesOptions ,
205
+ } ) ;
206
+ return ;
207
+ }
208
+
209
+ searchEntitiesByKind ( _phrase , entitiesAndKind . kind ) ;
210
+ } ;
211
+
212
+ return < > { props . children ( entities , kind , search ) } </ > ;
204
213
}
205
214
206
215
function extractPhrase ( phraseOrEvent : SearchPhrase ) : string {
0 commit comments