Skip to content

Commit

Permalink
chore(firestore): clean up the code for checking if instance exists (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyokone authored Oct 31, 2024
1 parent 9e80c1d commit 9335436
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ private FirebaseFirestore readFirestoreInstance(ByteBuffer buffer) {
String databaseURL = (String) readValue(buffer);
FirebaseFirestoreSettings settings = (FirebaseFirestoreSettings) readValue(buffer);
synchronized (FlutterFirebaseFirestorePlugin.firestoreInstanceCache) {
if (FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
appName, databaseURL)
!= null) {
return FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
appName, databaseURL);
FirebaseFirestore cachedFirestoreInstance =
FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
appName, databaseURL);
if (cachedFirestoreInstance != null) {
return cachedFirestoreInstance;
}

FirebaseApp app = FirebaseApp.getInstance(appName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ static FirebaseFirestoreSettings getSettingsFromPigeon(
public static FirebaseFirestore getFirestoreFromPigeon(
GeneratedAndroidFirebaseFirestore.FirestorePigeonFirebaseApp pigeonApp) {
synchronized (FlutterFirebaseFirestorePlugin.firestoreInstanceCache) {
if (FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
pigeonApp.getAppName(), pigeonApp.getDatabaseURL())
!= null) {
return FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
pigeonApp.getAppName(), pigeonApp.getDatabaseURL());
FirebaseFirestore cachedFirestoreInstance =
FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
pigeonApp.getAppName(), pigeonApp.getDatabaseURL());
if (cachedFirestoreInstance != null) {
return cachedFirestoreInstance;
}

FirebaseApp app = FirebaseApp.getInstance(pigeonApp.getAppName());
Expand Down

0 comments on commit 9335436

Please sign in to comment.