mirror of https://github.com/buster-so/buster.git
use a key reset instead
This commit is contained in:
parent
474b1c24be
commit
f678fdc79c
|
@ -69,7 +69,6 @@ const useEditorServerUpdates = ({
|
|||
isStreaming: boolean;
|
||||
}) => {
|
||||
const hasInitialized = useRef(false);
|
||||
const lastValue = useRef<string>('');
|
||||
|
||||
const { run: throttleStreamUpdate } = useThrottleFn(
|
||||
(v: string) => {
|
||||
|
@ -84,12 +83,6 @@ const useEditorServerUpdates = ({
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
// Reset initialization state if we're switching to a different report content
|
||||
if (value !== lastValue.current) {
|
||||
hasInitialized.current = false;
|
||||
lastValue.current = value || '';
|
||||
}
|
||||
|
||||
if (editor && isStreaming) {
|
||||
hasInitialized.current = true;
|
||||
throttleStreamUpdate(value);
|
||||
|
@ -102,16 +95,6 @@ const useEditorServerUpdates = ({
|
|||
autoSelect: false,
|
||||
});
|
||||
});
|
||||
} else if (editor && value && !hasInitialized.current && !isEmptyEditor(editor)) {
|
||||
// Handle case where editor has content but we need to switch to different report
|
||||
hasInitialized.current = true;
|
||||
markdownToPlatejs(editor, value).then((elements) => {
|
||||
editor.tf.reset();
|
||||
editor.tf.init({
|
||||
value: elements,
|
||||
autoSelect: false,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
editor?.getPlugin(StreamContentPlugin)?.api.streamContent.stop();
|
||||
}
|
||||
|
|
|
@ -7,10 +7,8 @@ import DynamicReportEditor from '@/components/ui/report/DynamicReportEditor';
|
|||
import type { IReportEditor } from '@/components/ui/report/ReportEditor';
|
||||
import { ReportEditorSkeleton } from '@/components/ui/report/ReportEditorSkeleton';
|
||||
import type { BusterReportEditor } from '@/components/ui/report/types';
|
||||
import { SCROLL_AREA_VIEWPORT_CLASS } from '@/components/ui/scroll-area/ScrollArea';
|
||||
import { useGetScrollAreaRef } from '@/components/ui/scroll-area/useGetScrollAreaRef';
|
||||
import { useMemoizedFn } from '@/hooks/useMemoizedFn';
|
||||
import { useMount } from '@/hooks/useMount';
|
||||
import { useEditorContext } from '@/layouts/AssetContainer/ReportAssetContainer';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { chatQueryKeys } from '../../api/query_keys/chat';
|
||||
|
@ -95,6 +93,7 @@ export const ReportPageController: React.FC<{
|
|||
>
|
||||
{report ? (
|
||||
<DynamicReportEditor
|
||||
key={reportId}
|
||||
value={content}
|
||||
placeholder="Start typing..."
|
||||
className={commonClassName}
|
||||
|
|
Loading…
Reference in New Issue