From 0c328bc39809f1ab947066952f9611d283f54465 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 14 Jul 2022 11:44:52 -0500 Subject: [PATCH] Move getStorage() into init.ts after initializeApp() is called. --- web/lib/firebase/init.ts | 2 ++ web/lib/firebase/storage.ts | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/web/lib/firebase/init.ts b/web/lib/firebase/init.ts index 12f3d832..bf712a8f 100644 --- a/web/lib/firebase/init.ts +++ b/web/lib/firebase/init.ts @@ -1,5 +1,6 @@ import { getFirestore } from '@firebase/firestore' import { initializeApp, getApps, getApp } from 'firebase/app' +import { getStorage } from 'firebase/storage' import { FIREBASE_CONFIG } from 'common/envs/constants' import { connectFirestoreEmulator } from 'firebase/firestore' import { connectFunctionsEmulator, getFunctions } from 'firebase/functions' @@ -8,6 +9,7 @@ import { connectFunctionsEmulator, getFunctions } from 'firebase/functions' export const app = getApps().length ? getApp() : initializeApp(FIREBASE_CONFIG) export const db = getFirestore() export const functions = getFunctions() +export const storage = getStorage() declare global { /* eslint-disable-next-line no-var */ diff --git a/web/lib/firebase/storage.ts b/web/lib/firebase/storage.ts index 5293a6bc..2fc2ccc7 100644 --- a/web/lib/firebase/storage.ts +++ b/web/lib/firebase/storage.ts @@ -1,11 +1,5 @@ -import { - getStorage, - ref, - uploadBytesResumable, - getDownloadURL, -} from 'firebase/storage' - -const storage = getStorage() +import { ref, uploadBytesResumable, getDownloadURL } from 'firebase/storage' +import { storage } from './init' // TODO: compress large images export const uploadImage = async (