WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,8 @@ a:visited {
background-color: transparent;
text-decoration: none;
}

.firebase-emulator-warning {
font-size: 10px;
height: 10px;
}
23 changes: 11 additions & 12 deletions src/shared/utils/firebase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface FirebaseError extends Error {
const app = firebase.initializeApp(config.firebase);
let db = firebase.firestore();

// WARNING: This function is enabling local emulator. If removed, move the emulator config out of this function
enableUnlimitedCachePersistence();
// Function to handle Firestore persistence errors
function handlePersistenceError(err: any) {
Expand Down Expand Up @@ -79,21 +80,19 @@ function enableUnlimitedCachePersistence() {
cacheSizeBytes: CACHE_SIZE_LIMIT,
};
db.settings(settings);

// Enable Firestore emulator in the local environment
if (REACT_APP_ENV === Environment.Local) {
firebase.auth().useEmulator(local.firebase.authDomain);
firebase
.firestore()
.useEmulator(
"localhost",
Number(local.firebase.databaseURL.split(/:/g)[2]),
);
}
db.enablePersistence({ synchronizeTabs: true }).catch(handlePersistenceError);
}

// Enable persistence in the local environment (with Firestore and Auth emulators)
if (REACT_APP_ENV === Environment.Local) {
firebase.auth().useEmulator(local.firebase.authDomain);
firebase
.firestore()
.useEmulator(
"localhost",
Number(local.firebase.databaseURL.split(/:/g)[2]),
);
}

let perf;
if (typeof window !== "undefined" && typeof window.fetch !== "undefined") {
perf = getPerformance(app);
Expand Down