fix: prevent closed artifacts from reopening when switching chats (#1280)
This commit is contained in:
parent
4e0e2222ac
commit
6a02d4fa9a
1 changed files with 3 additions and 4 deletions
|
|
@ -6,18 +6,17 @@ import { artifactDefinitions } from "./artifact";
|
||||||
import { useDataStream } from "./data-stream-provider";
|
import { useDataStream } from "./data-stream-provider";
|
||||||
|
|
||||||
export function DataStreamHandler() {
|
export function DataStreamHandler() {
|
||||||
const { dataStream } = useDataStream();
|
const { dataStream,setDataStream } = useDataStream();
|
||||||
|
|
||||||
const { artifact, setArtifact, setMetadata } = useArtifact();
|
const { artifact, setArtifact, setMetadata } = useArtifact();
|
||||||
const lastProcessedIndex = useRef(-1);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!dataStream?.length) {
|
if (!dataStream?.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newDeltas = dataStream.slice(lastProcessedIndex.current + 1);
|
const newDeltas = dataStream.slice();
|
||||||
lastProcessedIndex.current = dataStream.length - 1;
|
setDataStream([]);
|
||||||
|
|
||||||
for (const delta of newDeltas) {
|
for (const delta of newDeltas) {
|
||||||
const artifactDefinition = artifactDefinitions.find(
|
const artifactDefinition = artifactDefinitions.find(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue