From 80e9e99789e662b67470d99665d320d23f0e45df Mon Sep 17 00:00:00 2001 From: Salakar Date: Fri, 23 Feb 2018 09:51:05 +0000 Subject: [PATCH] [firestore][android] update transaction handler to reset command buffer at the start of each cycle --- .../io/invertase/firebase/firestore/RNFirebaseFirestore.java | 2 +- .../firestore/RNFirebaseFirestoreTransactionHandler.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestore.java b/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestore.java index 3bb250f5..48191f53 100644 --- a/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestore.java +++ b/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestore.java @@ -263,7 +263,7 @@ public class RNFirebaseFirestore extends ReactContextBaseJavaModule { .runTransaction(new Transaction.Function() { @Override public Void apply(@NonNull Transaction transaction) throws FirebaseFirestoreException { - transactionHandler.setFirestoreTransaction(transaction); + transactionHandler.resetState(transaction); // emit the update cycle to JS land using an async task // otherwise it gets blocked by the pending lock await diff --git a/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreTransactionHandler.java b/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreTransactionHandler.java index cf84ca64..ef136ed7 100644 --- a/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreTransactionHandler.java +++ b/android/src/main/java/io/invertase/firebase/firestore/RNFirebaseFirestoreTransactionHandler.java @@ -51,11 +51,12 @@ class RNFirebaseFirestoreTransactionHandler { } /** - * Keep a ref to the Transaction instance. + * Reset handler state - clears command buffer + updates to new Transaction instance * * @param firestoreTransaction */ - void setFirestoreTransaction(Transaction firestoreTransaction) { + void resetState(Transaction firestoreTransaction) { + this.commandBuffer = null; this.firestoreTransaction = firestoreTransaction; }