Skip to content

Commit

Permalink
fix: 无限滚动 #43
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Aug 25, 2023
1 parent 139d878 commit be69511
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/chat-suggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export function ChatSuggestions({ setInput, suggestions = [] }: ChatSuggestionsP

useEffect(() => {
setSuggestions(suggestions)
window.scrollBy(0, 400)
}, [suggestions, setSuggestions])
window.scrollBy(0, 800)
}, [])

return currentSuggestions?.length ? (
<div className="py-6">
Expand Down
6 changes: 2 additions & 4 deletions src/components/chat.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useCallback, useEffect, useMemo, useState } from 'react'
import { useEffect } from 'react'
import { useAtom } from 'jotai'
import { cn } from '@/lib/utils'
import { ChatList } from '@/components/chat-list'
Expand All @@ -18,7 +18,6 @@ import { useBing } from '@/lib/hooks/use-bing'
import { ChatMessageModel } from '@/lib/bots/bing/types'
import { ChatNotification } from './chat-notification'
import { Settings } from './settings'
import { ChatHistory } from './chat-history'

export type ChatProps = React.ComponentProps<'div'> & { initialMessages?: ChatMessageModel[] }

Expand Down Expand Up @@ -49,7 +48,6 @@ export default function Chat({ className }: ChatProps) {

return (
<div className={cn('flex flex-1 flex-col', bingStyle.toLowerCase())}>
<ChatHistory bot={bot} />
<div className="global-background" />
<Settings />
<div className={cn('flex-1 pb-16', className)}>
Expand All @@ -61,7 +59,7 @@ export default function Chat({ className }: ChatProps) {
<ChatList messages={messages} />
<ChatScrollAnchor trackVisibility={generating} />
<ChatNotification message={messages.at(-1)} bot={bot} />
<ChatSuggestions setInput={setInput} suggestions={messages.at(-1)?.suggestedResponses} />
{messages.at(-1)?.suggestedResponses && <ChatSuggestions setInput={setInput} suggestions={messages.at(-1)?.suggestedResponses} />}

{generating ? (
<div className="flex h-10 items-center justify-center my-4">
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function mockUser(cookies: Partial<{ [key: string]: string }>) {
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'User-Agent': ua!,
'x-ms-useragent': 'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.3 OS/Win32',
cookie: `_U=${_U}` || '',
cookie: `_U=${_U}`,
}
}

Expand Down

0 comments on commit be69511

Please sign in to comment.