diff --git a/src/Firebase.js b/src/Firebase.js
index 0f46104..ee0900e 100644
--- a/src/Firebase.js
+++ b/src/Firebase.js
@@ -39,6 +39,7 @@ async function loginWithGoogle() {
const newUserRef = collection(db, "userInfo");
await setDoc(doc(newUserRef, uid_str), {
"uid": uid_str,
+ "name": user.displayName,
"coins": 0,
"rooms": ["Gray"],
"decorations": []
@@ -56,6 +57,8 @@ async function loginWithGoogle() {
// @ts-ignore
uid: doc.data().uid,
// @ts-ignore
+ name: doc.data().name, // Add the user's name to the UserInfoStore
+ // @ts-ignore
coins: doc.data().coins,
// @ts-ignore
rooms: doc.data().rooms,
@@ -168,10 +171,23 @@ async function buyRoom(room, price) {
}
}
-export {
- loginWithGoogle,
- logoutFromGoogle,
- addActivity,
- getActivities,
- buyRoom
-}
\ No newline at end of file
+
+export const getGoogleUserDisplayName = () => {
+ const user = auth.currentUser;
+ if (user && user.providerData && user.providerData.length > 0) {
+ const providerData = user.providerData[0];
+ if (providerData.providerId === "google.com") {
+ return providerData.displayName;
+ }
+ }
+ return null;
+ };
+
+ export {
+ loginWithGoogle,
+ logoutFromGoogle,
+ addActivity,
+ getActivities,
+ buyRoom,
+ auth
+ };
\ No newline at end of file
diff --git a/src/routes/Homepage.svelte b/src/routes/Homepage.svelte
index 46ee6b8..569212e 100644
--- a/src/routes/Homepage.svelte
+++ b/src/routes/Homepage.svelte
@@ -3,10 +3,12 @@
import SessionStore from '../SessionStore';
import InSession from './components/InSession.svelte';
import ModalManager from './ModalManager.svelte';
- import { logoutFromGoogle } from '../Firebase';
+ import { logoutFromGoogle, getGoogleUserDisplayName } from '../Firebase';
import UserInfoStore from '../UserInfoStore';
import { onMount } from 'svelte';
+
+
/**
* @type {string}
*/
@@ -45,6 +47,7 @@
sessionActivity: ""
});
};
+ const displayName = getGoogleUserDisplayName();
const logout = () => {
SessionStore.set({
@@ -78,6 +81,17 @@
}
}
}
+
+ const profileModal = () => {
+ SessionStore.set({
+ inSession: $SessionStore.inSession,
+ sessionLength: $SessionStore.sessionLength,
+ modalType: "profile",
+ counter: $SessionStore.counter+1,
+ sessionActivity: $SessionStore.sessionActivity
+ });
+ };
+
-
+
{#if $SessionStore.inSession}