File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @puzzle-js/client-lib" ,
33 "main" : " dist/index.js" ,
4- "version" : " 1.2.0 " ,
4+ "version" : " 1.2.1 " ,
55 "author" : " <emre.kul@trendyol.com>" ,
66 "license" : " MIT" ,
77 "repository" : {
Original file line number Diff line number Diff line change @@ -109,10 +109,35 @@ export class Core extends Module {
109109 . get ( key , ( gunResponse : any ) => {
110110 if ( gunResponse . err || ! gunResponse . put ) {
111111 this . fetchGatewayFragment ( fragment )
112- . then ( gatewayResponse => Core . gun . get ( key ) . put ( gatewayResponse ) ) ;
112+ . then ( gatewayResponse => Core . gun . get ( key ) . put ( {
113+ ...gatewayResponse ,
114+ ...gatewayResponse . $headers ? {
115+ $headers : JSON . stringify ( gatewayResponse . $headers )
116+ } : { } ,
117+ ...gatewayResponse . $model ? {
118+ $model : JSON . stringify ( gatewayResponse . $model )
119+ } : { } ,
120+ } ) ) ;
113121 }
114122 } )
115- . on ( ( gunResponse : any ) => this . asyncRenderResponse ( fragment , gunResponse ) ) ;
123+ . on ( ( gunResponse : any ) => {
124+ try {
125+ gunResponse . $model = JSON . parse ( gunResponse . $model ) ;
126+ gunResponse . $headers = JSON . parse ( gunResponse . $headers ) ;
127+ this . asyncRenderResponse ( fragment , gunResponse ) ;
128+ } catch ( e ) {
129+ this . fetchGatewayFragment ( fragment )
130+ . then ( gatewayResponse => Core . gun . get ( key ) . put ( {
131+ ...gatewayResponse ,
132+ ...gatewayResponse . $headers ? {
133+ $headers : JSON . stringify ( gatewayResponse . $headers )
134+ } : { } ,
135+ ...gatewayResponse . $model ? {
136+ $model : JSON . stringify ( gatewayResponse . $model )
137+ } : { } ,
138+ } ) ) ;
139+ }
140+ } ) ;
116141 }
117142
118143 private static fetchGatewayFragment ( fragment : IPageFragmentConfig ) {
You can’t perform that action at this time.
0 commit comments