@@ -378,88 +378,88 @@ class LiveQueryClient {
378378 installationId : data . installationId ,
379379 } ;
380380 switch ( data . op ) {
381- case OP_EVENTS . CONNECTED :
382- if ( this . state === CLIENT_STATE . RECONNECTING ) {
383- this . resubscribe ( ) ;
384- }
385- this . emit ( CLIENT_EMMITER_TYPES . OPEN ) ;
386- this . id = data . clientId ;
387- this . connectPromise . resolve ( ) ;
388- this . state = CLIENT_STATE . CONNECTED ;
389- break ;
390- case OP_EVENTS . SUBSCRIBED :
391- if ( subscription ) {
392- this . attempts = 1 ;
393- subscription . subscribed = true ;
394- subscription . subscribePromise . resolve ( ) ;
395- setTimeout ( ( ) => subscription . emit ( SUBSCRIPTION_EMMITER_TYPES . OPEN , response ) , 200 ) ;
396- }
397- break ;
398- case OP_EVENTS . ERROR : {
399- const parseError = new ParseError ( data . code , data . error ) ;
400- if ( ! this . id ) {
401- this . connectPromise . reject ( parseError ) ;
402- this . state = CLIENT_STATE . DISCONNECTED ;
403- }
404- if ( data . requestId ) {
381+ case OP_EVENTS . CONNECTED :
382+ if ( this . state === CLIENT_STATE . RECONNECTING ) {
383+ this . resubscribe ( ) ;
384+ }
385+ this . emit ( CLIENT_EMMITER_TYPES . OPEN ) ;
386+ this . id = data . clientId ;
387+ this . connectPromise . resolve ( ) ;
388+ this . state = CLIENT_STATE . CONNECTED ;
389+ break ;
390+ case OP_EVENTS . SUBSCRIBED :
405391 if ( subscription ) {
406- subscription . subscribePromise . reject ( parseError ) ;
407- setTimeout ( ( ) => subscription . emit ( SUBSCRIPTION_EMMITER_TYPES . ERROR , data . error ) , 200 ) ;
392+ this . attempts = 1 ;
393+ subscription . subscribed = true ;
394+ subscription . subscribePromise . resolve ( ) ;
395+ setTimeout ( ( ) => subscription . emit ( SUBSCRIPTION_EMMITER_TYPES . OPEN , response ) , 200 ) ;
408396 }
409- } else {
410- this . emit ( CLIENT_EMMITER_TYPES . ERROR , data . error ) ;
411- }
412- if ( data . error === 'Additional properties not allowed' ) {
413- this . additionalProperties = false ;
414- }
415- if ( data . reconnect ) {
416- this . _handleReconnect ( ) ;
417- }
418- break ;
419- }
420- case OP_EVENTS . UNSUBSCRIBED : {
421- if ( subscription ) {
422- this . subscriptions . delete ( data . requestId ) ;
423- subscription . subscribed = false ;
424- subscription . unsubscribePromise . resolve ( ) ;
425- }
426- break ;
427- }
428- default : {
429- // create, update, enter, leave, delete cases
430- if ( ! subscription ) {
431397 break ;
432- }
433- let override = false ;
434- if ( data . original ) {
435- override = true ;
436- delete data . original . __type ;
437- // Check for removed fields
438- for ( const field in data . original ) {
439- if ( ! ( field in data . object ) ) {
440- data . object [ field ] = undefined ;
398+ case OP_EVENTS . ERROR : {
399+ const parseError = new ParseError ( data . code , data . error ) ;
400+ if ( ! this . id ) {
401+ this . connectPromise . reject ( parseError ) ;
402+ this . state = CLIENT_STATE . DISCONNECTED ;
403+ }
404+ if ( data . requestId ) {
405+ if ( subscription ) {
406+ subscription . subscribePromise . reject ( parseError ) ;
407+ setTimeout ( ( ) => subscription . emit ( SUBSCRIPTION_EMMITER_TYPES . ERROR , data . error ) , 200 ) ;
441408 }
409+ } else {
410+ this . emit ( CLIENT_EMMITER_TYPES . ERROR , data . error ) ;
411+ }
412+ if ( data . error === 'Additional properties not allowed' ) {
413+ this . additionalProperties = false ;
442414 }
443- data . original = ParseObject . fromJSON ( data . original , false ) ;
415+ if ( data . reconnect ) {
416+ this . _handleReconnect ( ) ;
417+ }
418+ break ;
444419 }
445- delete data . object . __type ;
446- const parseObject = ParseObject . fromJSON (
447- data . object ,
448- ! ( subscription . query && subscription . query . _select ) ? override : false
449- ) ;
450-
451- if ( data . original ) {
452- subscription . emit ( data . op , parseObject , data . original , response ) ;
453- } else {
454- subscription . emit ( data . op , parseObject , response ) ;
420+ case OP_EVENTS . UNSUBSCRIBED : {
421+ if ( subscription ) {
422+ this . subscriptions . delete ( data . requestId ) ;
423+ subscription . subscribed = false ;
424+ subscription . unsubscribePromise . resolve ( ) ;
425+ }
426+ break ;
455427 }
428+ default : {
429+ // create, update, enter, leave, delete cases
430+ if ( ! subscription ) {
431+ break ;
432+ }
433+ let override = false ;
434+ if ( data . original ) {
435+ override = true ;
436+ delete data . original . __type ;
437+ // Check for removed fields
438+ for ( const field in data . original ) {
439+ if ( ! ( field in data . object ) ) {
440+ data . object [ field ] = undefined ;
441+ }
442+ }
443+ data . original = ParseObject . fromJSON ( data . original , false ) ;
444+ }
445+ delete data . object . __type ;
446+ const parseObject = ParseObject . fromJSON (
447+ data . object ,
448+ ! ( subscription . query && subscription . query . _select ) ? override : false
449+ ) ;
450+
451+ if ( data . original ) {
452+ subscription . emit ( data . op , parseObject , data . original , response ) ;
453+ } else {
454+ subscription . emit ( data . op , parseObject , response ) ;
455+ }
456456
457- const localDatastore = CoreManager . getLocalDatastore ( ) ;
458- if ( override && localDatastore . isEnabled ) {
459- localDatastore . _updateObjectIfPinned ( parseObject ) . then ( ( ) => { } ) ;
457+ const localDatastore = CoreManager . getLocalDatastore ( ) ;
458+ if ( override && localDatastore . isEnabled ) {
459+ localDatastore . _updateObjectIfPinned ( parseObject ) . then ( ( ) => { } ) ;
460+ }
460461 }
461462 }
462- }
463463 }
464464
465465 _handleWebSocketClose ( ) {
0 commit comments