16
16
17
17
#include " Firestore/core/src/core/sync_engine.h"
18
18
19
+ #include < algorithm>
20
+
19
21
#include " Firestore/core/include/firebase/firestore/firestore_errors.h"
20
22
#include " Firestore/core/src/core/sync_engine_callback.h"
21
23
#include " Firestore/core/src/core/transaction.h"
@@ -528,8 +530,7 @@ void SyncEngine::UpdateTrackedLimboDocuments(
528
530
529
531
void SyncEngine::TrackLimboChange (const LimboDocumentChange& limbo_change) {
530
532
const DocumentKey& key = limbo_change.key ();
531
- if (active_limbo_targets_by_key_.find (key) ==
532
- active_limbo_targets_by_key_.end ()) {
533
+ if (active_limbo_targets_by_key_.find (key) == active_limbo_targets_by_key_.end () && std::find (enqueued_limbo_resolutions_.begin (), enqueued_limbo_resolutions_.end (), key) == enqueued_limbo_resolutions_.end ()) {
533
534
LOG_DEBUG (" New document in limbo: %s" , key.ToString ());
534
535
enqueued_limbo_resolutions_.push_back (key);
535
536
PumpEnqueuedLimboResolutions ();
@@ -553,6 +554,11 @@ void SyncEngine::PumpEnqueuedLimboResolutions() {
553
554
}
554
555
555
556
void SyncEngine::RemoveLimboTarget (const DocumentKey& key) {
557
+ auto enqueued_it = std::find (enqueued_limbo_resolutions_.begin (), enqueued_limbo_resolutions_.end (), key);
558
+ if (enqueued_it != enqueued_limbo_resolutions_.end ()) {
559
+ enqueued_limbo_resolutions_.erase (enqueued_it);
560
+ }
561
+
556
562
auto it = active_limbo_targets_by_key_.find (key);
557
563
if (it == active_limbo_targets_by_key_.end ()) {
558
564
// This target already got removed, because the query failed.
0 commit comments