Skip to content

Commit b4e92ed

Browse files
authored
fix(firestore, web): change the interop to fix an issue with startAt/endAt when compilating with dart2js in release mode (#9246)
1 parent 785c486 commit b4e92ed

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ class Query<T extends firestore_interop.QueryJsImpl>
467467
/// We need to call this method in all paginating methods to fix that Dart
468468
/// doesn't support varargs - we need to use [List] to call js function.
469469
S? _createQueryConstraint<S>(
470-
Function method, DocumentSnapshot? snapshot, List<dynamic>? fieldValues) {
470+
Object method, DocumentSnapshot? snapshot, List<dynamic>? fieldValues) {
471471
if (snapshot == null && fieldValues == null) {
472472
throw ArgumentError(
473473
'Please provide either snapshot or fieldValues parameter.');
@@ -477,7 +477,7 @@ class Query<T extends firestore_interop.QueryJsImpl>
477477
? [snapshot.jsObject]
478478
: fieldValues!.map(jsify).toList();
479479

480-
return callMethod(method, 'apply', jsify([null, args]));
480+
return callMethod(method, 'apply', [null, jsify(args)]);
481481
}
482482
}
483483

packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,6 @@ external PromiseJsImpl<void> enableMultiTabIndexedDbPersistence(
9292
@JS()
9393
external PromiseJsImpl<void> enableNetwork(FirestoreJsImpl firestore);
9494

95-
@JS()
96-
external QueryConstraintJsImpl endBefore(
97-
dynamic /* DocumentSnapshot | ...fieldValues */ fieldValues,
98-
);
99-
100-
@JS()
101-
external QueryConstraintJsImpl endAt(
102-
dynamic /* DocumentSnapshot | ...fieldValues */ fieldValues,
103-
);
10495
@JS()
10596
external PromiseJsImpl<DocumentSnapshotJsImpl> getDoc(
10697
DocumentReferenceJsImpl reference,
@@ -220,16 +211,6 @@ external bool snapshotEqual(
220211
dynamic /* DocumentSnapshot | QuerySnapshot */ right,
221212
);
222213

223-
@JS()
224-
external QueryConstraintJsImpl startAfter(
225-
dynamic /* DocumentSnapshot | ...fieldValues */ fieldValues,
226-
);
227-
228-
@JS()
229-
external QueryConstraintJsImpl startAt(
230-
dynamic /* DocumentSnapshot | ...fieldValues */ fieldValues,
231-
);
232-
233214
@JS()
234215
external PromiseJsImpl<void> terminate(FirestoreJsImpl firestore);
235216

@@ -655,3 +636,18 @@ abstract class SnapshotOptions {
655636

656637
external factory SnapshotOptions({String? serverTimestamps});
657638
}
639+
640+
// We type those 4 functions as Object to avoid an issue with dart2js compilation
641+
// in release mode
642+
// Discussed internally with dart2js team
643+
@JS()
644+
external Object get startAfter;
645+
646+
@JS()
647+
external Object get startAt;
648+
649+
@JS()
650+
external Object get endBefore;
651+
652+
@JS()
653+
external Object get endAt;

0 commit comments

Comments
 (0)