From 137c067da71bb7cc7a6e20247dfaa6ac6136d97a Mon Sep 17 00:00:00 2001 From: Ben Delaney Date: Fri, 29 Jan 2021 20:36:50 +1100 Subject: [PATCH 1/2] Add isEqual implementations for Query and CollectionReference TODO: Update types --- src/firebase.android.ts | 8 ++++++-- src/firebase.ios.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/firebase.android.ts b/src/firebase.android.ts index cc352ba0..490d987b 100755 --- a/src/firebase.android.ts +++ b/src/firebase.android.ts @@ -2531,7 +2531,9 @@ firebase.firestore._getCollectionReference = (colRef?: JCollectionReference): fi startAfter: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.startAfter(collectionPath, snapshotOrFieldValue, fieldValues, colRef), startAt: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.startAt(collectionPath, snapshotOrFieldValue, fieldValues, colRef), endAt: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endAt(collectionPath, snapshotOrFieldValue, fieldValues, colRef), - endBefore: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endBefore(collectionPath, snapshotOrFieldValue, fieldValues, colRef) + endBefore: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endBefore(collectionPath, snapshotOrFieldValue, fieldValues, colRef), + android: colRef, + isEqual: (other: firestore.Query): boolean => colRef.equals(other ? other.android : null) }; }; @@ -2780,7 +2782,9 @@ firebase.firestore._getQuery = (collectionPath: string, query: com.google.fireba startAt: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.startAt(collectionPath, snapshotOrFieldValue, fieldValues, query), endAt: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endAt(collectionPath, snapshotOrFieldValue, fieldValues, query), endBefore: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endBefore(collectionPath, snapshotOrFieldValue, fieldValues, query), - firestore: firebase.firestore + firestore: firebase.firestore, + android: query, + isEqual: (other: firestore.Query): boolean => query.equals(other ? other.android : null) }; }; diff --git a/src/firebase.ios.ts b/src/firebase.ios.ts index a5dac1a3..d102641c 100755 --- a/src/firebase.ios.ts +++ b/src/firebase.ios.ts @@ -2144,7 +2144,9 @@ firebase.firestore._getCollectionReference = (colRef?: FIRCollectionReference): startAfter: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.startAfter(collectionPath, snapshotOrFieldValue, fieldValues, colRef), startAt: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.startAt(collectionPath, snapshotOrFieldValue, fieldValues, colRef), endAt: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endAt(collectionPath, snapshotOrFieldValue, fieldValues, colRef), - endBefore: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endBefore(collectionPath, snapshotOrFieldValue, fieldValues, colRef) + endBefore: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endBefore(collectionPath, snapshotOrFieldValue, fieldValues, colRef), + ios: colRef, + isEqual: (other: firestore.Query): boolean => colRef.isEqual(other ? other.ios : null) }; }; @@ -2437,7 +2439,9 @@ firebase.firestore._getQuery = (collectionPath: string, query: FIRQuery): firest startAt: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.startAt(collectionPath, snapshotOrFieldValue, fieldValues, query), endAt: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endAt(collectionPath, snapshotOrFieldValue, fieldValues, query), endBefore: (snapshotOrFieldValue: DocumentSnapshot | any, ...fieldValues: any[]): firestore.Query => firebase.firestore.endBefore(collectionPath, snapshotOrFieldValue, fieldValues, query), - firestore: firebase.firestore + firestore: firebase.firestore, + ios: query, + isEqual: (other: firestore.Query): boolean => query.isEqual(other ? other.ios : null) }; }; From 0461ac30f2b32321b3b212d93585bcc68aeb21e3 Mon Sep 17 00:00:00 2001 From: Ben Delaney Date: Fri, 29 Jan 2021 21:28:48 +1100 Subject: [PATCH 2/2] Add types --- src/firebase.d.ts | 6 ++++++ src/platforms/ios/typings/objc!FirebaseFirestore.d.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/firebase.d.ts b/src/firebase.d.ts index 907d61b8..2f7c4a02 100644 --- a/src/firebase.d.ts +++ b/src/firebase.d.ts @@ -1000,6 +1000,12 @@ export namespace firestore { endBefore(snapshot: DocumentSnapshot): Query; endBefore(...fieldValues: any[]): Query; + + ios?: FIRQuery; + + android?: com.google.firebase.firestore.Query; + + isEqual: (other: firestore.Query) => boolean; } export interface CollectionGroup { diff --git a/src/platforms/ios/typings/objc!FirebaseFirestore.d.ts b/src/platforms/ios/typings/objc!FirebaseFirestore.d.ts index 6db80b1e..365f0dd5 100644 --- a/src/platforms/ios/typings/objc!FirebaseFirestore.d.ts +++ b/src/platforms/ios/typings/objc!FirebaseFirestore.d.ts @@ -294,6 +294,8 @@ declare class FIRQuery extends NSObject { addSnapshotListenerWithIncludeMetadataChangesListener(includeMetadataChanges: boolean, listener: (p1: FIRQuerySnapshot, p2: NSError) => void): FIRListenerRegistration; + isEqual(other: FIRQuery): boolean; + getDocumentsWithCompletion(completion: (p1: FIRQuerySnapshot, p2: NSError) => void): void; getDocumentsWithSourceCompletion(source: FIRFirestoreSource, completion: (p1: FIRQuerySnapshot, p2: NSError) => void): void;