Skip to content

Commit

Permalink
Revert "Update firebaseFunctions.ts"
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanAnsari authored Oct 8, 2024
1 parent 61a4ebb commit 1810e5f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions firebaseFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ export const getUserData = async (email: string): Promise<UserData | null> => {
const userDoc = await getDoc(userDocRef);

if (!userDoc.exists()) {
await initializeUserData(email);
return await getUserData(email);
await initializeUserData(email); // Initialize the user data if it doesn't exist
return await getUserData(email); // Fetch the newly created data
}

const data = userDoc.data() as UserData;

// Ensure 'usage' is returned (can be handled if missing)
return {
...data,
usage: data.usage ?? 0, // Fallback to 0 if usage is undefined
Expand Down

0 comments on commit 1810e5f

Please sign in to comment.