@@ -923,9 +923,7 @@ function pluginMutations (userState) {
923
923
PATCH_DOC : function ( state , patches ) {
924
924
var _this = this ;
925
925
// 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 ;
929
927
if ( state . _conf . firestoreRefType . toLowerCase ( ) === 'collection' ) {
930
928
ref = ref [ patches . id ] ;
931
929
}
@@ -958,17 +956,15 @@ function pluginMutations (userState) {
958
956
}
959
957
} ,
960
958
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 ;
964
960
var propArr = path . split ( '.' ) ;
965
961
var target = propArr . pop ( ) ;
966
962
if ( ! propArr . length ) {
967
963
return this . _vm . $delete ( searchTarget , target ) ;
968
964
}
969
965
var ref = createEasyAccess . getDeepRef ( searchTarget , propArr . join ( '.' ) ) ;
970
966
return this . _vm . $delete ( ref , target ) ;
971
- }
967
+ } ,
972
968
} ;
973
969
}
974
970
@@ -1981,7 +1977,7 @@ function pluginActions (Firebase) {
1981
1977
} ) ;
1982
1978
} ;
1983
1979
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 ;
1985
1981
return __generator ( this , function ( _a ) {
1986
1982
switch ( _a . label ) {
1987
1983
case 0 :
@@ -2005,6 +2001,26 @@ function pluginActions (Firebase) {
2005
2001
}
2006
2002
gotFirstLocalResponse = true ;
2007
2003
}
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
+ }
2008
2024
return [ 3 /*break*/ , 13 ] ;
2009
2025
case 1 :
2010
2026
if ( ! querySnapshot . metadata . hasPendingWrites ) return [ 3 /*break*/ , 2 ] ;
0 commit comments