Skip to content

Commit

Permalink
fix(firestore, web): change the interop to fix an issue with startAt/…
Browse files Browse the repository at this point in the history
…endAt when compilating with dart2js in release mode
  • Loading branch information
Lyokone committed Jul 28, 2022
1 parent 6737310 commit 4184d33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ class Query<T extends firestore_interop.QueryJsImpl>
/// We need to call this method in all paginating methods to fix that Dart
/// doesn't support varargs - we need to use [List] to call js function.
S? _createQueryConstraint<S>(
Function method, DocumentSnapshot? snapshot, List<dynamic>? fieldValues) {
Object method, DocumentSnapshot? snapshot, List<dynamic>? fieldValues) {
if (snapshot == null && fieldValues == null) {
throw ArgumentError(
'Please provide either snapshot or fieldValues parameter.');
Expand All @@ -477,7 +477,7 @@ class Query<T extends firestore_interop.QueryJsImpl>
? [snapshot.jsObject]
: fieldValues!.map(jsify).toList();

return callMethod(method, 'apply', jsify([null, args]));
return callMethod(method, 'apply', [null, jsify(args)]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ external PromiseJsImpl<void> enableMultiTabIndexedDbPersistence(
@JS()
external PromiseJsImpl<void> enableNetwork(FirestoreJsImpl firestore);

@JS()
external QueryConstraintJsImpl endBefore(
dynamic /* DocumentSnapshot | ...fieldValues */ fieldValues,
);

@JS()
external QueryConstraintJsImpl endAt(
dynamic /* DocumentSnapshot | ...fieldValues */ fieldValues,
);
@JS()
external PromiseJsImpl<DocumentSnapshotJsImpl> getDoc(
DocumentReferenceJsImpl reference,
Expand Down Expand Up @@ -220,16 +211,6 @@ external bool snapshotEqual(
dynamic /* DocumentSnapshot | QuerySnapshot */ right,
);

@JS()
external QueryConstraintJsImpl startAfter(
dynamic /* DocumentSnapshot | ...fieldValues */ fieldValues,
);

@JS()
external QueryConstraintJsImpl startAt(
dynamic /* DocumentSnapshot | ...fieldValues */ fieldValues,
);

@JS()
external PromiseJsImpl<void> terminate(FirestoreJsImpl firestore);

Expand Down Expand Up @@ -655,3 +636,18 @@ abstract class SnapshotOptions {

external factory SnapshotOptions({String? serverTimestamps});
}

// We type those 4 functions as Object to avoid an issue with dart2js compilation
// in release mode
// Discussed internally with dart2js team
@JS()
external Object get startAfter;

@JS()
external Object get startAt;

@JS()
external Object get endBefore;

@JS()
external Object get endAt;

0 comments on commit 4184d33

Please sign in to comment.