fix : endpoint option should hide on exist conversation

This commit is contained in:
Wentao Lyu 2023-04-01 03:02:16 +08:00
parent ec47879edc
commit 5cb59885ec
3 changed files with 23 additions and 65 deletions

View file

@ -1,38 +1,16 @@
import React, { useState, useEffect, forwardRef } from 'react';
import React from 'react';
import { useRecoilValue, useRecoilState } from 'recoil';
import { cn } from '~/utils';
import { Button } from '../../ui/Button.tsx';
import { Tabs, TabsList, TabsTrigger } from '../../ui/Tabs.tsx';
import store from '~/store';
// function BingStyles(props, ref) {
// const [conversation, setConversation] = useRecoilState(store.conversation) || {};
// const { endpoint, conversationId, jailbreak, toneStyle } = conversation;
// const messages = useRecoilValue(store.messages);
// const isBing = endpoint === 'bingAI';
// const show = isBing && (!conversationId || messages?.length === 0 || props.show);
// const defaultClasses =
// 'p-2 rounded-md min-w-[75px] font-normal bg-white/[.60] dark:bg-gray-700 text-black text-xs';
// const defaultSelected = cn(defaultClasses, 'font-medium data-[state=active]:text-white text-xs text-white');
// const selectedClass = val => val + '-tab ' + defaultSelected;
// const changeHandler = value => {
// setConversation(prevState => ({ ...prevState, toneStyle: value }));
// };
function BingAIOptions({ ref }) {
function BingAIOptions() {
const [conversation, setConversation] = useRecoilState(store.conversation) || {};
const messages = useRecoilValue(store.messages);
const { endpoint, conversationId } = conversation;
if (endpoint !== 'bingAI') return null;
const isBing = endpoint === 'bingAI';
const show = isBing && (!conversationId || messages?.length === 0);
if (conversationId !== 'new') return null;
const changeHandler = value => {
setConversation(prevState => ({ ...prevState, toneStyle: value }));
@ -47,16 +25,6 @@ function BingAIOptions({ ref }) {
const defaultSelected = cn(defaultClasses, 'font-medium data-[state=active]:text-white text-xs text-white');
const selectedClass = val => val + '-tab ' + defaultSelected;
// <Button
// type="button"
// className={
// cardStyle +
// ' flex h-[40px] items-center justify-center px-4 hover:bg-slate-50 dark:hover:bg-gray-600'
// }
// onClick={triggerAdvancedMode}
// >
// <span className="w-full text-center text-xs font-medium font-normal">More</span>
// </Button>
return (
<div className={' flex w-full items-center justify-center gap-2'}>
<Tabs
@ -66,7 +34,6 @@ function BingAIOptions({ ref }) {
' flex h-[40px] items-center justify-center px-0 hover:bg-slate-50 dark:hover:bg-gray-600'
}
onValueChange={changeHandler}
// ref={ref}
>
<TabsList className="bg-white/[.60] dark:bg-gray-700">
<TabsTrigger