Skip to content

Commit

Permalink
fix(masterbots.ai): cherry-pick conflict typo
Browse files Browse the repository at this point in the history
  • Loading branch information
AndlerRL committed May 20, 2024
1 parent 2be0044 commit fd782c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { ThreadAccordionServer } from '@/components/shared/thread-accordion.serv

export { generateMbMetadata as generateMetadata } from '@/lib/metadata'

// ? For site mapping, we should remove this route and make all redirections and link shares to the /b/ route.
// ? It is only valid to have /[category] when navigating between categories on browse.
export default async function ThreadPage({ params }: ThreadPageProps) {
const thread = await getThread({
threadId: params.threadId
})

const messagePairs = await getMessagePairs(thread.threadId)

return <ThreadAccordionServer messagePairs={messagePairs} thread={thread} />
Expand Down
16 changes: 11 additions & 5 deletions apps/masterbots.ai/app/b/[id]/[threadId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { BrowseThread } from '@/components/browse-thread'
import { ChatPageProps } from '@/app/chat/[chatbot]/[threadId]/page'
import { getThread } from '@/app/actions'

import { ThreadPageProps } from '@/app/(browse)/[category]/[threadId]/page'
import { getMessagePairs, getThread } from '@/app/actions'
import { ThreadAccordionServer } from '@/components/shared/thread-accordion.server'

export { generateMbMetadata as generateMetadata } from '@/lib/metadata'

export default async function ChatPage({ params }: ChatPageProps) {
// ? When a user clicks to a thread, the URL gets updated to this one.
// ? When a user navigates within the bot page and click to a thread, the URL gets updated to this one.
// * When sharing, the URL gets updated to this one.
export default async function ChatPage({ params }: ThreadPageProps) {
const thread = await getThread({
threadId: params.threadId,
})
return <BrowseThread thread={thread} />
const messagePairs = await getMessagePairs(thread.threadId)

return <ThreadAccordionServer messagePairs={messagePairs} thread={thread} />
}
10 changes: 4 additions & 6 deletions apps/masterbots.ai/lib/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { getThread } from '@/services/hasura'
import type { Metadata } from 'next'
import { getThreadLink } from './threads'
import { getThread } from '@/app/actions';

export async function generateMbMetadata({
params
}: {
params: any;
}): Promise<Metadata | undefined> {
const threadId = params?.threadId
const thread = await getThread({ threadId, jwt: '' })
const thread = await getThread({ threadId })
if (!thread) return

const firstQuestion =
thread.messages.find(m => m.role === 'user')?.content || 'not found'
const firstResponse =
thread.messages.find(m => m.role === 'assistant')?.content || 'not found'
const firstQuestion = thread.firstMessage.content || 'not found'
const firstResponse = thread.firstAnswer.content || 'not found'

const data = {
title: firstQuestion,
Expand Down

0 comments on commit fd782c8

Please sign in to comment.