Fixes Across the Board #98
@@ -7,7 +7,7 @@ import Drawer from '@mui/material/Drawer';
|
||||
|
||||
// Firebase Imports
|
||||
import { auth, database } from "../../../firebase-config";
|
||||
import { ref, onValue, set } from "firebase/database";
|
||||
import { ref, get, set } from "firebase/database";
|
||||
import { useAuthState } from "react-firebase-hooks/auth"
|
||||
|
||||
// Component Imports
|
||||
@@ -43,7 +43,7 @@ function Home() {
|
||||
// Authentication Verification / Redirection if Profile Data not Filled out
|
||||
useEffect(() => {
|
||||
if (authUser && authLoading === false) {
|
||||
onValue(ref(database, `users/${authUser.uid}`), (userData) => {
|
||||
get(ref(database, `users/${authUser.uid}`)).then((userData) => {
|
||||
userData = userData.val();
|
||||
if (userData) {
|
||||
setUser({...userData});
|
||||
|
||||
@@ -38,8 +38,8 @@ function Chat() {
|
||||
|
||||
// Authentication Verification / Redirection if Profile Data not Filled out
|
||||
useEffect(() => {
|
||||
if (authUser && authLoading === false) {
|
||||
onValue(ref(database, `users/${authUser.uid}`), (userData) => {
|
||||
if (authUser && authLoading === false && !user) {
|
||||
get(ref(database, `users/${authUser.uid}`)).then((userData) => {
|
||||
userData = userData.val();
|
||||
if (userData) {
|
||||
setUser(userData);
|
||||
|
||||
@@ -40,7 +40,7 @@ function Chat() {
|
||||
// Authentication Verification / Redirection if Profile Data not Filled out
|
||||
useEffect(() => {
|
||||
if (authUser && authLoading === false) {
|
||||
onValue(ref(database, `users/${authUser.uid}`), (userData) => {
|
||||
get(ref(database, `users/${authUser.uid}`)).then((userData) => {
|
||||
userData = userData.val();
|
||||
if (userData) {
|
||||
setUser(userData);
|
||||
|
||||
@@ -49,7 +49,7 @@ function UserProfile() {
|
||||
if (authUser && authLoading === false) {
|
||||
const searchParams = new URLSearchParams(document.location.search);
|
||||
var userUID = searchParams.get("uid")
|
||||
onValue(ref(database, `users/${authUser.uid}`), (userData) => {
|
||||
get(ref(database, `users/${authUser.uid}`)).then((userData) => {
|
||||
userData = userData.val();
|
||||
if (userData) {
|
||||
if (userData.uid == userUID) {
|
||||
@@ -70,7 +70,7 @@ function UserProfile() {
|
||||
useEffect(() => {
|
||||
const searchParams = new URLSearchParams(document.location.search);
|
||||
var userUID = searchParams.get("uid")
|
||||
onValue(ref(database, "/users/" + userUID), (snapshot) => {
|
||||
get(ref(database, "/users/" + userUID)).then((snapshot) => {
|
||||
setProfileData(snapshot.val());
|
||||
|
||||
// Populates array with user's interests
|
||||
|
||||
@@ -77,25 +77,31 @@ export function Geo({ loc, zoom, moveable, user }) {
|
||||
|
||||
|
||||
// Load Nearby Markers
|
||||
var nearbyMarkers = NearbyMarkers(loc);
|
||||
if (nearbyMarkers) {
|
||||
var nearbyMarkers = Object.values(nearbyMarkers).map((roomObj) => {
|
||||
return (<Marker
|
||||
key={roomObj.path + "-" + roomObj.name}
|
||||
anchor={[roomObj.latitude, roomObj.longitude]}
|
||||
onClick={() => {window.location.href = "/chat?room=" + roomObj.path + "/" + roomObj.name + "-" + roomObj.timestamp;}}
|
||||
style={{pointerEvents:'auto'} /* So stupid */}
|
||||
onMouseOver={() => {setHoverText(roomObj.name);setHovering(true);setHoverAnchor([roomObj.latitude, roomObj.longitude])}}
|
||||
onMouseOut={() => {setHovering(false)}}
|
||||
>
|
||||
<ChatBubbleTwoToneIcon color="secondary" fontSize="large"/>
|
||||
</Marker>)
|
||||
var nearbyMarkers = null;
|
||||
if (location) {
|
||||
const path = String(loc.latitude.toFixed(2)).replace(".", "") +"/" +String(loc.longitude.toFixed(2)).replace(".", "") +"/";
|
||||
get(ref(database, `/rooms/${path}`)).then((snapshot) => {
|
||||
if (snapshot.exists()) {
|
||||
nearbyMarkers = snapshot.val();
|
||||
if (nearbyMarkers) {
|
||||
var nearbyMarkers = Object.values(nearbyMarkers).map((roomObj) => {
|
||||
return (<Marker
|
||||
key={roomObj.path + "-" + roomObj.name}
|
||||
anchor={[roomObj.latitude, roomObj.longitude]}
|
||||
onClick={() => {window.location.href = "/chat?room=" + roomObj.path + "/" + roomObj.name + "-" + roomObj.timestamp;}}
|
||||
style={{pointerEvents:'auto'} /* So stupid */}
|
||||
onMouseOver={() => {setHoverText(roomObj.name);setHovering(true);setHoverAnchor([roomObj.latitude, roomObj.longitude])}}
|
||||
onMouseOut={() => {setHovering(false)}}
|
||||
>
|
||||
<ChatBubbleTwoToneIcon color="secondary" fontSize="large"/>
|
||||
</Marker>)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!loc) {
|
||||
return <div>Getting Location...</div>;
|
||||
} else {
|
||||
|
||||
@@ -11,7 +11,7 @@ export function Sidebar({user, chatRoomObj}) {
|
||||
|
||||
var path = chatRoomObj.UIDs[0] < chatRoomObj.UIDs[1] ? chatRoomObj.UIDs[0] + "-" + chatRoomObj.UIDs[1] : chatRoomObj.UIDs[1] + "-" + chatRoomObj.UIDs[0];
|
||||
var activeUsers = []
|
||||
onValue(ref(database, `/dms/${path}/users/online`), (snapshot) => {
|
||||
get(ref(database, `/dms/${path}/users/online`)).then((snapshot) => {
|
||||
if (snapshot.exists()) {
|
||||
var activeUsersJSON = snapshot.val();
|
||||
for (var activeUser in activeUsersJSON)
|
||||
|
||||
@@ -89,26 +89,28 @@ function classNames(...classes) {
|
||||
* @returns {Object} - App Page Sidebar Component
|
||||
*/
|
||||
export function Sidebar({user,location,loadingLoc}) {
|
||||
const [friends, setFriends] = useState([])
|
||||
const [friends, setFriends] = useState(null)
|
||||
const [friendRequests, setFriendRequests] = useState(null)
|
||||
const [dms, setDMs] = useState((<div>No DMs</div>))
|
||||
const [myRoomArr, setMyRoomArr] = useState([])
|
||||
const [myRoomArr, setMyRoomArr] = useState(null)
|
||||
|
||||
useEffect(() => {
|
||||
var myRoomArr = [];
|
||||
// Add myRooms to Sidebar
|
||||
for (var room in user.rooms) {
|
||||
get(ref(database, `/rooms/${user.rooms[room].path}/${user.rooms[room].name}-${user.rooms[room].timestamp}`)).then((snapshot) => {
|
||||
var newRoom = (
|
||||
<ChatRoomSidebar
|
||||
roomObj={snapshot.val()}
|
||||
key={snapshot.val().timestamp}
|
||||
/>
|
||||
);
|
||||
myRoomArr.push(newRoom);
|
||||
})
|
||||
if (user && myRoomArr == null) {
|
||||
var myRoomArr = [];
|
||||
// Add myRooms to Sidebar
|
||||
for (var room in user.rooms) {
|
||||
get(ref(database, `/rooms/${user.rooms[room].path}/${user.rooms[room].name}-${user.rooms[room].timestamp}`)).then((snapshot) => {
|
||||
var newRoom = (
|
||||
<ChatRoomSidebar
|
||||
roomObj={snapshot.val()}
|
||||
key={snapshot.val().timestamp}
|
||||
/>
|
||||
);
|
||||
myRoomArr.push(newRoom);
|
||||
})
|
||||
}
|
||||
setMyRoomArr(myRoomArr)
|
||||
}
|
||||
setMyRoomArr(myRoomArr)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -154,7 +156,7 @@ export function Sidebar({user,location,loadingLoc}) {
|
||||
}
|
||||
|
||||
})
|
||||
}, [user])
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="h-dvh bg-[aliceblue] pt-2 pb-2 pl-2 pr-1">
|
||||
|
||||
Reference in New Issue
Block a user