1- import { firebase , DocumentSnapshot , QuerySnapshot , GeoPoint , isDocumentReference } from "./firebase-common" ;
1+ import { firebase , DocumentSnapshot as DocumentSnapshotBase , QuerySnapshot , GeoPoint , isDocumentReference } from "./firebase-common" ;
22import * as application from "tns-core-modules/application" ;
33import { ios as iOSUtils } from "tns-core-modules/utils/utils" ;
44import { getClass } from "tns-core-modules/utils/types" ;
@@ -14,6 +14,14 @@ firebase._cachedInvitation = null;
1414firebase . _cachedDynamicLink = null ;
1515firebase . _configured = false ;
1616
17+ class DocumentSnapshot extends DocumentSnapshotBase {
18+ ios : FIRDocumentSnapshot ;
19+ constructor ( snapshot : FIRDocumentSnapshot ) {
20+ super ( snapshot . documentID , snapshot . exists , firebase . toJsObject ( snapshot . data ( ) ) ) ;
21+ this . ios = snapshot ;
22+ }
23+ }
24+
1725// Note that FIRApp.configure must be called only once, but not here (see https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/564)
1826
1927const invokeOnRunLoop = ( ( ) => {
@@ -2205,7 +2213,11 @@ firebase.firestore.collection = (collectionPath: string): firestore.CollectionRe
22052213 where : ( fieldPath : string , opStr : firestore . WhereFilterOp , value : any ) => firebase . firestore . where ( collectionPath , fieldPath , opStr , value ) ,
22062214 orderBy : ( fieldPath : string , directionStr : firestore . OrderByDirection ) : firestore . Query => firebase . firestore . orderBy ( collectionPath , fieldPath , directionStr , fIRCollectionReference ) ,
22072215 limit : ( limit : number ) : firestore . Query => firebase . firestore . limit ( collectionPath , limit , fIRCollectionReference ) ,
2208- onSnapshot : ( callback : ( snapshot : QuerySnapshot ) => void ) => firebase . firestore . onCollectionSnapshot ( fIRCollectionReference , callback )
2216+ onSnapshot : ( callback : ( snapshot : QuerySnapshot ) => void ) => firebase . firestore . onCollectionSnapshot ( fIRCollectionReference , callback ) ,
2217+ startAfter : ( document : DocumentSnapshot ) => firebase . firestore . startAfter ( collectionPath , document , fIRCollectionReference ) ,
2218+ startAt : ( document : DocumentSnapshot ) => firebase . firestore . startAt ( collectionPath , document , fIRCollectionReference ) ,
2219+ endAt : ( document : DocumentSnapshot ) => firebase . firestore . endAt ( collectionPath , document , fIRCollectionReference ) ,
2220+ endBefore : ( document : DocumentSnapshot ) => firebase . firestore . endBefore ( collectionPath , document , fIRCollectionReference ) ,
22092221 } ;
22102222
22112223 } catch ( ex ) {
@@ -2217,7 +2229,7 @@ firebase.firestore.collection = (collectionPath: string): firestore.CollectionRe
22172229firebase . firestore . onDocumentSnapshot = ( docRef : FIRDocumentReference , callback : ( doc : DocumentSnapshot ) => void ) : ( ) => void => {
22182230 const listener = docRef . addSnapshotListener ( ( snapshot : FIRDocumentSnapshot , error : NSError ) => {
22192231 if ( ! error && snapshot ) {
2220- callback ( new DocumentSnapshot ( snapshot . documentID , snapshot . exists , firebase . toJsObject ( snapshot . data ( ) ) ) ) ;
2232+ callback ( new DocumentSnapshot ( snapshot ) ) ;
22212233 }
22222234 } ) ;
22232235
@@ -2238,7 +2250,7 @@ firebase.firestore.onCollectionSnapshot = (colRef: FIRCollectionReference, callb
22382250 const docSnapshots : Array < firestore . DocumentSnapshot > = [ ] ;
22392251 for ( let i = 0 , l = snapshot . documents . count ; i < l ; i ++ ) {
22402252 const document : FIRQueryDocumentSnapshot = snapshot . documents . objectAtIndex ( i ) ;
2241- docSnapshots . push ( new DocumentSnapshot ( document . documentID , true , firebase . toJsObject ( document . data ( ) ) ) ) ;
2253+ docSnapshots . push ( new DocumentSnapshot ( document ) ) ;
22422254 }
22432255
22442256 const snap = new QuerySnapshot ( ) ;
@@ -2454,7 +2466,7 @@ firebase.firestore.getCollection = (collectionPath: string): Promise<firestore.Q
24542466 const docSnapshots : Array < firestore . DocumentSnapshot > = [ ] ;
24552467 for ( let i = 0 , l = snapshot . documents . count ; i < l ; i ++ ) {
24562468 const document : FIRQueryDocumentSnapshot = snapshot . documents . objectAtIndex ( i ) ;
2457- docSnapshots . push ( new DocumentSnapshot ( document . documentID , true , firebase . toJsObject ( document . data ( ) ) ) ) ;
2469+ docSnapshots . push ( new DocumentSnapshot ( document ) ) ;
24582470 }
24592471 const snap = new QuerySnapshot ( ) ;
24602472 snap . docSnapshots = docSnapshots ;
@@ -2489,7 +2501,7 @@ firebase.firestore.getDocument = (collectionPath: string, documentPath: string):
24892501 reject ( error . localizedDescription ) ;
24902502 } else {
24912503 const exists = snapshot . exists ;
2492- resolve ( new DocumentSnapshot ( exists ? snapshot . documentID : null , exists , firebase . toJsObject ( snapshot . data ( ) ) ) ) ;
2504+ resolve ( new DocumentSnapshot ( snapshot ) ) ;
24932505 }
24942506 } ) ;
24952507
@@ -2511,7 +2523,7 @@ firebase.firestore._getQuery = (collectionPath: string, query: FIRQuery): firest
25112523 const docSnapshots : Array < firestore . DocumentSnapshot > = [ ] ;
25122524 for ( let i = 0 , l = snapshot . documents . count ; i < l ; i ++ ) {
25132525 const document : FIRQueryDocumentSnapshot = snapshot . documents . objectAtIndex ( i ) ;
2514- docSnapshots . push ( new DocumentSnapshot ( document . documentID , true , firebase . toJsObject ( document . data ( ) ) ) ) ;
2526+ docSnapshots . push ( new DocumentSnapshot ( document ) ) ;
25152527 }
25162528 const snap = new QuerySnapshot ( ) ;
25172529 snap . docSnapshots = docSnapshots ;
@@ -2522,7 +2534,11 @@ firebase.firestore._getQuery = (collectionPath: string, query: FIRQuery): firest
25222534 where : ( fp : string , os : firestore . WhereFilterOp , v : any ) : firestore . Query => firebase . firestore . where ( collectionPath , fp , os , v , query ) ,
25232535 orderBy : ( fp : string , directionStr : firestore . OrderByDirection ) : firestore . Query => firebase . firestore . orderBy ( collectionPath , fp , directionStr , query ) ,
25242536 limit : ( limit : number ) : firestore . Query => firebase . firestore . limit ( collectionPath , limit , query ) ,
2525- onSnapshot : ( callback : ( snapshot : QuerySnapshot ) => void ) => firebase . firestore . onCollectionSnapshot ( query , callback )
2537+ onSnapshot : ( callback : ( snapshot : QuerySnapshot ) => void ) => firebase . firestore . onCollectionSnapshot ( query , callback ) ,
2538+ startAfter : ( document : DocumentSnapshot ) => firebase . firestore . startAfter ( collectionPath , document , query ) ,
2539+ startAt : ( document : DocumentSnapshot ) => firebase . firestore . startAt ( collectionPath , document , query ) ,
2540+ endAt : ( document : DocumentSnapshot ) => firebase . firestore . endAt ( collectionPath , document , query ) ,
2541+ endBefore : ( document : DocumentSnapshot ) => firebase . firestore . endBefore ( collectionPath , document , query ) ,
25262542 } ;
25272543} ;
25282544
@@ -2573,6 +2589,26 @@ firebase.firestore.limit = (collectionPath: string, limit: number, query: FIRQue
25732589 return firebase . firestore . _getQuery ( collectionPath , query ) ;
25742590} ;
25752591
2592+ firebase . firestore . startAt = ( collectionPath : string , document : DocumentSnapshot , query : FIRQuery ) => {
2593+ query = query . queryStartingAtDocument ( document . ios ) ;
2594+ return firebase . firestore . _getQuery ( collectionPath , query ) ;
2595+ }
2596+
2597+ firebase . firestore . startAfter = ( collectionPath : string , document : DocumentSnapshot , query : FIRQuery ) => {
2598+ query = query . queryStartingAfterDocument ( document . ios ) ;
2599+ return firebase . firestore . _getQuery ( collectionPath , query ) ;
2600+ } ;
2601+
2602+ firebase . firestore . endAt = ( collectionPath : string , document : DocumentSnapshot , query : FIRQuery ) => {
2603+ query = query . queryEndingAtDocument ( document . ios ) ;
2604+ return firebase . firestore . _getQuery ( collectionPath , query ) ;
2605+ } ;
2606+
2607+ firebase . firestore . endBefore = ( collectionPath : string , document : DocumentSnapshot , query : FIRQuery ) => {
2608+ query = query . queryEndingBeforeDocument ( document . ios ) ;
2609+ return firebase . firestore . _getQuery ( collectionPath , query ) ;
2610+ } ;
2611+
25762612// see https://developer.apple.com/reference/usernotifications/unusernotificationcenterdelegate?language=objc
25772613class UNUserNotificationCenterDelegateImpl extends NSObject implements UNUserNotificationCenterDelegate {
25782614 public static ObjCProtocols = [ ] ;
0 commit comments