chore: remove universal chat code (#2194)

This commit is contained in:
Joel
2024-01-25 11:47:35 +08:00
committed by GitHub
parent 77636945fb
commit bec998ab94
26 changed files with 10 additions and 1720 deletions

View File

@@ -58,7 +58,6 @@ export type IMainProps = {
isInstalledApp?: boolean
installedAppInfo?: InstalledApp
isSupportPlugin?: boolean
isUniversalChat?: boolean
}
const Main: FC<IMainProps> = ({

View File

@@ -11,7 +11,6 @@ import AppInfo from '@/app/components/share/chat/sidebar/app-info'
// import Card from './card'
import type { ConversationItem, SiteInfo } from '@/models/share'
import { fetchConversations } from '@/service/share'
import { fetchConversations as fetchUniversalConversations } from '@/service/universal-chat'
export type ISidebarProps = {
copyRight: string
@@ -25,7 +24,6 @@ export type ISidebarProps = {
isClearPinnedConversationList: boolean
isInstalledApp: boolean
installedAppId?: string
isUniversalChat?: boolean
siteInfo: SiteInfo
onMoreLoaded: (res: { data: ConversationItem[]; has_more: boolean }) => void
onPinnedMoreLoaded: (res: { data: ConversationItem[]; has_more: boolean }) => void
@@ -50,7 +48,6 @@ const Sidebar: FC<ISidebarProps> = ({
isClearPinnedConversationList,
isInstalledApp,
installedAppId,
isUniversalChat,
siteInfo,
onMoreLoaded,
onPinnedMoreLoaded,
@@ -66,13 +63,7 @@ const Sidebar: FC<ISidebarProps> = ({
const [hasPinned, setHasPinned] = useState(false)
const checkHasPinned = async () => {
let res: any
if (isUniversalChat)
res = await fetchUniversalConversations(undefined, true)
else
res = await fetchConversations(isInstalledApp, installedAppId, undefined, true)
const res = await fetchConversations(isInstalledApp, installedAppId, undefined, true) as any
setHasPinned(res.data.length > 0)
}
@@ -85,13 +76,13 @@ const Sidebar: FC<ISidebarProps> = ({
checkHasPinned()
}, [controlUpdateList])
const maxListHeight = (isInstalledApp || isUniversalChat) ? 'max-h-[30vh]' : 'max-h-[40vh]'
const maxListHeight = (isInstalledApp) ? 'max-h-[30vh]' : 'max-h-[40vh]'
return (
<div
className={
cn(
(isInstalledApp || isUniversalChat) ? 'tablet:h-[calc(100vh_-_74px)]' : '',
(isInstalledApp) ? 'tablet:h-[calc(100vh_-_74px)]' : '',
'shrink-0 flex flex-col bg-white pc:w-[244px] tablet:w-[192px] mobile:w-[240px] border-r border-gray-200 mobile:h-screen',
)
}
@@ -125,7 +116,6 @@ const Sidebar: FC<ISidebarProps> = ({
isClearConversationList={isClearPinnedConversationList}
isInstalledApp={isInstalledApp}
installedAppId={installedAppId}
isUniversalChat={isUniversalChat}
onMoreLoaded={onPinnedMoreLoaded}
isNoMore={isPinnedNoMore}
isPinned={true}
@@ -149,7 +139,6 @@ const Sidebar: FC<ISidebarProps> = ({
isClearConversationList={isClearConversationList}
isInstalledApp={isInstalledApp}
installedAppId={installedAppId}
isUniversalChat={isUniversalChat}
onMoreLoaded={onMoreLoaded}
isNoMore={isNoMore}
isPinned={false}
@@ -160,11 +149,9 @@ const Sidebar: FC<ISidebarProps> = ({
</div>
</div>
{!isUniversalChat && (
<div className="flex flex-shrink-0 pr-4 pb-4 pl-4">
<div className="text-gray-400 font-normal text-xs">© {copyRight} {(new Date()).getFullYear()}</div>
</div>
)}
<div className="flex flex-shrink-0 pr-4 pb-4 pl-4">
<div className="text-gray-400 font-normal text-xs">© {copyRight} {(new Date()).getFullYear()}</div>
</div>
</div>
)
}

View File

@@ -9,7 +9,6 @@ import RenameModal from '../rename-modal'
import Item from './item'
import type { ConversationItem } from '@/models/share'
import { fetchConversations, renameConversation } from '@/service/share'
import { fetchConversations as fetchUniversalConversations, renameConversation as renameUniversalConversation } from '@/service/universal-chat'
import Toast from '@/app/components/base/toast'
export type IListProps = {
@@ -20,7 +19,6 @@ export type IListProps = {
onListChanged?: (newList: ConversationItem[]) => void
isClearConversationList: boolean
isInstalledApp: boolean
isUniversalChat?: boolean
installedAppId?: string
onMoreLoaded: (res: { data: ConversationItem[]; has_more: boolean }) => void
isNoMore: boolean
@@ -38,7 +36,6 @@ const List: FC<IListProps> = ({
onListChanged,
isClearConversationList,
isInstalledApp,
isUniversalChat,
installedAppId,
onMoreLoaded,
isNoMore,
@@ -56,11 +53,7 @@ const List: FC<IListProps> = ({
let lastId = !isClearConversationList ? list[list.length - 1]?.id : undefined
if (lastId === '-1')
lastId = undefined
let res: any
if (isUniversalChat)
res = await fetchUniversalConversations(lastId, isPinned)
else
res = await fetchConversations(isInstalledApp, installedAppId, lastId, isPinned)
const res = await fetchConversations(isInstalledApp, installedAppId, lastId, isPinned) as any
const { data: conversations, has_more }: any = res
onMoreLoaded({ data: conversations, has_more })
}
@@ -93,11 +86,7 @@ const List: FC<IListProps> = ({
setIsSaving()
const currId = currentConversation.id
try {
if (isUniversalChat)
await renameUniversalConversation(currId, newName)
else
await renameConversation(isInstalledApp, installedAppId, currId, newName)
await renameConversation(isInstalledApp, installedAppId, currId, newName)
Toast.notify({
type: 'success',