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