From b29db11903f5a3f04d1423423203779bc7e781ff Mon Sep 17 00:00:00 2001 From: Nathanael Liu Date: Fri, 3 May 2024 20:01:52 +0000 Subject: [PATCH] fix: User View Navigation Regression --- apps/masterbots.ai/app/b/[id]/page.tsx | 20 ++++++---- apps/masterbots.ai/app/u/[slug]/page.tsx | 20 ++++++---- .../components/shared/account-details.tsx | 19 ++++++--- .../components/shared/thread-heading.tsx | 40 +++++++++++-------- .../shared/thread-list-accordion.tsx | 20 ++++++++-- .../components/shared/thread-list.tsx | 8 +++- 6 files changed, 84 insertions(+), 43 deletions(-) diff --git a/apps/masterbots.ai/app/b/[id]/page.tsx b/apps/masterbots.ai/app/b/[id]/page.tsx index 1c73e7e1..2fc8c4e4 100644 --- a/apps/masterbots.ai/app/b/[id]/page.tsx +++ b/apps/masterbots.ai/app/b/[id]/page.tsx @@ -1,9 +1,13 @@ -import { getChatbot, getBrowseThreads, getCategories } from '@/services/hasura' +import { + getChatbot, + getBrowseThreads + // getCategories +} from '@/services/hasura' import { botNames } from '@/lib/bots-names' import { ThreadList } from '@/components/shared/thread-list' import AccountDetails from '@/components/shared/account-details' -import { CategoryTabs } from '@/components/shared/category-tabs/category-tabs' -import { SearchInput } from '@/components/shared/search-input' +// import { CategoryTabs } from '@/components/shared/category-tabs/category-tabs' +// import { SearchInput } from '@/components/shared/search-input' import { toSlug } from '@/lib/url' export default async function BotThreadsPage({ @@ -11,7 +15,7 @@ export default async function BotThreadsPage({ }: { params: { id: string } }) { - const categories = await getCategories() + // const categories = await getCategories() let chatbot, threads chatbot = await getChatbot({ @@ -28,9 +32,9 @@ export default async function BotThreadsPage({ console.log(chatbot.categories) return ( -
- - +
+ {/* */} + {/* */}
- +
) diff --git a/apps/masterbots.ai/app/u/[slug]/page.tsx b/apps/masterbots.ai/app/u/[slug]/page.tsx index 3cd26965..d5e1696e 100644 --- a/apps/masterbots.ai/app/u/[slug]/page.tsx +++ b/apps/masterbots.ai/app/u/[slug]/page.tsx @@ -1,19 +1,19 @@ import { getBrowseThreads, - getCategories, + // getCategories, getUserInfoFromBrowse } from '@/services/hasura' import { ThreadList } from '@/components/shared/thread-list' import AccountDetails from '@/components/shared/account-details' -import { CategoryTabs } from '@/components/shared/category-tabs/category-tabs' -import { SearchInput } from '@/components/shared/search-input' +// import { CategoryTabs } from '@/components/shared/category-tabs/category-tabs' +// import { SearchInput } from '@/components/shared/search-input' export default async function BotThreadsPage({ params }: { params: { slug: string } }) { - const categories = await getCategories() + // const categories = await getCategories() const user = await getUserInfoFromBrowse(params.slug) if (!user) return
No user found.
const threads = await getBrowseThreads({ @@ -21,9 +21,9 @@ export default async function BotThreadsPage({ limit: 20 }) return ( -
- - +
+ {/* + */}
- +
) diff --git a/apps/masterbots.ai/components/shared/account-details.tsx b/apps/masterbots.ai/components/shared/account-details.tsx index f3346a62..4d077572 100644 --- a/apps/masterbots.ai/components/shared/account-details.tsx +++ b/apps/masterbots.ai/components/shared/account-details.tsx @@ -1,6 +1,7 @@ import Image from 'next/image' import Link from 'next/link' import { Separator } from '../ui/separator' +import { cn } from '@/lib/utils' export default function AccountDetails({ alt, @@ -17,7 +18,12 @@ export default function AccountDetails({ return (
-
+
{username
{category}
-
-
- {description ?
{description}
: ''} + {description && ( +
+
+
{description}
+
-
- + )}
Threads: {threadNum ?? 0} diff --git a/apps/masterbots.ai/components/shared/thread-heading.tsx b/apps/masterbots.ai/components/shared/thread-heading.tsx index 3fda2a67..780942ac 100644 --- a/apps/masterbots.ai/components/shared/thread-heading.tsx +++ b/apps/masterbots.ai/components/shared/thread-heading.tsx @@ -10,7 +10,9 @@ export function ThreadHeading({ response, question, copy = false, - chat = false + chat = false, + isUser = false, + isBot = false }: ThreadHeadingProps) { return (
@@ -20,11 +22,13 @@ export function ThreadHeading({ )} >
- + {!isBot && ( + + )}
{question} - {chat ? null : ( - <> - by - - - )} + {chat + ? null + : !isUser && ( + <> + by + + + )}
{copy ? : null} @@ -62,4 +68,6 @@ interface ThreadHeadingProps { question: string copy?: boolean chat?: boolean + isBot?: boolean + isUser?: boolean } diff --git a/apps/masterbots.ai/components/shared/thread-list-accordion.tsx b/apps/masterbots.ai/components/shared/thread-list-accordion.tsx index 575d896f..82d19915 100644 --- a/apps/masterbots.ai/components/shared/thread-list-accordion.tsx +++ b/apps/masterbots.ai/components/shared/thread-list-accordion.tsx @@ -16,7 +16,9 @@ import { createMessagePairs } from '@/lib/threads' export function ThreadListAccordion({ thread, - chat = false + chat = false, + isUser = false, + isBot = false }: ThreadListAccordionProps) { const [state, setState] = useSetState({ isOpen: false, @@ -35,10 +37,16 @@ export function ThreadListAccordion({ type="multiple" > {/* Frist level question and excerpt visible on lists */} - + @@ -60,7 +70,7 @@ export function ThreadListAccordion({ showHeading={false} thread={thread} initialMessagePairs={createMessagePairs(thread.messages)} - className='border-r-[transparent]' + className="border-r-[transparent]" />
@@ -72,4 +82,6 @@ export function ThreadListAccordion({ interface ThreadListAccordionProps extends DialogProps { thread: Thread chat?: boolean + isBot?: boolean + isUser?: boolean } diff --git a/apps/masterbots.ai/components/shared/thread-list.tsx b/apps/masterbots.ai/components/shared/thread-list.tsx index 7c724da3..32baf473 100644 --- a/apps/masterbots.ai/components/shared/thread-list.tsx +++ b/apps/masterbots.ai/components/shared/thread-list.tsx @@ -18,7 +18,9 @@ export function ThreadList({ initialThreads, filter, chat = false, - dialog = false + dialog = false, + isUser = false, + isBot = false }: ThreadListProps) { const { query } = useGlobalStore() const loadMoreRef = useRef(null) @@ -120,6 +122,8 @@ export function ThreadList({ defaultOpen={false} // we can have one open by default key={thread.threadId} thread={thread} + {...(isBot ? { isBot } : {})} + {...(isUser ? { isUser } : {})} /> ))}
@@ -134,4 +138,6 @@ interface ThreadListProps { chat?: boolean dialog?: boolean filter: GetBrowseThreadsParams + isUser?: boolean + isBot?: boolean }