use of com.google.firebase.firestore.remote.RemoteEvent in project firebase-android-sdk by firebase.
the class SyncEngine method handleRejectedListen.
/**
* Called by FirestoreClient to notify us of a rejected listen.
*/
@Override
public void handleRejectedListen(int targetId, Status error) {
assertCallback("handleRejectedListen");
LimboResolution limboResolution = activeLimboResolutionsByTarget.get(targetId);
DocumentKey limboKey = limboResolution != null ? limboResolution.key : null;
if (limboKey != null) {
// Since this query failed, we won't want to manually unlisten to it.
// So go ahead and remove it from bookkeeping.
activeLimboTargetsByKey.remove(limboKey);
activeLimboResolutionsByTarget.remove(targetId);
pumpEnqueuedLimboResolutions();
// TODO: Retry on transient errors?
// It's a limbo doc. Create a synthetic event saying it was deleted. This is kind of a hack.
// Ideally, we would have a method in the local store to purge a document. However, it would
// be tricky to keep all of the local store's invariants with another method.
MutableDocument result = MutableDocument.newNoDocument(limboKey, SnapshotVersion.NONE);
Map<DocumentKey, MutableDocument> documentUpdates = Collections.singletonMap(limboKey, result);
Set<DocumentKey> limboDocuments = Collections.singleton(limboKey);
RemoteEvent event = new RemoteEvent(SnapshotVersion.NONE, /* targetChanges= */
Collections.emptyMap(), /* targetMismatches= */
Collections.emptySet(), documentUpdates, limboDocuments);
handleRemoteEvent(event);
} else {
localStore.releaseTarget(targetId);
removeAndCleanupTarget(targetId, error);
}
}
Aggregations