@@ -923,9 +923,7 @@ function pluginMutations (userState) {
923923 PATCH_DOC : function ( state , patches ) {
924924 var _this = this ;
925925 // Get the state prop ref
926- var ref = state . _conf . statePropName
927- ? state [ state . _conf . statePropName ]
928- : state ;
926+ var ref = state . _conf . statePropName ? state [ state . _conf . statePropName ] : state ;
929927 if ( state . _conf . firestoreRefType . toLowerCase ( ) === 'collection' ) {
930928 ref = ref [ patches . id ] ;
931929 }
@@ -958,17 +956,15 @@ function pluginMutations (userState) {
958956 }
959957 } ,
960958 DELETE_PROP : function ( state , path ) {
961- var searchTarget = state . _conf . statePropName
962- ? state [ state . _conf . statePropName ]
963- : state ;
959+ var searchTarget = state . _conf . statePropName ? state [ state . _conf . statePropName ] : state ;
964960 var propArr = path . split ( '.' ) ;
965961 var target = propArr . pop ( ) ;
966962 if ( ! propArr . length ) {
967963 return this . _vm . $delete ( searchTarget , target ) ;
968964 }
969965 var ref = createEasyAccess . getDeepRef ( searchTarget , propArr . join ( '.' ) ) ;
970966 return this . _vm . $delete ( ref , target ) ;
971- }
967+ } ,
972968 } ;
973969}
974970
@@ -1981,7 +1977,7 @@ function pluginActions (Firebase) {
19811977 } ) ;
19821978 } ;
19831979 var unsubscribe = dbRef . onSnapshot ( { includeMetadataChanges : includeMetadataChanges } , function ( querySnapshot ) { return __awaiter ( _this , void 0 , void 0 , function ( ) {
1984- var message , error_1 ;
1980+ var docChanges , message , error_1 ;
19851981 return __generator ( this , function ( _a ) {
19861982 switch ( _a . label ) {
19871983 case 0 :
@@ -2005,6 +2001,26 @@ function pluginActions (Firebase) {
20052001 }
20062002 gotFirstLocalResponse = true ;
20072003 }
2004+ else if ( gotFirstLocalResponse ) {
2005+ // it's not the first call and it's a change from cache
2006+ // normally we only need to listen to the server changes, but there's an edge case here:
2007+ // case: "a permission is removed server side, and instead of this being notified
2008+ // by firestore from the _server side_, it only notifies this from the cache...
2009+ if ( getters . collectionMode ) {
2010+ docChanges = querySnapshot . docChanges ( ) ;
2011+ docChanges . forEach ( function ( change ) {
2012+ // only do stuff on "removed" !!
2013+ if ( change . type === 'removed' ) {
2014+ var doc = getters . cleanUpRetrievedDoc ( change . doc . data ( ) , change . doc . id ) ;
2015+ dispatch ( 'applyHooksAndUpdateState' , {
2016+ change : change . type ,
2017+ id : change . doc . id ,
2018+ doc : doc ,
2019+ } ) ;
2020+ }
2021+ } ) ;
2022+ }
2023+ }
20082024 return [ 3 /*break*/ , 13 ] ;
20092025 case 1 :
20102026 if ( ! querySnapshot . metadata . hasPendingWrites ) return [ 3 /*break*/ , 2 ] ;
0 commit comments