Skip to content

Commit 8cb66a5

Browse files
Starting the Mutation Queue in a Transaction (#92)
1 parent 0d5d619 commit 8cb66a5

File tree

1 file changed

+10
-2
lines changed
  • firebase-firestore/src/main/java/com/google/firebase/firestore/local

1 file changed

+10
-2
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/local/LocalStore.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,15 @@ public LocalStore(Persistence persistence, User initialUser) {
138138
}
139139

140140
public void start() {
141-
mutationQueue.start();
141+
startMutationQueue();
142+
}
143+
144+
private void startMutationQueue() {
145+
persistence.runTransaction(
146+
"Start MutationQueue",
147+
() -> {
148+
mutationQueue.start();
149+
});
142150
}
143151

144152
// PORTING NOTE: no shutdown for LocalStore or persistence components on Android.
@@ -148,7 +156,7 @@ public ImmutableSortedMap<DocumentKey, MaybeDocument> handleUserChange(User user
148156
List<MutationBatch> oldBatches = mutationQueue.getAllMutationBatches();
149157

150158
mutationQueue = persistence.getMutationQueue(user);
151-
mutationQueue.start();
159+
startMutationQueue();
152160

153161
List<MutationBatch> newBatches = mutationQueue.getAllMutationBatches();
154162

0 commit comments

Comments
 (0)