Search in sources :

Example 6 with User

use of com.google.firebase.firestore.auth.User in project firebase-android-sdk by firebase.

the class SQLiteOverlayMigrationManager method buildOverlays.

private void buildOverlays() {
    db.runTransaction("build overlays", () -> {
        Set<String> userIds = getAllUserIds();
        RemoteDocumentCache remoteDocumentCache = db.getRemoteDocumentCache();
        for (String uid : userIds) {
            User user = new User(uid);
            MutationQueue mutationQueue = db.getMutationQueue(user, db.getIndexManager(user));
            // Get all document keys that have local mutations
            Set<DocumentKey> allDocumentKeys = new HashSet<>();
            List<MutationBatch> batches = mutationQueue.getAllMutationBatches();
            for (MutationBatch batch : batches) {
                allDocumentKeys.addAll(batch.getKeys());
            }
            // Recalculate and save overlays
            DocumentOverlayCache documentOverlayCache = db.getDocumentOverlay(user);
            LocalDocumentsView localView = new LocalDocumentsView(remoteDocumentCache, mutationQueue, documentOverlayCache, db.getIndexManager(user));
            localView.recalculateAndSaveOverlays(allDocumentKeys);
        }
        removePendingOverlayMigrations();
    });
}
Also used : User(com.google.firebase.firestore.auth.User) MutationBatch(com.google.firebase.firestore.model.mutation.MutationBatch) DocumentKey(com.google.firebase.firestore.model.DocumentKey) HashSet(java.util.HashSet)

Aggregations

User (com.google.firebase.firestore.auth.User)6 AsyncQueue (com.google.firebase.firestore.util.AsyncQueue)2 Test (org.junit.Test)2 NonNull (androidx.annotation.NonNull)1 FirebaseAppCheckTokenProvider (com.google.firebase.firestore.auth.FirebaseAppCheckTokenProvider)1 FirebaseAuthCredentialsProvider (com.google.firebase.firestore.auth.FirebaseAuthCredentialsProvider)1 DatabaseId (com.google.firebase.firestore.model.DatabaseId)1 DocumentKey (com.google.firebase.firestore.model.DocumentKey)1 MutationBatch (com.google.firebase.firestore.model.mutation.MutationBatch)1 HashSet (java.util.HashSet)1