Skip to content

Commit

Permalink
Support offline cache
Browse files Browse the repository at this point in the history
  • Loading branch information
odiak committed Nov 5, 2024
1 parent ee10d7e commit bdef5d9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { initializeAnalytics, isSupported, setUserId, setUserProperties } from '
import { initializeApp } from 'firebase/app'
import { initializeAppCheck, ReCaptchaV3Provider } from 'firebase/app-check'
import { getAuth, onAuthStateChanged } from 'firebase/auth'
import {
initializeFirestore,
persistentLocalCache,
persistentMultipleTabManager
} from 'firebase/firestore'

export async function initializeFirebase() {
const app = initializeApp(kakeruSecrets.firebaseConfig)
Expand All @@ -15,6 +20,13 @@ export async function initializeFirebase() {
isTokenAutoRefreshEnabled: true
})

initializeFirestore(app, {
ignoreUndefinedProperties: true,
localCache: persistentLocalCache({
tabManager: persistentMultipleTabManager()
})
})

const analyticsSupported = await isSupported()
if (analyticsSupported) {
const analytics = initializeAnalytics(app)
Expand Down

0 comments on commit bdef5d9

Please sign in to comment.