mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
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:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user