adding some things for the whole convo view

This commit is contained in:
Arjun Patel
2022-02-05 20:55:58 -08:00
parent 5c13954764
commit 291d3050f0
3 changed files with 46 additions and 20 deletions
@@ -17,6 +17,12 @@ import {
} from "react-icons/fa"; } from "react-icons/fa";
import LinkIcon from "../Drawer/LinkIcon"; import LinkIcon from "../Drawer/LinkIcon";
import UserAvatar, { UserAvatarSizes } from "../UserDetails/UserAvatar"; import UserAvatar, { UserAvatarSizes } from "../UserDetails/UserAvatar";
import { useRecoilValue } from "recoil";
import { allRelevantConversationsAtom } from "../../recoil/main";
import { useRouter } from "next/router";
import Conversation from "@nirvana/common/models/conversation";
import { useAuth } from "../../contexts/authContext";
import { QueryRoutes, Routes } from "@nirvana/common/helpers/routes";
const testDrawerItems: { const testDrawerItems: {
linkType: LinkType; linkType: LinkType;
@@ -102,17 +108,37 @@ const testAudioClips: {
]; ];
export default function ViewConvo(props: { conversationId: string }) { export default function ViewConvo(props: { conversationId: string }) {
// auth if do not have this conversation in react cache, then we are not authorized const { currUser } = useAuth();
// if somehow it's still cached but we were removed, const allConvosMap = useRecoilValue(allRelevantConversationsAtom);
// then authenticate by checking if we are in the array of users for the conversation
const endOfTimeline = useRef<HTMLSpanElement>(); const endOfTimeline = useRef<HTMLSpanElement>();
const router = useRouter();
useEffect(() => { useEffect(() => {
endOfTimeline.current?.scrollIntoView({ behavior: "smooth" }); endOfTimeline.current?.scrollIntoView({ behavior: "smooth" });
}, []); }, []);
// auth if do not have this conversation in react cache, then we are not authorized
// if somehow it's still cached but we were removed,
// then authenticate by checking if we are in the array of users for the conversation
const convo: Conversation | undefined = allConvosMap.get(
props.conversationId
);
useEffect(() => {
if (!convo || !convo.activeMembers.includes(currUser!.uid)) {
toast.error("Not authorized for this conversation");
router.push({
pathname: Routes.home,
query: { page: QueryRoutes.convos },
});
}
}, []);
return ( return (
<> <>
<div className="flex flex-col items-stretch mt-5 space-y-10"> <div className="flex flex-col items-stretch mt-5 space-y-10">
@@ -120,21 +146,21 @@ export default function ViewConvo(props: { conversationId: string }) {
<div className="flex-1 flex flex-col overflow-auto"> <div className="flex-1 flex flex-col overflow-auto">
{/* header */} {/* header */}
<span className="flex flex-row justify-between items-center mb-5"> <span className="flex flex-row justify-between items-center mb-5">
<span className="flex flex-col group"> <span className="flex flex-col">
<span className="flex flex-row items-center"> <span className="flex flex-row items-center group">
<span <span
className="text-md tracking-widest font-semibold className="text-md tracking-widest font-semibold
text-slate-500 uppercase" text-slate-500 uppercase"
> >
Engineering {convo?.name}
</span> </span>
<span className="p-2 rounded-full hover:cursor-pointer hover:bg-slate-200 group-hover:visible invisible"> <span className="p-2 rounded-full hover:cursor-pointer hover:bg-slate-200 group-hover:visible invisible">
<FaEdit className="ml-auto text-md text-slate-400" /> <FaEdit className="ml-auto text-md text-slate-400" />
</span> </span>
</span> </span>
<span className="text-xs text-slate-300 hover:decoration-slate-400"> <span className="text-xs text-slate-300 hover:decoration-slate-400 hover:underline hover:cursor-pointer">
25 members {convo?.activeMembers.length} members
</span> </span>
</span> </span>
+1 -1
View File
@@ -45,7 +45,7 @@ export default function Me() {
} else if (currPage === QueryRoutes.createConvo) { } else if (currPage === QueryRoutes.createConvo) {
fullCleanPageContent = <CreateConversation />; fullCleanPageContent = <CreateConversation />;
} else if (currConvo) { } else if (currConvo) {
fullCleanPageContent = <ViewConvo conversationId={"woahhh"} />; fullCleanPageContent = <ViewConvo conversationId={currConvo} />;
} }
if (fullCleanPageContent) { if (fullCleanPageContent) {
+11 -11
View File
@@ -42,17 +42,17 @@ console.log("initialized firebase");
// Initialize firestore persistence for data caching // Initialize firestore persistence for data caching
export const firestoreDb = getFirestore(app); export const firestoreDb = getFirestore(app);
enableIndexedDbPersistence(firestoreDb).catch((err) => { // enableIndexedDbPersistence(firestoreDb).catch((err) => {
if (err.code == "failed-precondition") { // if (err.code == "failed-precondition") {
// Multiple tabs open, persistence can only be enabled // // Multiple tabs open, persistence can only be enabled
// in one tab at a a time. // // in one tab at a a time.
// ... // // ...
} else if (err.code == "unimplemented") { // } else if (err.code == "unimplemented") {
// The current browser does not support all of the // // The current browser does not support all of the
// features required to enable persistence // // features required to enable persistence
// ... // // ...
} // }
}); // });
setPersistence(getAuth(), browserSessionPersistence); setPersistence(getAuth(), browserSessionPersistence);