Spaces:
Sleeping
Sleeping
wuyiqunLu
commited on
fix: chat visible to logout user (#47)
Browse files<img width="1519" alt="image"
src="https://github.com/landing-ai/vision-agent-ui/assets/132986242/aea90f4a-63a3-4304-acfc-8b50693d685c">
- app/all/layout.tsx +10 -11
- app/chat/layout.tsx +11 -12
app/all/layout.tsx
CHANGED
|
@@ -14,22 +14,21 @@ export default async function Layout({ children }: ChatLayoutProps) {
|
|
| 14 |
|
| 15 |
if (!isAdmin) {
|
| 16 |
redirect('/');
|
| 17 |
-
} else if (!user) {
|
| 18 |
-
return null;
|
| 19 |
}
|
| 20 |
-
|
| 21 |
const chats = await adminGetAllKVChats();
|
| 22 |
|
| 23 |
return (
|
| 24 |
<div className="relative flex h-[calc(100vh_-_theme(spacing.16))] overflow-hidden">
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
<
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
<Suspense fallback={<Loading />}>
|
| 34 |
<div className="group w-full overflow-auto pl-0 animate-in duration-300 ease-in-out peer-[[data-state=open]]:lg:pl-[250px] peer-[[data-state=open]]:xl:pl-[300px]">
|
| 35 |
{children}
|
|
|
|
| 14 |
|
| 15 |
if (!isAdmin) {
|
| 16 |
redirect('/');
|
|
|
|
|
|
|
| 17 |
}
|
|
|
|
| 18 |
const chats = await adminGetAllKVChats();
|
| 19 |
|
| 20 |
return (
|
| 21 |
<div className="relative flex h-[calc(100vh_-_theme(spacing.16))] overflow-hidden">
|
| 22 |
+
{user && (
|
| 23 |
+
<div
|
| 24 |
+
data-state="open"
|
| 25 |
+
className="peer absolute inset-y-0 z-30 hidden border-r bg-muted duration-300 ease-in-out translate-x-0 lg:flex lg:w-[250px] xl:w-[300px] h-full flex-col dark:bg-zinc-950 overflow-auto py-2"
|
| 26 |
+
>
|
| 27 |
+
<Suspense fallback={<Loading />}>
|
| 28 |
+
<ChatSidebarList chats={chats} isAdminView />
|
| 29 |
+
</Suspense>
|
| 30 |
+
</div>
|
| 31 |
+
)}
|
| 32 |
<Suspense fallback={<Loading />}>
|
| 33 |
<div className="group w-full overflow-auto pl-0 animate-in duration-300 ease-in-out peer-[[data-state=open]]:lg:pl-[250px] peer-[[data-state=open]]:xl:pl-[300px]">
|
| 34 |
{children}
|
app/chat/layout.tsx
CHANGED
|
@@ -9,22 +9,21 @@ interface ChatLayoutProps {
|
|
| 9 |
}
|
| 10 |
|
| 11 |
export default async function Layout({ children }: ChatLayoutProps) {
|
| 12 |
-
const { email,
|
| 13 |
const chats = await getKVChats();
|
| 14 |
-
if (!user) {
|
| 15 |
-
return null;
|
| 16 |
-
}
|
| 17 |
|
| 18 |
return (
|
| 19 |
<div className="relative flex h-[calc(100vh_-_theme(spacing.16))] overflow-hidden">
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
<
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
<Suspense fallback={<Loading />}>
|
| 29 |
<div className="group w-full overflow-auto pl-0 animate-in duration-300 ease-in-out peer-[[data-state=open]]:lg:pl-[250px]">
|
| 30 |
{children}
|
|
|
|
| 9 |
}
|
| 10 |
|
| 11 |
export default async function Layout({ children }: ChatLayoutProps) {
|
| 12 |
+
const { email, user } = await authEmail();
|
| 13 |
const chats = await getKVChats();
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
return (
|
| 16 |
<div className="relative flex h-[calc(100vh_-_theme(spacing.16))] overflow-hidden">
|
| 17 |
+
{user && (
|
| 18 |
+
<div
|
| 19 |
+
data-state={email ? 'open' : 'closed'}
|
| 20 |
+
className="peer absolute inset-y-0 z-30 hidden border-r bg-muted duration-300 ease-in-out -translate-x-full data-[state=open]:translate-x-0 lg:flex lg:w-[250px] h-full flex-col overflow-auto py-2"
|
| 21 |
+
>
|
| 22 |
+
<Suspense fallback={<Loading />}>
|
| 23 |
+
<ChatSidebarList chats={chats} />
|
| 24 |
+
</Suspense>
|
| 25 |
+
</div>
|
| 26 |
+
)}
|
| 27 |
<Suspense fallback={<Loading />}>
|
| 28 |
<div className="group w-full overflow-auto pl-0 animate-in duration-300 ease-in-out peer-[[data-state=open]]:lg:pl-[250px]">
|
| 29 |
{children}
|