Show shared chats without login popup shown to unauthenticated users

The login popup is an unnecessary distraction as you do not need
to be logged in to view shared chats.
This commit is contained in:
Debanjum
2025-08-31 23:31:16 -07:00
parent 52b1928023
commit 0bd4bf182c

View File

@@ -26,6 +26,7 @@ import { useIsDarkMode, useIsMobileWidth } from "@/app/common/utils";
import { UserPlusIcon } from "lucide-react";
import { useAuthenticatedData, UserProfile } from "@/app/common/auth";
import LoginPrompt from "../loginPrompt/loginPrompt";
import { usePathname } from "next/navigation";
async function openChat(userData: UserProfile | null | undefined) {
const unauthenticatedRedirectUrl = `/login?redirect=${encodeURIComponent(window.location.pathname)}`;
@@ -88,17 +89,21 @@ interface AppSidebarProps {
export function AppSidebar(props: AppSidebarProps) {
const isMobileWidth = useIsMobileWidth();
const { data, isLoading, error } = useAuthenticatedData();
const pathname = usePathname();
const { state, open, setOpen, openMobile, setOpenMobile, isMobile, toggleSidebar } =
useSidebar();
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
// Check if we're on a shared chat page
const isSharedChatPage = pathname?.startsWith("/share/chat");
useEffect(() => {
if (!isLoading && !data) {
if (!isLoading && !data && !isSharedChatPage) {
setShowLoginPrompt(true);
}
}, [isLoading, data]);
}, [isLoading, data, isSharedChatPage]);
return (
<Sidebar collapsible={"icon"} variant="sidebar" className="md:py-2">