File tree Expand file tree Collapse file tree 6 files changed +20
-11
lines changed
runtime/src/runtime/hooks Expand file tree Collapse file tree 6 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @ensembleui/react-framework " : patch
3+ " @ensembleui/react-runtime " : patch
4+ ---
5+
6+ fix ensemble api response mapping with screendata
Original file line number Diff line number Diff line change @@ -39,8 +39,7 @@ export const invokeAPI = async (
3939 // Now, because the API exists, set its state to loading
4040 set ( update , api . name , {
4141 isLoading : true ,
42- isError : false ,
43- isSuccess : false ,
42+ statusCode : undefined ,
4443 } ) ;
4544 setter ( screenDataAtom , update ) ;
4645 }
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ export const useScreenContext = ():
110110 const screenContext = useAtomValue ( screenAtom ) ;
111111 const setDataAtom = useSetAtom ( screenDataAtom ) ;
112112 const setData = useCallback (
113- ( name : string , response : Response | WebSocketConnection ) => {
113+ ( name : string , response : Partial < Response > | WebSocketConnection ) => {
114114 const data = screenContext . data ;
115115 data [ name ] = response ;
116116 setDataAtom ( clone ( data ) ) ;
Original file line number Diff line number Diff line change @@ -16,7 +16,10 @@ export const useScreenData = (): {
1616 apis ?: EnsembleAPIModel [ ] ;
1717 sockets ?: EnsembleSocketModel [ ] ;
1818 data : ScreenContextData ;
19- setData : ( name : string , response : Response | WebSocketConnection ) => void ;
19+ setData : (
20+ name : string ,
21+ response : Partial < Response > | WebSocketConnection ,
22+ ) => void ;
2023 mockResponses : {
2124 [ apiName : string ] : EnsembleMockResponse | string | undefined ;
2225 } ;
@@ -41,7 +44,7 @@ export const useScreenData = (): {
4144 const mockResponses = useEvaluate ( apiMockResponses ) ;
4245
4346 const setData = useCallback (
44- ( name : string , response : Response | WebSocketConnection ) => {
47+ ( name : string , response : Partial < Response > | WebSocketConnection ) => {
4548 if ( isEqual ( data [ name ] , response ) ) {
4649 return ;
4750 }
Original file line number Diff line number Diff line change @@ -15,12 +15,15 @@ export interface ScreenContextDefinition {
1515}
1616
1717export interface ScreenContextData {
18- [ key : string ] : Response | WebSocketConnection ;
18+ [ key : string ] : Partial < Response > | WebSocketConnection ;
1919}
2020
2121export interface ScreenContextActions {
2222 setWidget : ( id : string , state : WidgetState ) => void ;
23- setData : ( name : string , response : Response | WebSocketConnection ) => void ;
23+ setData : (
24+ name : string ,
25+ response : Partial < Response > | WebSocketConnection ,
26+ ) => void ;
2427 setCustom : ( id : string , data : unknown ) => void ;
2528}
2629
Original file line number Diff line number Diff line change @@ -195,15 +195,13 @@ export const useInvokeAPI: EnsembleActionHook<InvokeAPIAction> = (action) => {
195195 // Set initial loading state
196196 setData ( currentApi . name , {
197197 isLoading : true ,
198- isSuccess : false ,
199- isError : false ,
198+ statusCode : undefined ,
200199 } ) ;
201200
202201 if ( action . id ) {
203202 setData ( action . id , {
204203 isLoading : true ,
205- isSuccess : false ,
206- isError : false ,
204+ statusCode : undefined ,
207205 } ) ;
208206 }
209207
You can’t perform that action at this time.
0 commit comments