mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
refactor: plugin loading logic (#3448)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { IconButton } from '@affine/component';
|
||||
import { SendIcon } from '@blocksuite/icons';
|
||||
import { contentLayoutAtom } from '@toeverything/plugin-infra/atom';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import type { ReactElement } from 'react';
|
||||
import { Suspense, useCallback, useState } from 'react';
|
||||
@@ -62,11 +61,7 @@ const DetailContentImpl = () => {
|
||||
};
|
||||
|
||||
export const DetailContent = (): ReactElement => {
|
||||
const layout = useAtomValue(contentLayoutAtom);
|
||||
const key = useAtomValue(openAIApiKeyAtom);
|
||||
if (layout === 'editor' || layout.second !== 'copilot') {
|
||||
return <></>;
|
||||
}
|
||||
if (!key) {
|
||||
return <span>Please set OpenAI API Key in the debug panel.</span>;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,13 @@ export const HeaderItem = (): ReactElement => {
|
||||
<IconButton
|
||||
onClick={useCallback(
|
||||
() =>
|
||||
// todo: abstract a context function to open a new tab
|
||||
setLayout(layout => {
|
||||
if (layout === 'editor') {
|
||||
return {
|
||||
direction: 'horizontal',
|
||||
first: 'editor',
|
||||
second: 'copilot',
|
||||
second: '@affine/copilot',
|
||||
splitPercentage: 70,
|
||||
};
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user