mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
fix(core): optimize request chat cards fn (#7331)
This commit is contained in:
@@ -47,6 +47,7 @@ import {
|
||||
MultiTabSidebarBody,
|
||||
MultiTabSidebarHeaderSwitcher,
|
||||
sidebarTabs,
|
||||
type TabOnLoadFn,
|
||||
} from '../../../modules/multi-tab-sidebar';
|
||||
import {
|
||||
RightSidebarService,
|
||||
@@ -74,9 +75,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
||||
const docCollection = workspace.docCollection;
|
||||
const mode = useLiveData(doc.mode$);
|
||||
const { appSettings } = useAppSettingHelper();
|
||||
const [tabOnLoad, setTabOnLoad] = useState<
|
||||
((component: HTMLElement) => void) | null
|
||||
>(null);
|
||||
const [tabOnLoad, setTabOnLoad] = useState<TabOnLoadFn | null>(null);
|
||||
|
||||
const isActiveView = useIsActiveView();
|
||||
// TODO(@eyhn): remove jotai here
|
||||
@@ -110,12 +109,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
||||
// * The right sidebar is not open
|
||||
// * Chat panel is not activated
|
||||
if (!opened || !actived) {
|
||||
const callback = async (chatPanel: HTMLElement) => {
|
||||
const chatCards = await AIProvider.requestChatCardsElement(chatPanel);
|
||||
if (!chatCards) return;
|
||||
if (chatCards.temporaryParams) return;
|
||||
chatCards.temporaryParams = params;
|
||||
};
|
||||
const callback = AIProvider.genRequestChatCardsFn(params);
|
||||
setTabOnLoad(() => callback);
|
||||
} else {
|
||||
setTabOnLoad(null);
|
||||
|
||||
Reference in New Issue
Block a user