Files
outline/app/hooks/useFocusedComment.ts
Tom Moor ea885133ac Notifications interface (#5354)
Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
2023-05-20 07:47:32 -07:00

16 lines
552 B
TypeScript

import { useLocation } from "react-router-dom";
import useQuery from "~/hooks/useQuery";
import useStores from "./useStores";
export default function useFocusedComment() {
const { comments } = useStores();
const location = useLocation<{ commentId?: string }>();
const query = useQuery();
const focusedCommentId = location.state?.commentId || query.get("commentId");
const comment = focusedCommentId ? comments.get(focusedCommentId) : undefined;
return comment?.parentCommentId
? comments.get(comment.parentCommentId)
: comment;
}