Skip to content

Commit c74f67a

Browse files
committed
fix(firestore): onSnapshot handling
1 parent c41c406 commit c74f67a

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

packages/firebase-firestore/index.android.ts

+16-7
Original file line numberDiff line numberDiff line change
@@ -537,25 +537,28 @@ export class Query<T extends DocumentData = DocumentData> implements IQuery<T> {
537537
if (error) {
538538
onError?.(FirebaseError.fromNative(error));
539539
} else {
540+
// onError -> onCompletion
540541
onCompletion?.();
542+
// options -> onNext
541543
onNext?.(QuerySnapshot.fromNative(ss));
542544
}
543545
}
544546
} else {
545547
if (error) {
546-
// onNext -> onError
548+
//onError -> onNext
547549
onNext?.(FirebaseError.fromNative(error));
548550
} else {
549-
// onError -> onCompletion
551+
// onCompletion ->
550552
onError?.();
551553
// options -> onNext
552554
options?.(QuerySnapshot.fromNative(ss));
553555
}
554556
}
555557
} else {
556558
if (typeof arguments[1] === 'function') {
559+
// onNext -> options
557560
if (!error) {
558-
onNext?.(QuerySnapshot.fromNative(ss));
561+
options?.(QuerySnapshot.fromNative(ss));
559562
}
560563
} else {
561564
if (error) {
@@ -976,22 +979,28 @@ export class DocumentReference<T extends DocumentData = DocumentData> implements
976979
if (error) {
977980
onError?.(FirebaseError.fromNative(error));
978981
} else {
982+
// onError -> onCompletion
979983
onCompletion?.();
984+
// options -> onNext
980985
onNext?.(DocumentSnapshot.fromNative(ss));
981986
}
982987
}
983988
} else {
984989
if (error) {
985-
onError?.(FirebaseError.fromNative(error));
990+
//onError -> onNext
991+
onNext?.(FirebaseError.fromNative(error));
986992
} else {
987-
onCompletion?.();
988-
onNext?.(DocumentSnapshot.fromNative(ss));
993+
// onCompletion ->
994+
onError?.();
995+
// options -> onNext
996+
options?.(DocumentSnapshot.fromNative(ss));
989997
}
990998
}
991999
} else {
9921000
if (typeof arguments[1] === 'function') {
1001+
// onNext -> options
9931002
if (!error) {
994-
onNext?.(DocumentSnapshot.fromNative(ss));
1003+
options?.(DocumentSnapshot.fromNative(ss));
9951004
}
9961005
} else {
9971006
if (error) {

packages/firebase-firestore/index.ios.ts

+21-12
Original file line numberDiff line numberDiff line change
@@ -476,27 +476,30 @@ export class Query<T extends DocumentData = DocumentData> implements IQuery<T> {
476476
}
477477
} else {
478478
if (error) {
479-
// onNext -> onError
480-
onNext?.(FirebaseError.fromNative(error));
479+
onError?.(FirebaseError.fromNative(error));
481480
} else {
482481
// onError -> onCompletion
483-
onError?.();
482+
onCompletion?.();
484483
// options -> onNext
485-
options?.(QuerySnapshot.fromNative(ss));
484+
onNext?.(QuerySnapshot.fromNative(ss));
486485
}
487486
}
488487
} else {
489488
if (error) {
490-
onError?.(FirebaseError.fromNative(error));
489+
//onError -> onNext
490+
onNext?.(FirebaseError.fromNative(error));
491491
} else {
492-
onCompletion?.();
493-
onNext?.(QuerySnapshot.fromNative(ss));
492+
// onCompletion ->
493+
onError?.();
494+
// options -> onNext
495+
options?.(QuerySnapshot.fromNative(ss));
494496
}
495497
}
496498
} else {
497499
if (typeof arguments[1] === 'function') {
500+
// onNext -> options
498501
if (!error) {
499-
onNext?.(QuerySnapshot.fromNative(ss));
502+
options?.(QuerySnapshot.fromNative(ss));
500503
}
501504
} else {
502505
if (error) {
@@ -896,22 +899,28 @@ export class DocumentReference<T extends DocumentData = DocumentData> implements
896899
if (error) {
897900
onError?.(FirebaseError.fromNative(error));
898901
} else {
902+
// onError -> onCompletion
899903
onCompletion?.();
904+
// options -> onNext
900905
onNext?.(DocumentSnapshot.fromNative(ss));
901906
}
902907
}
903908
} else {
904909
if (error) {
905-
onError?.(FirebaseError.fromNative(error));
910+
//onError -> onNext
911+
onNext?.(FirebaseError.fromNative(error));
906912
} else {
907-
onCompletion?.();
908-
onNext?.(DocumentSnapshot.fromNative(ss));
913+
// onCompletion ->
914+
onError?.();
915+
// options -> onNext
916+
options?.(DocumentSnapshot.fromNative(ss));
909917
}
910918
}
911919
} else {
912920
if (typeof arguments[1] === 'function') {
921+
// onNext -> options
913922
if (!error) {
914-
onNext?.(DocumentSnapshot.fromNative(ss));
923+
options?.(DocumentSnapshot.fromNative(ss));
915924
}
916925
} else {
917926
if (error) {

0 commit comments

Comments
 (0)